@@ -22,51 +22,96 @@ cd cluster-api-provider-nested
2222kind create cluster --name=capn
2323```
2424
25- ### Install ` cert-manager `
25+ ### Clone CAPI and build ` clusterctl ` tool
2626
27- Cert Manager is a soft dependency for the Cluster API components to enable mutating
28- and validating webhooks to be auto deployed. For more detailed instructions
29- go [ Cert Manager Installion] ( https://cert-manager.io/docs/installation/kubernetes/#installing-with-regular-manifests ) .
27+ As a Cluster API (CAPI) provider, CAPN needs the ` clusterctl ` binary to install and manage clusters.
3028
3129``` shell
32- kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml
30+ git clone
[email protected] :kubernetes-sigs/cluster-api.git
31+ cd cluster-api
32+ make clusterctl
3333```
3434
35- ### Clone CAPI and Deploy Dev release
35+ ### Create Dev Repo
3636
37- As a cluster API~ (CAPI) provider, CAPN requires core components of CAPI to be setup.
38- We need to deploy the unreleased version of CAPI for ` v1alpha4 ` API support.
37+ ```
38+ mkdir -p ~/.cluster-api/dev-repository/
39+ ```
3940
40- ``` shell
41- git clone
[email protected] :kubernetes-sigs/cluster-api.git
42- cd cluster-api
43- make release-manifests
44- # change feature flags on core
45- sed -i' ' -e ' s@- --feature-gates=.*@- --feature-gates=MachinePool=false,ClusterResourceSet=true@' out/core-components.yaml
46- kubectl apply -f out/core-components.yaml
47- cd ..
41+ ### Update config for CAPI Beta
42+
43+ In order to use the ` beta ` build with ` clusterctl ` you need to tell it where to find the proper images for the core and bootstrap components.
44+
45+ ```
46+ cat <<EOF >>~/.cluster-api/dev-repository/config.yaml
47+ ---
48+ providers:
49+ - name: "cluster-api"
50+ url: "https://github.com/kubernetes-sigs/cluster-api/releases/v0.4.0-beta.0/core-components.yaml"
51+ type: "CoreProvider"
52+ - name: "kubeadm"
53+ url: "https://github.com/kubernetes-sigs/cluster-api/releases/v0.4.0-beta.0/bootstrap-components.yaml"
54+ type: "BootstrapProvider"
55+ EOF
4856```
4957
50- ### Create Docker Images, Manifests and Load Images
58+ ### Init control plane, infrastructure etc
59+
60+ If you aren't familar with CAPI & ` clusterctl ` this command will deploy the core components, as well as the Nested components for infra providers and for control plane providers.
5161
5262``` shell
53- PULL_POLICY=Never TAG=dev make docker-build release-manifests
54- kind load docker-image gcr.io/cluster-api-nested-controller-amd64:dev --name=capn
55- kind load docker-image gcr.io/nested-controlplane-controller-amd64:dev --name=capn
63+ ./bin/clusterctl init --core cluster-api:v0.4.0-beta.0 --control-plane nested:v0.1.0 --infrastructure nested:v0.1.0 --config ~ /.cluster-api/dev-repository/config.yaml
64+ ```
65+
66+ you should see something like:
5667```
68+ Fetching providers
69+ Installing cert-manager Version="v1.1.0"
70+ Waiting for cert-manager to be available...
71+ Installing Provider="cluster-api" Version="v0.4.0-beta.0" TargetNamespace="capi-system"
72+ Installing Provider="bootstrap-kubeadm" Version="v0.4.0-beta.0" TargetNamespace="capi-kubeadm-bootstrap-system"
73+ Installing Provider="control-plane-nested" Version="v0.1.0" TargetNamespace="capn-nested-control-plane-system"
74+ Installing Provider="infrastructure-nested" Version="v0.1.0" TargetNamespace="capn-system"
75+
76+ Your management cluster has been initialized successfully!
5777
58- ### Deploy CAPN
78+ You can now create your first workload cluster by running the following:
5979
60- Next, we will deploy the CAPN related CRDs and controllers.
80+ clusterctl generate cluster [name] --kubernetes-version [version] | kubectl apply -f -
81+ ```
82+
83+ and wait for all pods to be ` Running ` before proceed to next step:
84+ ```
85+ kubectl get pods --all-namespaces
86+ NAMESPACE NAME READY STATUS RESTARTS AGE
87+ capi-kubeadm-bootstrap-system capi-kubeadm-bootstrap-controller-manager-c59c94d6f-l8f4v 1/1 Running 0 4m45s
88+ capi-system capi-controller-manager-6c555b545d-rtw8k 1/1 Running 0 4m46s
89+ capn-nested-control-plane-system capn-nested-control-plane-controller-manager-698c444c6d-nhddn 2/2 Running 0 4m45s
90+ capn-system capn-controller-manager-7f9757b67f-cp8d9 2/2 Running 0 4m43s
91+ cert-manager cert-manager-5597cff495-gwgr5 1/1 Running 0 5m7s
92+ cert-manager cert-manager-cainjector-bd5f9c764-vvbjf 1/1 Running 0 5m7s
93+ cert-manager cert-manager-webhook-5f57f59fbc-ccg5k 1/1 Running 0 5m7s
94+ kube-system coredns-74ff55c5b-9pspc 1/1 Running 0 6m16s
95+ kube-system coredns-74ff55c5b-nqnk9 1/1 Running 0 6m16s
96+ kube-system etcd-capn-control-plane 1/1 Running 0 6m29s
97+ kube-system kindnet-9g9z4 1/1 Running 0 6m16s
98+ kube-system kube-apiserver-capn-control-plane 1/1 Running 0 6m29s
99+ kube-system kube-controller-manager-capn-control-plane 1/1 Running 0 6m29s
100+ kube-system kube-proxy-jl46r 1/1 Running 0 6m16s
101+ kube-system kube-scheduler-capn-control-plane 1/1 Running 0 6m29s
102+ local-path-storage local-path-provisioner-78776bfc44-qcx49 1/1 Running 0 6m16s
103+ ```
104+
105+ ### Set clustername (in our example, we set clustername to ` cluster-sample ` )
61106
62107``` shell
63- kubectl apply -f out/ cluster-api-provider-nested-components.yaml
108+ export CLUSTER_NAME= cluster-sample
64109```
65110
66- ### Apply Sample Cluster
111+ ### Generate custom resource ( ` Cluster ` , ` NestedCluster ` etc) and apply to our cluster
67112
68113``` shell
69- kubectl apply -f config/samples/
114+ ./bin/clusterctl generate cluster ${CLUSTER_NAME} --infrastructure=nested:v0.1.0 | kubectl apply -f -
70115```
71116
72117### Get ` KUBECONFIG `
@@ -75,10 +120,29 @@ We will use the `clusterctl` command-line tool to generate the `KUBECONFIG`, whi
75120will be used to access the nested controlplane later.
76121
77122``` shell
78- cd cluster-api
79- make clusterctl
80- ./bin/clusterctl get kubeconfig cluster-sample > ../kubeconfig
81- cd ..
123+ ./bin/clusterctl get kubeconfig ${CLUSTER_NAME} > ../kubeconfig
124+ ```
125+
126+ This error means that the status of the cluster is not ready.
127+ ```
128+ Error: "cluster-sample-kubeconfig" not found in namespace "default": secrets "cluster-sample-kubeconfig" not found
129+ ```
130+
131+ Run following command and make sure the ` Ready ` is true before retry above command.
132+ ```
133+ kubectl get nestedcluster -w
134+ NAME READY AGE
135+ cluster-sample true 26h
136+ ```
137+
138+ ### Make sure ` cluster-sample ` related pods are running before proceed.
139+
140+ ```
141+ kubectl get pods
142+ NAME READY STATUS RESTARTS AGE
143+ cluster-sample-apiserver-0 1/1 Running 0 25h
144+ cluster-sample-controller-manager-0 1/1 Running 0 25h
145+ cluster-sample-etcd-0 1/1 Running 0 25h
82146```
83147
84148### Port Forward
@@ -88,6 +152,8 @@ to `port-forward` the apiserver service.
88152
89153``` shell
90154kubectl port-forward svc/cluster-sample-apiserver 6443:6443
155+ Forwarding from 127.0.0.1:6443 -> 6443
156+ Forwarding from [::1]:6443 -> 6443
91157```
92158
93159### Connect to Cluster
@@ -104,6 +170,9 @@ following line to `/etc/hosts`.
104170
105171``` shell
106172kubectl --kubeconfig kubeconfig get all -A
173+ NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
174+ default service/kubernetes ClusterIP 10.32.0.1 < none> 443/TCP 25h
175+
107176```
108177
109178### Clean Up
0 commit comments