Deploying CAPA with EKS Enterprise
Creating your first CAPA Cluster
Make sure the following software is installed before continuing with these instructions:
- github cli>= 2.3.0 (source)
- kubectl(source)
- eksctl(source)
- aws cli(source)
- clusterctl>= v1.0.1 (source)
- clusterawsadm>= v1.1.0 (source)
The AWS_ACCESS_KEY_IDand AWS_SECRET_ACCESS_KEY of a user should be configured either via aws configure or exported in the current shell.
The GITHUB_TOKEN should be set as an environment variable in the current shell. It should have permissions to create Pull Requests against the cluster config repo.
If you've followed the Installation guide you should have a management cluster ready to roll.
1. Configure a capi provider
See Cluster API Providers page for more details on providers. He're we'll continue with eks and capa as an example.
# Enable support for `ClusterResourceSet`s for automatically installing CNIs
export EXP_EKS=true
export EXP_MACHINE_POOL=true
export CAPA_EKS_IAM=true
export EXP_CLUSTER_RESOURCE_SET=true
clusterctl init --infrastructure aws
2. Add a template
See CAPI Templates page for more details on this topic. Once we load a template we can use it in the UI to create clusters!
Download the template below to your config repository path, then commit and push to your git origin.
apiVersion: templates.weave.works/v1alpha2
kind: GitOpsTemplate
metadata:
  name: aws-eks-dev
  namespace: default
  annotations:
    templates.weave.works/inject-prune-annotation: "true"
    templates.weave.works/add-common-bases: "true"
  labels:
    weave.works/template-type: cluster
spec:
  description: AWS EKS Development Cluster
  params:
    - name: CLUSTER_NAME
      description: The name for this cluster.
    - name: AWS_REGION
      description: AWS Region to create cluster
      options: ["us-east-1", "eu-central-1", "eu-west-2", "us-west-2"]
    - name: KUBERNETES_VERSION
      description: EKS Kubernetes version to use
      options: ["v1.19.8", "v1.20.7", "v1.21.2"]
    - name: WORKER_MACHINE_COUNT
      description: Number of worker nodes to create.
  resourcetemplates:
    - contents:
        - apiVersion: gitops.weave.works/v1alpha1
          kind: GitopsCluster
          metadata:
            name: "${CLUSTER_NAME}"
            namespace: default
            labels:
              weave.works/capi: bootstrap
          spec:
            capiClusterRef:
              name: "${CLUSTER_NAME}"
        - apiVersion: cluster.x-k8s.io/v1beta1
          kind: Cluster
          metadata:
            name: ${CLUSTER_NAME}
            namespace: default
            labels:
              weave.works/capi: bootstrap
          spec:
            clusterNetwork:
              pods:
                cidrBlocks:
                  - 192.168.0.0/16
            controlPlaneRef:
              apiVersion: controlplane.cluster.x-k8s.io/v1beta1
              kind: AWSManagedControlPlane
              name: ${CLUSTER_NAME}-control-plane
            infrastructureRef:
              apiVersion: controlplane.cluster.x-k8s.io/v1beta1
              kind: AWSManagedControlPlane
              name: ${CLUSTER_NAME}-control-plane
        - apiVersion: controlplane.cluster.x-k8s.io/v1beta1
          kind: AWSManagedControlPlane
          metadata:
            name: ${CLUSTER_NAME}-control-plane
            namespace: default
          spec:
            region: ${AWS_REGION}
            sshKeyName: default
            version: ${KUBERNETES_VERSION}
            eksClusterName: ${CLUSTER_NAME}
        - apiVersion: cluster.x-k8s.io/v1beta1
          kind: MachinePool
          metadata:
            name: ${CLUSTER_NAME}-pool-0
            namespace: default
          spec:
            clusterName: ${CLUSTER_NAME}
            replicas: ${WORKER_MACHINE_COUNT}
            template:
              spec:
                bootstrap:
                  dataSecretName: ""
                clusterName: ${CLUSTER_NAME}
                infrastructureRef:
                  apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
                  kind: AWSManagedMachinePool
                  name: ${CLUSTER_NAME}-pool-0
        - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
          kind: AWSManagedMachinePool
          metadata:
            name: ${CLUSTER_NAME}-pool-0
            namespace: default
          spec: {}