This tutorial introduces how to create a nested controlplane. CAPN should work with any standard
Kubernetes cluster out of box, but for demo purposes, in this tutorial, we will use
a kind
cluster as the management cluster as well as the nested workload cluster.
Please install the latest version of kind and kubectl
git clone https://github.com/kubernetes-sigs/cluster-api-provider-nested
cd cluster-api-provider-nested
kind create cluster --name=capn
Cert Manager is a soft dependency for the Cluster API components to enable mutating and validating webhooks to be auto deployed. For more detailed instructions go Cert Manager Installion.
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml
As a cluster API~(CAPI) provider, CAPN requires core components of CAPI to be setup.
We need to deploy the unreleased version of CAPI for v1alpha4
API support.
git clone [email protected]:kubernetes-sigs/cluster-api.git
cd cluster-api
make release-manifests
# change feature flags on core
sed -i'' -e 's@- --feature-gates=.*@- --feature-gates=MachinePool=false,ClusterResourceSet=true@' out/core-components.yaml
kubectl apply -f out/core-components.yaml
cd ..
PULL_POLICY=Never TAG=dev make docker-build release-manifests
kind load docker-image gcr.io/cluster-api-nested-controller-amd64:dev --name=capn
kind load docker-image gcr.io/nested-controlplane-controller-amd64:dev --name=capn
Next, we will deploy the CAPN related CRDs and controllers.
kubectl apply -f out/cluster-api-provider-nested-components.yaml
kubectl apply -f config/samples/
We will use the clusterctl
command-line tool to generate the KUBECONFIG
, which
will be used to access the nested controlplane later.
cd cluster-api
make clusterctl
./bin/clusterctl get kubeconfig cluster-sample > ../kubeconfig
cd ..
To access the nested controlplane, in a separate shell, you will need
to port-forward
the apiserver service.
kubectl port-forward svc/cluster-sample-apiserver 6443:6443
To use the KUBECONFIG
created by clusterctl
without modification, we first
need to setup a host record for the apiserver service name, to do this we can
define a custom hosts file by setting the HOSTALIASES
env and append the
IP-address-to-URL mapping to the hosts file.
echo '127.0.0.1 cluster-sample-apiserver' >> ~/.hosts
export HOSTALIASES=~/.hosts
kubectl --kubeconfig kubeconfig get all -A
kind delete cluster --name=capn