sigs.k8s.io/cluster-api@v1.6.3/docs/book/src/tasks/experimental-features/ignition.md (about)

     1  # Experimental Feature: Ignition Bootstrap Config (alpha)
     2  
     3  The default configuration engine for bootstrapping workload cluster machines is [cloud-init](https://cloudinit.readthedocs.io/). **Ignition** is an alternative engine used by Linux distributions such as [Flatcar Container Linux](https://www.flatcar.org/docs/latest/provisioning/ignition/) and [Fedora CoreOS](https://docs.fedoraproject.org/en-US/fedora-coreos/producing-ign/) and therefore should be used when choosing an Ignition-based distribution as the underlying OS for workload clusters.
     4  
     5  <aside class="note warning">
     6  
     7  <h1>Note</h1>
     8  
     9  This initial implementation uses Ignition **v2** and was tested with **Flatcar Container Linux** only. Future releases are expected to add Ignition **v3** support and cover more Linux distributions.
    10  
    11  </aside>
    12  
    13  <aside class="note warning">
    14  
    15  <h1>Note</h1>
    16  
    17  If using ignition with CAPD you should take care of setting `kubeletExtraArgs` for the `kindest/node` image in use,
    18  because default CAPD templates do not include anymore those settings since when the cloud-init shim for CAPD is automatically taking care of this.
    19  An example of how to set `kubeletExtraArgs` for the `kindest/node` can be found under `cluster-api/test/e2e/data/infrastructure-docker/main/cluster-template-ignition`.
    20  
    21  Hopefully, this will be automated for Ignition too in a future release.
    22  
    23  </aside>
    24  
    25  This guide explains how to deploy an AWS workload cluster using Ignition.
    26  
    27  ## Prerequisites
    28  
    29  - [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) installed locally
    30  - [clusterawsadm](https://cluster-api-aws.sigs.k8s.io/introduction.html#clusterawsadm) installed locally - download from the [releases](https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases) page of the AWS provider
    31  - [kind](https://kind.sigs.k8s.io/) and [Docker](https://www.docker.com/) installed locally (when using kind to create a management cluster)
    32  
    33  ## Configure a management cluster
    34  
    35  Follow [this](../../user/quick-start.md#install-andor-configure-a-kubernetes-cluster) section of the quick start guide to deploy a Kubernetes cluster or connect to an existing one.
    36  
    37  Follow [this](../../user/quick-start.md#install-clusterctl) section of the quick start guide to install `clusterctl`.
    38  
    39  ## Initialize the management cluster
    40  
    41  Before workload clusters can be deployed, Cluster API components must be deployed to the management cluster.
    42  
    43  Initialize the management cluster:
    44  
    45  ```bash
    46  export AWS_REGION=us-east-1
    47  export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
    48  export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
    49  
    50  # Workload clusters need to call the AWS API as part of their normal operation.
    51  # The following command creates a CloudFormation stack which provisions the
    52  # necessary IAM resources to be used by workload clusters.
    53  clusterawsadm bootstrap iam create-cloudformation-stack
    54  
    55  # The management cluster needs to call the AWS API in order to manage cloud
    56  # resources for workload clusters. The following command tells clusterctl to
    57  # store the AWS credentials provided before in a Kubernetes secret where they
    58  # can be retrieved by the AWS provider running on the management cluster.
    59  export AWS_B64ENCODED_CREDENTIALS=$(clusterawsadm bootstrap credentials encode-as-profile)
    60  
    61  # Enable the feature gates controlling Ignition bootstrap.
    62  export EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION=true # Used by the kubeadm bootstrap provider
    63  export EXP_BOOTSTRAP_FORMAT_IGNITION=true # Used by the AWS provider
    64  
    65  # Initialize the management cluster.
    66  clusterctl init --infrastructure aws
    67  ```
    68  
    69  ## Generate a workload cluster configuration
    70  
    71  ```bash
    72  # Deploy the workload cluster in the following AWS region.
    73  export AWS_REGION=us-east-1
    74  
    75  # Authorize the following SSH public key on cluster nodes.
    76  export AWS_SSH_KEY_NAME=my-key
    77  
    78  # Ignition bootstrap data needs to be stored in an S3 bucket so that nodes can
    79  # read them at boot time. Store Ignition bootstrap data in the following bucket.
    80  export AWS_S3_BUCKET_NAME=my-bucket
    81  
    82  # Set the EC2 machine size for controllers and workers.
    83  export AWS_CONTROL_PLANE_MACHINE_TYPE=t3a.small
    84  export AWS_NODE_MACHINE_TYPE=t3a.small
    85  
    86  clusterctl generate cluster ignition-cluster \
    87      --from https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/main/templates/cluster-template-flatcar.yaml \
    88      --kubernetes-version v1.28.0 \
    89      --worker-machine-count 2 \
    90      > ignition-cluster.yaml
    91  ```
    92  
    93  NOTE: Only certain Kubernetes versions have pre-built Kubernetes AMIs. See [list](https://cluster-api-aws.sigs.k8s.io/topics/images/built-amis) of published pre-built Kubernetes AMIs.
    94  
    95  ## Apply the workload cluster
    96  
    97  ```bash
    98  kubectl apply -f ignition-cluster.yaml
    99  ```
   100  
   101  Wait for the control plane of the workload cluster to become initialized:
   102  
   103  ```bash
   104  kubectl get kubeadmcontrolplane ignition-cluster-control-plane
   105  ```
   106  
   107  This could take a while. When the control plane is initialized, the `INITIALIZED` field should be `true`:
   108  
   109  ```bash
   110  NAME                             CLUSTER            INITIALIZED   API SERVER AVAILABLE   REPLICAS   READY   UPDATED   UNAVAILABLE   AGE    VERSION
   111  ignition-cluster-control-plane   ignition-cluster   true                                 1                  1         1             7m7s   v1.22.2
   112  ```
   113  
   114  ## Connect to the workload cluster
   115  
   116  Generate a kubeconfig for the workload cluster:
   117  
   118  ```bash
   119  clusterctl get kubeconfig ignition-cluster > ./kubeconfig
   120  ```
   121  
   122  Set `kubectl` to use the generated kubeconfig:
   123  
   124  ```bash
   125  export KUBECONFIG=$(pwd)/kubeconfig
   126  ```
   127  
   128  Verify connectivity with the workload cluster's API server:
   129  
   130  ```bash
   131  kubectl cluster-info
   132  ```
   133  
   134  Sample output:
   135  
   136  ```bash
   137  Kubernetes control plane is running at https://ignition-cluster-apiserver-284992524.us-east-1.elb.amazonaws.com:6443
   138  CoreDNS is running at https://ignition-cluster-apiserver-284992524.us-east-1.elb.amazonaws.com:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
   139  
   140  To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
   141  ```
   142  
   143  ## Deploy a CNI plugin
   144  
   145  A [CNI plugin](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) must be deployed to the workload cluster for the cluster to become ready. We use [Calico](https://www.tigera.io/project-calico/) here, however other CNI plugins could be used, too.
   146  
   147  ```bash
   148  kubectl apply -f https://docs.projectcalico.org/v3.20/manifests/calico.yaml
   149  ```
   150  
   151  Ensure all cluster nodes become ready:
   152  
   153  ```bash
   154  kubectl get nodes
   155  ```
   156  
   157  Sample output:
   158  
   159  ```bash
   160  NAME                                            STATUS   ROLES                  AGE   VERSION
   161  ip-10-0-122-154.us-east-1.compute.internal   Ready    control-plane,master   14m   v1.22.2
   162  ip-10-0-127-59.us-east-1.compute.internal    Ready    <none>                 13m   v1.22.2
   163  ip-10-0-89-169.us-east-1.compute.internal    Ready    <none>                 13m   v1.22.2
   164  ```
   165  
   166  ## Clean up
   167  
   168  Delete the workload cluster (from a shell connected to the *management* cluster):
   169  
   170  ```bash
   171  kubectl delete cluster ignition-cluster
   172  ```
   173  
   174  ## Caveats
   175  
   176  ### Supported infrastructure providers
   177  
   178  Cluster API has multiple [infrastructure providers](../../user/concepts.md#infrastructure-provider) which can be used to deploy workload clusters.
   179  
   180  The following infrastructure providers already have Ignition support:
   181  
   182  - [AWS](https://cluster-api-aws.sigs.k8s.io/)
   183  
   184  Ignition support will be added to more providers in the future.