In previous steps, you created a new Management cluster, which is self-managed. When you use these steps to create new Managed clusters, they will become Attached clusters under your Management Cluster.

When creating Managed clusters, you do not need to create and move CAPI objects, or install the Kommander component. Those tasks are only done on Management clusters!

Choose a Workspace for the New Cluster

  1. If you have an existing Workspace name, run this command to find the name:
    ⚠️ NOTE: If you need to create a new Workspace, follow the instructions to Create a Workspace.

    kubectl get workspace -A
    CODE
  2. When you have the Workspace name, set the WORKSPACE_NAMESPACE environment variable:

    export WORKSPACE_NAMESPACE=<workspace_namespace>
    CODE

Name Your Cluster

Follow these steps:

  1. Give your cluster a unique name suitable for your environment.

    In AWS it is critical that the name is unique, as no two clusters in the same AWS account can have the same name.

  2. Set the environment variable:

    export CLUSTER_NAME=<aws-additional>
    CODE

The cluster name may only contain the following characters: a-z, 0-9, ., and -. Cluster creation will fail if the name has capital letters. See Kubernetes for more naming information.

3. Execute this command to create your Kubernetes cluster using any relevant flags but note that the --self-managed is absent so that this cluster can be attached to your previously created Management Cluster.

dkp create cluster aws --cluster-name=${CLUSTER_NAME} \
--additional-tags=owner=$(whoami) \
--with-aws-bootstrap-credentials=true \
--vpc-id=${AWS_VPC_ID} \
--ami=${AWS_AMI_ID} \
--subnet-ids=${AWS_SUBNET_IDS} \
--internal-load-balancer=true \
--additional-security-group-ids=${AWS_ADDITIONAL_SECURITY_GROUPS} \
--registry-mirror-url=${REGISTRY_URL} \
--registry-mirror-cacert=${REGISTRY_CA} \
--registry-mirror-username=${REGISTRY_USERNAME} \
--registry-mirror-password=${REGISTRY_PASSWORD} \
--namespace=${WORKSPACE_NAMESPACE}
CODE

Manually Attach a DKP CLI Cluster to the Management Cluster

  1. Find out the name of the created Cluster, so you can reference it later:

    kubectl -n <workspace_namespace> get clusters
    CODE
  2. Attach the cluster by creating a KommanderCluster:

    cat << EOF | kubectl apply -f -
    apiVersion: kommander.mesosphere.io/v1beta1
    kind: KommanderCluster
    metadata:
      name: <cluster_name>
      namespace: <workspace_namespace>
    spec:
      kubeconfigRef:
        name: <cluster_name>-kubeconfig
      clusterRef:
        capiCluster:
          name: <cluster_name>
    EOF
    CODE

Once you have existing clusters or want to create new clusters to attach, there are many ways to attach a cluster with various requirements and restrictions. To see all the options, visit the section in documentation Day 2 - Attach an Existing Kubernetes Cluster.

Next Step:

Day 2 - Cluster Operations Management