Skip to content

accessEntries reconciliation causes continuous delete+recreate cycle, breaking auth #6003

Description

@vterdunov

What happened

When accessEntries is defined in AWSManagedControlPlane, CAPA deletes and recreates the access entry on every reconcile loop (~7 seconds). The access policy association is lost during this cycle because the next delete occurs before the policy is successfully re-associated.

This results in intermittent Unauthorized and Forbidden errors for all users authenticating via the affected access entry, making the cluster unusable for human operators.

What I expected

CAPA should detect that the access entry already exists with the correct configuration and skip reconciliation (no delete+create).

How to reproduce

  1. Create an EKS cluster via CAPA with the following accessEntries in AWSManagedControlPlane:
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: AWSManagedControlPlane
metadata:
  name: my-cluster
spec:
  eksClusterName: my-cluster
  region: eu-central-1
  version: v1.35.1
  accessConfig:
    authenticationMode: api_and_config_map
  accessEntries:
    - principalARN: "arn:aws:iam::123456789012:role/aws-reserved/sso.amazonaws.com/eu-central-1/AWSReservedSSO_AdministratorAccess_abc123def456"
      type: standard
      accessPolicies:
        - policyARN: "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
          accessScope:
            type: cluster
  endpointAccess:
    private: true
    public: false
  1. Wait for the cluster to become Ready.
  2. Observe that kubectl get ns intermittently returns Unauthorized or Forbidden.

Evidence

Access entry createdAt changes every ~7 seconds (entry is being deleted and recreated):

$ for i in 1 2 3; do aws eks describe-access-entry ... --query 'accessEntry.createdAt'; sleep 7; done
"2024-01-01T10:00:00.044000+00:00"
"2024-01-01T10:00:07.355000+00:00"
"2024-01-01T10:00:14.683000+00:00"

Access policy is empty after recreation — CAPA creates the entry but fails to associate the policy before the next reconcile deletes it:

$ aws eks list-associated-access-policies --cluster-name my-cluster --principal-arn "arn:aws:iam::..."
{
    "associatedAccessPolicies": []
}

Kubernetes events showed 707 reconciliations before event deduplication kicked in (count stopped incrementing while createdAt continued to change every 7s):

$ kubectl get events -n my-cluster --field-selector reason=SuccessfulReconcileAccessEntries
707    2024-01-01T10:00:00Z    2024-01-01T11:39:00Z

Stopping CAPA controller confirms it is the cause — after scaling the deployment to 0, createdAt stops changing and (once policy is manually re-associated) auth works stably.

CAPA controller logs do not explicitly log access entry create/delete operations at Info level, making this issue difficult to diagnose. The only indication is the Kubernetes event count and the changing createdAt timestamp.

Suspected root cause

The access entry reconciler detects drift on every cycle even when the entry matches the desired state, triggering a delete+create. The sequence is: detect drift → delete entry (removes policy association) → create entry → (should associate policy, but next reconcile deletes before association completes).

Environment

  • CAPA version: v2.11.1
  • EKS version: v1.35.1
  • Kubernetes (management cluster): v1.35
  • Auth mode: API_AND_CONFIG_MAP
  • Endpoint: private only
  • Principal ARN: SSO role with full IAM path (/aws-reserved/sso.amazonaws.com/...)

When accessEntries is not defined in the spec, CAPA logs "no access entries defined, skipping reconcile" and does not touch existing entries.

Metadata

Metadata

Assignees

Labels

lifecycle/activeIndicates that an issue or PR is actively being worked on by a contributor.needs-prioritytriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions