AWS Controllers for Kubernetes (ACK) Documentation
repository·main·Indexed 25 days ago
https://github.com/aws-controllers-k8s/communityAWS Controllers for Kubernetes (ACK) is an open-source project that extends the Kubernetes API to manage AWS resources. It allows developers to provision and manage AWS services, such as RDS, SQS, and S3, using standard Kubernetes manifests and Custom Resource Definitions (CRDs). The documentation covers installation via Helm, the resource lifecycle, deprecation policies, and a list of available service controllers.
What's inside AWS Controllers for Kubernetes (ACK)
- AWS Controllers for Kubernetes (ACK) allows you to define and manage AWS service resources directly from a Kubernetes cluster using Custom Resource Definitions (CRDs) and custom controllers. This enables you to provision managed services like databases, message queues, and object stores as part of your Kubernetes application lifecycle, providing a unified way to manage applications and their AWS dependencies.
Understand ACK Resource Definition and API Inference
mainACK resources are automatically generated from AWS API model files (JSON files containing Actions and Shapes). The code generator identifies which AWS operations become Kubernetes Custom Resource Definitions (CRDs) by looking for operations that start with
Createfollowed by a singular noun (e.g.,CreateBucketbecomes aBucketresource).An ACK resource consists of two primary parts:
- Spec: Defines the desired state, derived from the
Inputshape of theCreateoperation. - Status: Defines the observed state, derived from the
Outputshape of theCreateoperation.
The OpenAPIv3 Validating Schema for these CRDs is generated using the
controller-gen crdCLI command.- Spec: Defines the desired state, derived from the
Understand the ACK release deliverables
mainACK releases consist of two primary deliverables shipped to users:
- Controller container image: The packaged controller used in Kubernetes environments.
- Helm chart release: The package used for deploying the controller via Helm.
Container images are built using a base image defined in the project's code (linked to the
code-generatorDockerfile) and environment variables/images defined in thetest-infraProw jobs.Understand the relationship between ACK and cdk8s
mainACK and cdk8s are complementary tools:
- cdk8s is a framework used to define Kubernetes applications and reusable abstractions (including Custom Resources) using programming languages.
- ACK controllers watch for specific Custom Resources (CRs).
Workflow: You can use
cdk8sto generate the Kubernetes resources, and ACK will then use those resources to provision the corresponding AWS infrastructure.Understand the IAM Role Selector design
mainThe IAM Role Selector is a proposed redesign of the current Cross Account Resource Management (CARM) mechanism in AWS Controllers for Kubernetes (ACK). While CARM was focused on cross-account management, the IAM Role Selector is designed for general "multi-role" usage, allowing different resources to interact with AWS services using different IAM roles.
Key Improvements over CARM:
- Typed Configuration: Moves away from untyped ConfigMaps and annotations to improve tooling support and error feedback.
- Dynamic Selection: Replaces hard-coded namespace mappings with selectors, allowing for more dynamic configuration.
- Simplified Semantics: Removes the confusing requirement of mapping roles to arbitrary "account ID" strings.
Core Requirements:
- Feature Parity with CARM: Supports mapping IAM roles to specific namespaces and scoping roles to specific ACK services.
- Role Chaining: Supports multi-role assumption/role chaining for both cross-account and same-account usage.
- Extensibility: Designed to eventually support resource-level IAM role selection (though this is out of scope for the initial implementation).
Contribution Overview for ACK
mainThis documentation provides context for contributors interested in enhancing the AWS Controllers for Kubernetes (ACK) platform, developing specific service controllers, or understanding the ACK architecture. The project is community-driven and focuses on open development, code generation, and a consistent Kubernetes experience for managing AWS resources.Understand the Kubernetes Resource Model (KRM) in ACK
mainACK resources follow the Kubernetes Resource Model (KRM). An ACK
Objectconsists of metadata and aSpecfield representing the desired state.An
Objectincludes:- GroupVersionKind (GVK): Defines the API version and resource type (e.g.,
s3.services.k8s.aws/v1alpha1:Bucket). - Metadata: Contains the
Name,Namespace,Labels, andAnnotations. - Spec: A struct containing the desired state of the resource. Fields in the
Specare mapped to AWS API parameters (e.g.,Spec.Namemight be passed to aCreateBucketAPI call).
Users interact with these objects using YAML manifests via CLI tools like
kubectl.apiVersion: s3.services.k8s.aws/v1alpha1 kind: Bucket metadata: name: my-amazing-bucket annotations: pronounced-as: boo-kay spec: name: my-amazing-bucket- GroupVersionKind (GVK): Defines the API version and resource type (e.g.,
Understand ACK drift detection and remediation
mainACK controllers detect 'drift'—when an actor other than the controller (such as a person or another program) modifies an AWS resource—by periodically comparing the actual state of the resource in AWS against the desired state defined in Kubernetes.
By default, ACK controllers attempt to detect drift once every 10 hours after a resource has been marked with the
ResourceSynced = truecondition. If a difference is detected, the controller initiates a reconciliation loop to return the resource to its desired state.Understand the ACK platform code generation pipeline
mainThe ACK platform uses a code generation
pipelineto transformaws-sdkshapes into Kubernetes resources. The process involves several stages:- API Inference: Discovering the structure of API resources and their relationships.
- Model Generation: The
modelcommand takesaws-sdkandgenerator.yaml(represented asackgenconfig) as input to produce anackmodel(serialized JSON). - Code Generation: Downstream commands like
apisandcontrollerconsume theackmodelto generate the final Go code.
Key terminology:
ackgenconfig: The internal representation ofgenerator.yamlused as input to the code-generator.ackmodel: The output of the API inference stage, containing discovered CRDs and fields.shape: The original AWS SDK models, operations, and structs.
Understand the ACK resource lifecycle
mainAWS Controllers for Kubernetes (ACK) allows you to manage AWS resources by describing their desired state using Kubernetes Custom Resources (CRs).
The workflow follows these steps:
- Manifest Submission: A user issues a
kubectl applycommand with a manifest describing the AWS resource (e.g.,Kind: s3.services.k8s.aws/Bucket). - API Validation: The Kubernetes API server validates the user's permissions and the manifest's format, then stores the CR in
etcd. - Controller Notification: The specific ACK service controller (running as a Pod) is notified of the new CR.
- AWS Provisioning: The ACK controller calls the corresponding AWS API (e.g., S3
CreateBucket) to provision the resource. - Status Update: The controller updates the CR's
Statusfield in the Kubernetes API with information returned from the AWS API.
- Manifest Submission: A user issues a
Understand AWS credential determination in ACK
mainACK service controllers use the
aws-sdk-golibrary to communicate with AWS APIs. When a controller starts, it creates anaws-sdk-goSessionobject which automatically looks for credentials in a specific order:AWS_PROFILE: If set, the controller uses the specified profile from the configured credentials file.AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY: If both are set as environment variables, they are used.AWS_WEB_IDENTITY_TOKEN_FILE: If set, the controller loads credentials from the JSON web token (JWT) in the file pointed to by this variable. This is the standard mechanism for IAM Roles for Service Accounts (IRSA).- Shared Credentials File: If no other method is found, the controller looks for a credentials file at the location specified by
AWS_SHARED_CREDENTIALS_FILE(or$HOME/.aws/credentialsif the variable is unset) and uses the[default]profile.
Compare ACK EKS controller with Kubernetes Cluster API
mainThe ACK service controller for EKS is not a replacement for Kubernetes Cluster API (CAPI). They serve different purposes:
Feature Kubernetes Cluster API (CAPI) ACK EKS Controller Design Goal Generic way to create K8s clusters anywhere. Built directly from the EKS API spec for AWS. Source of Truth Infrastructure (VPC, etc.) is managed via CAPI. Managed via AWS/EKS APIs. Flexibility Abstracted for general Kubernetes clusters. Full EKS API flexibility (Managed Node Groups, Fargate). IAM Scope Requires broad permissions (CAPA) to provision VPC, gateways, etc. Can be scoped to specific ACK controllers. Services Often relies on services running inside the cluster (metrics/logging). Can leverage AWS services like CloudWatch.