This is a companion to the tutorial at openSUSE 2023.
To complete the tutorial yourself you will need to install the following:
- kind
- clusterctl
- Rancher Desktop or Docker Engine/Desktop
- kubectl
- (optional)k9s
If you have a Mac with Apple Silicon some of the sections will have alternative commands.
- Download kind-cluster-with-extramounts.yaml
- Run the following command in a terminal:
kind create cluster --config kind-cluster-with-extramounts.yaml
- Download clusterctl.yaml
- Move it to the following directory: ~/.cluster-api/clusterctl.yaml
You will probably need to create the ~/.cluster-api directory.
This step isn't required as we are using different providers.
We need to install the Docker and RKE2 providers.
- In a terminal run the following:
clusterctl init -i docker2 -b rke2 -c rke2
We need to install the Docker and Kubeadm providers.
- In a terminal run the following:
export EXP_CLUSTER_RESOURCE_SET=true
clusterctl init -i docker
- Open a terminal and run the following:
export CABPR_CP_REPLICAS=1
export CABPR_WK_REPLICAS=1
export KUBERNETES_VERSION=v1.26.4
clusterctl generate cluster test1 --from https://github.com/capi-samples/opensuse-23/blob/main/templates/online-default.yaml > cluster.yaml
- Open a terminal and run the following:
export CONTROL_PLANE_MACHINE_COUNT=1
export WORKER_MACHINE_COUNT=1
export KUBERNETES_VERSION=v1.26.4
clusterctl generate cluster test1 --from https://github.com/capi-samples/opensuse-23/blob/main/templates/kubeadm-docker.yaml > cluster.yaml
- Apply the cluster yaml to your management cluster
kubectl apply -f cluster.yaml
- Watch the Cluster being provisioned:
kubectl get clusters -A -w
- Watch the Machine being provisioned:
kubectl get machines -A -w
- In your terminal run the following to get the kubeconfig for the child cluster:
clusterctl get kubeconfig test1 > test.kubeconfig
- Then use it to explore the cluster:
kubectl --kubeconfig test.kubeconfig get pods -A
- In your terminal run the following to get the kubeconfig for the child cluster:
kind get kubeconfig --name test1 > test.kubeconfig
- Then use it to explore the cluster:
kubectl --kubeconfig test.kubeconfig get pods -A
Lets scale the control plane to 3 nodes:
- Open 2 terminals
- In the first terminal watch the nodes of the child cluster:
kubectl --kubeconfig test.kubeconfig get nodes -w
- In the second terminal edit the control plane:
kubectl edit rke2controlplane/test1-control-plane
- In the editor find spec.replicas and change it to 3
- Save and exit from editor
- Watch the nodes being added to the child cluster
- In the second terminal edit the control plane:
kubectl edit kubeadmcontrolplane/test1-control-plane
- In the editor find spec.replicas and change it to 3
- Save and exit from editor
- Watch the nodes being added to the child cluster
- Delete the child cluster by running:
kubectl delete cluster test1
- Delete the management cluster by running:
kind delete cluster --name=capi-test