@@ -22,51 +22,96 @@ 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 needs the ` clusterctl ` binary to install and manage clusters.
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
+ 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
48
56
```
49
57
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.
51
61
52
62
``` 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:
56
67
```
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!
57
77
58
- ### Deploy CAPN
78
+ You can now create your first workload cluster by running the following:
59
79
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 ` )
61
106
62
107
``` shell
63
- kubectl apply -f out/ cluster-api-provider-nested-components.yaml
108
+ export CLUSTER_NAME= cluster-sample
64
109
```
65
110
66
- ### Apply Sample Cluster
111
+ ### Generate custom resource ( ` Cluster ` , ` NestedCluster ` etc) and apply to our cluster
67
112
68
113
``` shell
69
- kubectl apply -f config/samples/
114
+ ./bin/clusterctl generate cluster ${CLUSTER_NAME} --infrastructure=nested:v0.1.0 | kubectl apply -f -
70
115
```
71
116
72
117
### Get ` KUBECONFIG `
@@ -75,10 +120,29 @@ We will use the `clusterctl` command-line tool to generate the `KUBECONFIG`, whi
75
120
will be used to access the nested controlplane later.
76
121
77
122
``` 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
82
146
```
83
147
84
148
### Port Forward
@@ -88,6 +152,8 @@ to `port-forward` the apiserver service.
88
152
89
153
``` shell
90
154
kubectl port-forward svc/cluster-sample-apiserver 6443:6443
155
+ Forwarding from 127.0.0.1:6443 -> 6443
156
+ Forwarding from [::1]:6443 -> 6443
91
157
```
92
158
93
159
### Connect to Cluster
@@ -104,6 +170,9 @@ following line to `/etc/hosts`.
104
170
105
171
``` shell
106
172
kubectl --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
+
107
176
```
108
177
109
178
### Clean Up
0 commit comments