|
| 1 | +## Quick Start |
| 2 | + |
| 3 | +This tutorial introduces how to create a nested controlplane. . CAPN should work with any standard |
| 4 | +Kubernetes cluster out of box, but for demo purposes, in this tutorial, we will use |
| 5 | +a kind cluster as the meta cluster as well as the infrastructure provider. |
| 6 | + |
| 7 | +### Prerequests |
| 8 | + |
| 9 | +Please install the latest version of [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) |
| 10 | +and [kubectl](https://kubernetes.io/docs/tasks/tools/) |
| 11 | + |
| 12 | +### Clone CAPN |
| 13 | + |
| 14 | +```shell |
| 15 | +git clone https://github.com/kubernetes-sigs/cluster-api-provider-nested |
| 16 | +cd cluster-api-provider-nested |
| 17 | +``` |
| 18 | + |
| 19 | +### Create `kind` cluster |
| 20 | + |
| 21 | +```shell |
| 22 | +kind create cluster |
| 23 | +``` |
| 24 | + |
| 25 | +### Install `cert-manager` |
| 26 | + |
| 27 | +**TODO: briefly explain why install cert-manager** |
| 28 | + |
| 29 | +```shell |
| 30 | +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml |
| 31 | +``` |
| 32 | + |
| 33 | +### Clone CAPI and Deploy Dev release |
| 34 | + |
| 35 | +Though CAPN can be used independently, as a cluster API~(CAPI) provider, |
| 36 | +we recommand using CAPN with CAPI. We need to deploy the unreleased version of |
| 37 | +CAPI for `v1alpha4` API support. |
| 38 | + |
| 39 | +```shell |
| 40 | +git clone [email protected]:kubernetes-sigs/cluster-api.git |
| 41 | +cd cluster-api |
| 42 | +make release-manifests |
| 43 | +# change feature flags on core |
| 44 | +sed -i'' -e 's@- --feature-gates=.*@- --feature-gates=MachinePool=false,ClusterResourceSet=true@' out/core-components.yaml |
| 45 | +kubectl apply -f out/core-components.yaml |
| 46 | +cd .. |
| 47 | +``` |
| 48 | + |
| 49 | +### Create Docker Images, Manifests and Load Images |
| 50 | + |
| 51 | +```shell |
| 52 | +export PULL_POLICY=Never |
| 53 | +export TAG=dev |
| 54 | +make docker-build release-manifests |
| 55 | +kind load docker-image gcr.io/cluster-api-nested-controller-amd64:dev |
| 56 | +kind load docker-image gcr.io/nested-controlplane-controller-amd64:dev |
| 57 | +``` |
| 58 | + |
| 59 | +### Deploy CAPN |
| 60 | + |
| 61 | +Next, we will deploy the CAPN related CRDs and controllers. |
| 62 | + |
| 63 | +```shell |
| 64 | +kubectl apply -f out/cluster-api-provider-nested-components.yaml |
| 65 | +``` |
| 66 | + |
| 67 | +### Apply Sample Cluster |
| 68 | + |
| 69 | +```shell |
| 70 | +kubectl apply -f config/samples/ |
| 71 | +``` |
| 72 | + |
| 73 | +### Get `KUBECONFIG` |
| 74 | + |
| 75 | +We will use the `clusterctl` command-line tool to generate the `KUBECONFIG`, which |
| 76 | +will be used to access the nested controlplane later. |
| 77 | + |
| 78 | +```shell |
| 79 | +cd cluster-api |
| 80 | +make clusterctl |
| 81 | +./bin/clusterctl get kubeconfig cluster-sample > ../kubeconfig |
| 82 | +cd .. |
| 83 | +``` |
| 84 | + |
| 85 | +### Port Forward |
| 86 | + |
| 87 | +To access the nested controlplane, in a separate shell, you will need |
| 88 | +to `port-forward` the apiserver service. |
| 89 | + |
| 90 | +```shell |
| 91 | +kubectl port-forward svc/cluster-sample-apiserver 6443:6443 |
| 92 | +``` |
| 93 | + |
| 94 | +### Connect to Cluster |
| 95 | + |
| 96 | +To use the `KUBECONFIG` created by `clusterctl` without modification, we first |
| 97 | +need to setup a host record for the apiserver service name, to do this we can |
| 98 | +define a custom hosts file by setting the `HOSTALIASES` env and append the |
| 99 | +IP-address-to-URL mapping to the hosts file. |
| 100 | + |
| 101 | +```shell |
| 102 | +echo '127.0.0.1 localhost1' >> ~/.hosts |
| 103 | +export HOSTALIASES=~/.hosts |
| 104 | +``` |
| 105 | + |
| 106 | +### Connect to the Cluster! tada |
| 107 | + |
| 108 | +```shell |
| 109 | +kubectl --kubeconfig kubeconfig get all -A |
| 110 | +``` |
0 commit comments