### Install Prerequisites and Configure AWS Source: https://eksctl.io/getting-started Commands to install the Kubernetes CLI, configure AWS credentials, and verify the identity. ```bash brew install kubernetes-cli ``` ```bash aws configure ``` ```bash aws sts get-caller-identity ``` -------------------------------- ### Complete ClusterConfig example Source: https://eksctl.io/usage/cloudwatch-cluster-logging A full ClusterConfig example demonstrating both log type selection and retention period configuration. ```yaml apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: cluster-11 region: eu-west-2 nodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 1 cloudWatch: clusterLogging: enableTypes: ["audit", "authenticator"] logRetentionInDays: 7 ``` -------------------------------- ### Install eksctl with Homebrew Source: https://eksctl.io/getting-started Commands to add the AWS tap and install the eksctl binary on Linux or macOS. ```bash brew tap aws/tap ``` ```bash brew install aws/tap/eksctl ``` -------------------------------- ### CLI flag examples for --node-ami Source: https://eksctl.io/usage/custom-ami-support Examples of using the --node-ami flag with the create cluster command to either auto-resolve the AMI or specify a custom AMI ID. ```bash eksctl create cluster --node-ami=auto # with a custom ami id eksctl create cluster --node-ami=ami-custom1234 ``` -------------------------------- ### Minimal Spot Instance Configuration Source: https://eksctl.io/usage/spot-instances A minimal configuration example for enabling spot instances in a nodegroup. ```yaml nodeGroups: - name: ng-1 instancesDistribution: instanceTypes: ["t3.small", "t3.medium"] # At least one instance type should be specified ``` -------------------------------- ### Example CIDR range configuration Source: https://eksctl.io/usage/nodegroup-with-custom-subnet An example of adding a new CIDR range to an existing VPC configuration. ```text 192.168.0.0/19 -> existing CIDR + 192.169.0.0/19 -> new CIDR ``` -------------------------------- ### Download and install eksctl on Unix Source: https://eksctl.io/installation Downloads the latest eksctl release for Unix-like systems, optionally verifies the checksum, and installs the binary to /usr/local/bin. Set ARCH to arm64 for ARM systems. ```bash # for ARM systems, set ARCH to: `arm64` ARCH=amd64 PLATFORM=$(uname -s)_$ARCH curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz" # (Optional) Verify checksum curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz sudo install -m 0755 /tmp/eksctl /usr/local/bin && rm /tmp/eksctl ``` -------------------------------- ### Config file example for node groups Source: https://eksctl.io/usage/custom-ami-support Configuration file structure for defining node groups and managed node groups with custom AMIs or auto-resolution, including an example of an overrideBootstrapCommand. ```yaml nodeGroups: - name: ng1 instanceType: p2.xlarge amiFamily: AmazonLinux2 ami: auto - name: ng2 instanceType: m5.large amiFamily: AmazonLinux2 ami: ami-custom1234 managedNodeGroups: - name: m-ng-2 amiFamily: AmazonLinux2 ami: ami-custom1234 instanceType: m5.large overrideBootstrapCommand: | #!/bin/bash /etc/eks/bootstrap.sh ``` -------------------------------- ### List Capabilities Source: https://eksctl.io/usage/capabilities View all capabilities in your cluster using the eksctl get capabilities command. ```bash eksctl get capabilities --cluster my-cluster ``` -------------------------------- ### ClusterConfig object example Source: https://eksctl.io/usage/nodegroup-with-custom-subnet A YAML configuration example for defining a nodegroup with specific subnets. ```yaml # A simple example of ClusterConfig object with two nodegroups: --- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: cluster-3 region: eu-north-1 nodeGroups: - name: new-subnet-nodegroup instanceType: m5.large desiredCapacity: 1 subnets: - subnet-id1 - subnet-id2 ``` -------------------------------- ### Install NVIDIA device plugin for versions 0.15.0 and above Source: https://eksctl.io/usage/gpu-support Manually apply the NVIDIA device plugin configuration for newer versions. ```bash kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin//deployments/static/nvidia-device-plugin.yml ``` -------------------------------- ### Configure addon values using YAML Source: https://eksctl.io/usage/addons Example of providing configuration values for an addon using the YAML format in a configuration file. ```yaml addons: - name: coredns configurationValues: |- replicaCount: 2 ``` -------------------------------- ### Install NVIDIA device plugin for older versions Source: https://eksctl.io/usage/gpu-support Manually apply the NVIDIA device plugin configuration for older versions. ```bash kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin//nvidia-device-plugin.yml ``` -------------------------------- ### Example ClusterConfig with Subnet Configuration Source: https://eksctl.io/usage/troubleshooting A sample configuration file specifying subnets for a VPC in the us-east-1 region. ```yaml apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: test region: us-east-1 vpc: subnets: public: us-east-1a: {id: subnet-11111111} us-east-1b: {id: subnet-22222222} private: us-east-1a: {id: subnet-33333333} us-east-1b: {id: subnet-44444444} nodeGroups: [] ``` -------------------------------- ### Create managed nodegroups with launch template Source: https://eksctl.io/usage/launch-template-support Example configuration for a cluster with two managed nodegroups using a specified launch template ID and version. ```yaml # managed-cluster.yaml # A cluster with two managed nodegroups --- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: managed-cluster region: us-west-2 managedNodeGroups: - name: managed-ng-1 launchTemplate: id: lt-12345 version: "2" # optional (uses the default launch template version if unspecified) - name: managed-ng-2 minSize: 2 desiredCapacity: 2 maxSize: 4 labels: role: worker tags: nodegroup-name: managed-ng-2 privateNetworking: true launchTemplate: id: lt-12345 ``` -------------------------------- ### Define Addons in ClusterConfig Source: https://eksctl.io/usage/addons Example configuration file for defining addons with specific versions, tags, and IAM policies or roles. ```yaml apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: example-cluster region: us-west-2 iam: withOIDC: true addons: - name: vpc-cni # all below properties are optional version: 1.7.5 tags: team: eks # you can specify at most one of: attachPolicyARNs: - arn:aws:iam::account:policy/AmazonEKS_CNI_Policy # or serviceAccountRoleARN: arn:aws:iam::account:role/AmazonEKSCNIAccess # or attachPolicy: Statement: - Effect: Allow Action: - ec2:AssignPrivateIpAddresses - ec2:AttachNetworkInterface - ec2:CreateNetworkInterface - ec2:DeleteNetworkInterface - ec2:DescribeInstances - ec2:DescribeTags - ec2:DescribeNetworkInterfaces - ec2:DescribeInstanceTypes - ec2:DetachNetworkInterface - ec2:ModifyNetworkInterfaceAttribute - ec2:UnassignPrivateIpAddresses Resource: '*' ``` -------------------------------- ### Get Specific Capability Source: https://eksctl.io/usage/capabilities Get a specific capability by name using the eksctl get capability command. ```bash eksctl get capability --cluster my-cluster --name my-capability ``` -------------------------------- ### Create addon with auto-apply configuration Source: https://eksctl.io/usage/pod-identity-associations Run the create command with the auto-apply configuration enabled. ```bash eksctl create addon -f config.yaml 2024-05-13 15:38:58 [ℹ] "addonsConfig.autoApplyPodIdentityAssociations" is set to true; will lookup recommended pod identity configuration for "vpc-cni" addon ``` -------------------------------- ### Example of all supported add-on policies Source: https://eksctl.io/usage/iam-policies Shows a nodeGroups configuration with all supported add-on policies enabled. The policies include imageBuilder, autoScaler, externalDNS, certManager, appMesh, appMeshPreview, ebs, fsx, efs, awsLoadBalancerController, xRay, and cloudWatch. ```yaml nodeGroups: - name: ng-1 instanceType: m5.xlarge desiredCapacity: 1 iam: withAddonPolicies: imageBuilder: true autoScaler: true externalDNS: true certManager: true appMesh: true appMeshPreview: true ebs: true fsx: true efs: true awsLoadBalancerController: true xRay: true cloudWatch: true ``` -------------------------------- ### Get nodegroups with eksctl get nodegroups Source: https://eksctl.io/usage/nodegroup-unmanaged Lists the nodegroups in the cluster. Used to identify the old nodegroup before creating a replacement. ```bash eksctl get nodegroups --cluster= --region= ``` -------------------------------- ### Create cluster with manual NVIDIA plugin installation Source: https://eksctl.io/usage/gpu-support Disable the automatic installation of the NVIDIA Kubernetes device plugin using the --install-nvidia-plugin=false flag. ```bash eksctl create cluster --node-type=p2.xlarge --install-nvidia-plugin=false ``` -------------------------------- ### Create addon with explicit pod identity configuration Source: https://eksctl.io/usage/pod-identity-associations Run the create command using the configuration file containing the pod identity associations. ```bash eksctl create addon -f config.yaml 2024-05-13 15:38:58 [ℹ] pod identity associations are set for "vpc-cni" addon; will use these to configure required IAM permissions ``` -------------------------------- ### Describe available addons by Kubernetes version Source: https://eksctl.io/usage/addons Discovers available addons for a specific Kubernetes version. ```bash eksctl utils describe-addon-versions --kubernetes-version ``` -------------------------------- ### Get all identity mappings Source: https://eksctl.io/usage/iam-identity-mappings Retrieves all IAM identity mappings for a specified cluster. ```bash eksctl get iamidentitymapping --cluster --region= ``` -------------------------------- ### Upgrade control plane using a config file Source: https://eksctl.io/usage/cluster-upgrade This example shows a ClusterConfig file and the corresponding `eksctl upgrade cluster` command. The `metadata.version` field specifies the target version. Only the current version or one version higher is allowed. ```bash cat cluster1.yaml --- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: cluster-1 region: eu-north-1 version: "1.16" eksctl upgrade cluster --config-file cluster1.yaml ``` -------------------------------- ### EC2NodeClass configuration Source: https://eksctl.io/usage/eksctl-karpenter Example EC2NodeClass definition. Replace ${CLUSTER_NAME} with your actual cluster name. ```yaml apiVersion: karpenter.k8s.aws/v1 kind: EC2NodeClass metadata: name: example annotations: kubernetes.io/description: "Example EC2NodeClass" spec: role: "eksctl-KarpenterNodeRole-${CLUSTER_NAME}" # replace with your cluster name subnetSelectorTerms: - tags: karpenter.sh/discovery: "${CLUSTER_NAME}" # replace with your cluster name securityGroupSelectorTerms: - tags: karpenter.sh/discovery: "${CLUSTER_NAME}" # replace with your cluster name amiSelectorTerms: - alias: al2023@latest # Amazon Linux 2023 ``` -------------------------------- ### Create Addon from Config File Source: https://eksctl.io/usage/addons Command to create an addon explicitly after cluster creation using a configuration file. ```bash eksctl create addon -f config.yaml ``` -------------------------------- ### NodePool configuration Source: https://eksctl.io/usage/eksctl-karpenter Example NodePool definition. The nodeClassRef must match the name of an EC2NodeClass. ```yaml apiVersion: karpenter.sh/v1 kind: NodePool metadata: name: example annotations: kubernetes.io/description: "Example NodePool" spec: template: spec: requirements: - key: kubernetes.io/arch operator: In values: ["amd64"] - key: kubernetes.io/os operator: In values: ["linux"] - key: karpenter.sh/capacity-type operator: In values: ["on-demand"] - key: karpenter.k8s.aws/instance-category operator: In values: ["c", "m", "r"] - key: karpenter.k8s.aws/instance-generation operator: Gt values: ["2"] nodeClassRef: group: karpenter.k8s.aws kind: EC2NodeClass name: example # must match the name of an EC2NodeClass ``` -------------------------------- ### Get Fargate profile details Source: https://eksctl.io/usage/fargate-support Retrieve the configuration of the created Fargate profile in YAML format. ```bash eksctl get fargateprofile --cluster ridiculous-painting-1574859263 -o yaml - name: fp-default podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-1574859263-ServiceRole-EIFQOH0S1GE7 selectors: - namespace: default - namespace: kube-system subnets: - subnet-0b3a5522f3b48a742 - subnet-0c35f1497067363f3 - subnet-0a29aa00b25082021 ``` -------------------------------- ### Get addon configuration values Source: https://eksctl.io/usage/addons Retrieves the current configuration values for an addon in YAML format. ```bash eksctl get addon --cluster my-cluster --output yaml ``` ```yaml - ConfigurationValues: '{"replicaCount":3}' IAMRole: "" Issues: null Name: coredns NewerVersion: "" Status: ACTIVE Version: v1.8.7-eksbuild.3 ``` -------------------------------- ### Create Addon via CLI Flags Source: https://eksctl.io/usage/addons Command to create an addon by specifying the name, version, and service account role ARN directly. ```bash eksctl create addon --name vpc-cni --version 1.7.5 --service-account-role-arn ``` -------------------------------- ### Get access entries by cluster name Source: https://eksctl.io/usage/access-entries Retrieve all access entries for a specific cluster by name. ```bash eksctl get accessentry --cluster my-cluster ``` -------------------------------- ### Create capabilities after cluster creation Source: https://eksctl.io/usage/capabilities Use this command to create capabilities on an existing cluster using the configuration file. ```bash eksctl create capability -f config.yaml ``` -------------------------------- ### Get identity mappings matching an ARN Source: https://eksctl.io/usage/iam-identity-mappings Retrieves identity mappings that match a specific ARN. ```bash eksctl get iamidentitymapping --cluster --region= --arn arn:aws:iam::123456:role/testing-role ``` -------------------------------- ### Create addon with CLI flag for auto-apply Source: https://eksctl.io/usage/pod-identity-associations Use the --auto-apply-pod-identity-associations flag to enable automatic configuration via the CLI. ```bash eksctl create addon --cluster my-cluster --name vpc-cni --auto-apply-pod-identity-associations ``` -------------------------------- ### Define Nodegroup with Labels and Taints Source: https://eksctl.io/usage/autoscaling Example of a nodegroup definition containing specific labels and taints. ```yaml nodeGroups: - name: ng1-public ... labels: my-cool-label: pizza taints: key: feaster value: "true" effect: NoSchedule ``` -------------------------------- ### Create cluster with Spot instances using --spot flag Source: https://eksctl.io/usage/spot-instances Creates a new EKS cluster with a managed nodegroup using Spot instances. The --spot flag enables Spot, and --instance-types specifies the allowed instance types. ```bash eksctl create cluster --spot --instance-types=c3.large,c4.large,c5.large ``` -------------------------------- ### Get pod identity associations by namespace Source: https://eksctl.io/usage/pod-identity-associations Retrieve pod identity associations filtered by a specific namespace. ```bash eksctl get podidentityassociation --cluster my-cluster --namespace default ``` -------------------------------- ### Create Addon in Custom Namespace Source: https://eksctl.io/usage/addons Command to deploy an addon to a custom namespace using the --namespace-config flag. ```bash eksctl create addon --name aws-ebs-csi-driver --namespace-config 'namespace=custom-namespace' ``` -------------------------------- ### Get pod identity associations by cluster name Source: https://eksctl.io/usage/pod-identity-associations Retrieve all pod identity associations for a specific cluster. ```bash eksctl get podidentityassociation --cluster my-cluster ``` -------------------------------- ### Retrieve addon namespace configuration Source: https://eksctl.io/usage/addons Displays the namespace configuration for an addon retrieved via the get command. ```yaml - ConfigurationValues: "" IAMRole: "" Issues: null Name: aws-ebs-csi-driver NamespaceConfig: namespace: custom-namespace NewerVersion: "" PodIdentityAssociations: null Status: ACTIVE Version: v1.47.0-eksbuild.1 ``` -------------------------------- ### Download and install eksctl using Git Bash Source: https://eksctl.io/installation Downloads the latest eksctl release for Windows using Git Bash, optionally verifies the checksum, and extracts it to $HOME/bin. Set ARCH to arm64 for ARM systems. ```bash # for ARM systems, set ARCH to: `arm64` ARCH=amd64 PLATFORM=windows_$ARCH curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.zip" # (Optional) Verify checksum curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check unzip eksctl_$PLATFORM.zip -d $HOME/bin rm eksctl_$PLATFORM.zip ``` -------------------------------- ### Describe available addons by cluster Source: https://eksctl.io/usage/addons Discovers available addons based on the Kubernetes version of the specified cluster. ```bash eksctl utils describe-addon-versions --cluster ``` -------------------------------- ### Get access entries by config file Source: https://eksctl.io/usage/access-entries Retrieve all access entries associated with a cluster defined in a configuration file. ```bash eksctl get accessentry -f config.yaml ``` -------------------------------- ### Create Capability via CLI Source: https://eksctl.io/usage/capabilities Create a capability with an inline policy using the eksctl CLI command. ```bash eksctl create capability \ --cluster my-cluster \ --name my-capability \ --type ACK \ --attach-policy '{"Statement":[{"Effect":"Allow","Action":["s3:GetObject"],"Resource":"*"}]}' ``` -------------------------------- ### Enable Fish completion Source: https://eksctl.io/installation Commands to create the completions directory and generate the fish completion script. ```bash mkdir -p ~/.config/fish/completions eksctl completion fish > ~/.config/fish/completions/eksctl.fish ``` -------------------------------- ### Output in Different Formats Source: https://eksctl.io/usage/capabilities Get capabilities output in YAML or JSON format using the --output flag. ```bash eksctl get capabilities --cluster my-cluster --output yaml eksctl get capabilities --cluster my-cluster --output json ``` -------------------------------- ### Kubectl Authorization Error Messages Source: https://eksctl.io/usage/troubleshooting Examples of authorization errors that may occur when nodes are deployed in a private subnet. ```text Error attaching, falling back to logs: unable to upgrade connection: Authorization error (user=kube-apiserver-kubelet-client, verb=create, resource=nodes, subresource=proxy) ``` ```text Error from server (InternalError): Internal error occurred: Authorization error (user=kube-apiserver-kubelet-client, verb=get, resource=nodes, subresource=proxy) ``` -------------------------------- ### Create cluster with specific addons Source: https://eksctl.io/usage/addons Explicitly define the addons you want to install while disabling the default networking addons. ```yaml addonsConfig: disableDefaultAddons: true addons: - name: kube-proxy - name: coredns ``` ```bash eksctl create cluster -f cluster.yaml ``` -------------------------------- ### Create cluster from ClusterConfig file Source: https://eksctl.io/usage/instance-selector Deploys a cluster using the specified YAML configuration file containing instance selector settings. ```bash eksctl create cluster -f instance-selector-cluster.yaml ``` -------------------------------- ### Check eksctl anywhere version Source: https://eksctl.io/usage/eksctl-anywhere Verify that the eksctl-anywhere binary is correctly installed and accessible in your PATH by checking its version. ```bash eksctl anywhere version v0.5.0 ```