@@ -22,63 +22,113 @@ cd cluster-api-provider-nested
22
22
kind create cluster --name=capn
23
23
```
24
24
25
- ### Install ` cert-manager `
25
+ ### Clone CAPI and build ` clusterctl ` tool
26
26
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 need build ` clusterctl ` tool
30
28
31
29
``` 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
33
33
```
34
34
35
- ### Clone CAPI and Deploy Dev release
35
+ # Create Dev Repo
36
36
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
+ ```
39
40
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
+ ```
44
+ cat <<EOF >>~/.cluster-api/dev-repository/config.yaml
45
+ ---
46
+ providers:
47
+ - name: "cluster-api"
48
+ url: "https://github.com/kubernetes-sigs/cluster-api/releases/v0.4.0-beta.0/core-components.yaml"
49
+ type: "CoreProvider"
50
+ - name: "kubeadm"
51
+ url: "https://github.com/kubernetes-sigs/cluster-api/releases/v0.4.0-beta.0/bootstrap-components.yaml"
52
+ type: "BootstrapProvider"
53
+ EOF
48
54
```
49
55
50
- ### Create Docker Images, Manifests and Load Images
56
+ ### Init control plane, infrastructure etc
51
57
52
58
``` 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
59
+ ./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
60
+ ```
61
+
62
+ you should see something like:
56
63
```
64
+ Fetching providers
65
+ Installing cert-manager Version="v1.1.0"
66
+ Waiting for cert-manager to be available...
67
+ Installing Provider="cluster-api" Version="v0.4.0-beta.0" TargetNamespace="capi-system"
68
+ Installing Provider="bootstrap-kubeadm" Version="v0.4.0-beta.0" TargetNamespace="capi-kubeadm-bootstrap-system"
69
+ Installing Provider="control-plane-nested" Version="v0.1.0" TargetNamespace="capn-nested-control-plane-system"
70
+ Installing Provider="infrastructure-nested" Version="v0.1.0" TargetNamespace="capn-system"
57
71
58
- ### Deploy CAPN
72
+ Your management cluster has been initialized successfully!
59
73
60
- Next, we will deploy the CAPN related CRDs and controllers.
74
+ You can now create your first workload cluster by running the following:
75
+
76
+ clusterctl generate cluster [name] --kubernetes-version [version] | kubectl apply -f -
77
+ ```
78
+
79
+ and wait for all pods to be ` Running ` before proceed to next step:
80
+ ```
81
+ kubectl get pods --all-namespaces
82
+ NAMESPACE NAME READY STATUS RESTARTS AGE
83
+ capi-kubeadm-bootstrap-system capi-kubeadm-bootstrap-controller-manager-c59c94d6f-l8f4v 1/1 Running 0 4m45s
84
+ capi-system capi-controller-manager-6c555b545d-rtw8k 1/1 Running 0 4m46s
85
+ capn-nested-control-plane-system capn-nested-control-plane-controller-manager-698c444c6d-nhddn 2/2 Running 0 4m45s
86
+ capn-system capn-controller-manager-7f9757b67f-cp8d9 2/2 Running 0 4m43s
87
+ cert-manager cert-manager-5597cff495-gwgr5 1/1 Running 0 5m7s
88
+ cert-manager cert-manager-cainjector-bd5f9c764-vvbjf 1/1 Running 0 5m7s
89
+ cert-manager cert-manager-webhook-5f57f59fbc-ccg5k 1/1 Running 0 5m7s
90
+ kube-system coredns-74ff55c5b-9pspc 1/1 Running 0 6m16s
91
+ kube-system coredns-74ff55c5b-nqnk9 1/1 Running 0 6m16s
92
+ kube-system etcd-capn-control-plane 1/1 Running 0 6m29s
93
+ kube-system kindnet-9g9z4 1/1 Running 0 6m16s
94
+ kube-system kube-apiserver-capn-control-plane 1/1 Running 0 6m29s
95
+ kube-system kube-controller-manager-capn-control-plane 1/1 Running 0 6m29s
96
+ kube-system kube-proxy-jl46r 1/1 Running 0 6m16s
97
+ kube-system kube-scheduler-capn-control-plane 1/1 Running 0 6m29s
98
+ local-path-storage local-path-provisioner-78776bfc44-qcx49 1/1 Running 0 6m16s
99
+ ```
100
+
101
+ ### Set clustername (in our example, we set clustername to ` cluster-sample ` )
61
102
62
103
``` shell
63
- kubectl apply -f out/ cluster-api-provider-nested-components.yaml
104
+ export CLUSTER_NAME= cluster-sample
64
105
```
65
106
66
- ### Apply Sample Cluster
107
+ ### Generate custom resource ( ` Cluster ` , ` NestedCluster ` etc) and apply to our cluster
67
108
68
109
``` shell
69
- kubectl apply -f config/samples/
110
+ ./bin/clusterctl generate cluster ${CLUSTER_NAME} --infrastructure=nested:v0.1.0
70
111
```
71
112
72
113
### Get ` KUBECONFIG `
73
114
74
- We will use the ` clusterctl ` command-line tool to generate the ` KUBECONFIG ` , which
75
- will be used to access the nested controlplane later.
76
-
77
115
``` shell
78
- cd cluster-api
79
- make clusterctl
80
- ./bin/clusterctl get kubeconfig cluster-sample > ../kubeconfig
81
- cd ..
116
+ ./bin/clusterctl get kubeconfig ${CLUSTER_NAME} > ../kubeconfig
117
+ ```
118
+
119
+ Note you might see following error, wait for a while and retry
120
+ ```
121
+ Error: "cluster-sample-kubeconfig" not found in namespace "default": secrets "cluster-sample-kubeconfig" not found
122
+ ```
123
+
124
+ ### Make sure ` cluster-sample ` related pods are running before proceed.
125
+
126
+ ```
127
+ # kubectl get pods
128
+ NAME READY STATUS RESTARTS AGE
129
+ cluster-sample-apiserver-0 1/1 Running 0 25h
130
+ cluster-sample-controller-manager-0 1/1 Running 0 25h
131
+ cluster-sample-etcd-0 1/1 Running 0 25h
82
132
```
83
133
84
134
### Port Forward
@@ -87,7 +137,9 @@ To access the nested controlplane, in a separate shell, you will need
87
137
to ` port-forward ` the apiserver service.
88
138
89
139
``` shell
90
- kubectl port-forward svc/cluster-sample-apiserver 6443:6443
140
+ # kubectl port-forward svc/cluster-sample-apiserver 6443:6443
141
+ Forwarding from 127.0.0.1:6443 -> 6443
142
+ Forwarding from [::1]:6443 -> 6443
91
143
```
92
144
93
145
### Connect to Cluster
@@ -103,7 +155,10 @@ following line to `/etc/hosts`.
103
155
### Connect to the Cluster! :tada :
104
156
105
157
``` shell
106
- kubectl --kubeconfig kubeconfig get all -A
158
+ # kubectl --kubeconfig kubeconfig get all -A
159
+ NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
160
+ default service/kubernetes ClusterIP 10.32.0.1 < none> 443/TCP 25h
161
+
107
162
```
108
163
109
164
### Clean Up
0 commit comments