Skip to content

Commit f8b37e4

Browse files
authored
docs: quick move instructions for maintainers (#79)
1 parent 2ab0479 commit f8b37e4

File tree

3 files changed

+167
-1
lines changed

3 files changed

+167
-1
lines changed

DEVELOPMENT.md

+127
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,130 @@ Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project
186186
```sh
187187
kubectl apply -f https://raw.githubusercontent.com/<org>/cluster-api-provider-metal-stack/<tag or branch>/dist/install.yaml
188188
```
189+
190+
## Quick opinionated Cluster Bootstrap and move
191+
192+
This is a short and opinionated fast track to create and move a cluster using our provider.
193+
In contrast to a guide and the README, we do not explain all commands and try to be concise.
194+
195+
Configure your clusterctl:
196+
197+
```yaml
198+
# ~/.config/cluster-api/clusterctl.yaml
199+
providers:
200+
- name: "metal-stack"
201+
url: "https://github.com/metal-stack/cluster-api-provider-metal-stack/releases/latest/download/infrastructure-components.yaml"
202+
# or for PRs
203+
# url: "${HOME}/path/to/infrastructure-metal-stack/v0.4.0/infrastructure-components.yaml"
204+
# generate with:
205+
# IMG_TAG=branch-name RELEASE_DIR=${HOME}/path/to/infrastructure-metal-stack/v0.4.0 make release-manifests
206+
type: InfrastructureProvider
207+
```
208+
209+
Set environment variables. Don't forget to update them along the way.
210+
211+
```bash
212+
export EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION=true
213+
214+
export METAL_API_HMAC=
215+
export METAL_API_HMAC_AUTH_TYPE=
216+
export METAL_API_URL=
217+
218+
export METAL_PARTITION=
219+
export METAL_PROJECT_ID=
220+
export METAL_NODE_NETWORK_ID=
221+
222+
export FIREWALL_MACHINE_IMAGE=
223+
export FIREWALL_MACHINE_SIZE=
224+
225+
export CONTROL_PLANE_MACHINE_IMAGE=
226+
export CONTROL_PLANE_MACHINE_SIZE=
227+
export WORKER_MACHINE_IMAGE=
228+
export WORKER_MACHINE_SIZE=
229+
230+
export CLUSTER_NAME=
231+
export NAMESPACE=default
232+
export KUBERNETES_VERSION=v1.30.6
233+
234+
export CONTROL_PLANE_MACHINE_COUNT=1
235+
export WORKER_MACHINE_COUNT=1
236+
237+
# Additional envs
238+
export repo_path=$HOME/path/to/cluster-api-provider-metal-stack
239+
export project_name=
240+
export tenant_name=
241+
export firewall_id=
242+
```
243+
244+
Create firewall if needed:
245+
246+
```bash
247+
metalctl project create --name $project_name --tenant $tenant_name --description "Cluster API test project"
248+
metalctl network allocate --description "Node network for $CLUSTER_NAME" --name $CLUSTER_NAME --project $METAL_PROJECT_ID --partition $METAL_PARTITION
249+
metalctl firewall create --description "Firewall for $CLUSTER_NAME cluster" --name firewall-$CLUSTER_NAME --hostname firewall-$CLUSTER_NAME --project $METAL_PROJECT_ID --partition $METAL_PARTITION --image $FIREWALL_MACHINE_IMAGE --size $FIREWALL_MACHINE_SIZE --firewall-rules-file $repo_path/config/target-cluster/firewall-rules.yaml --networks internet,$METAL_NODE_NETWORK_ID
250+
```
251+
252+
```bash
253+
kind create cluster --name bootstrap
254+
kind export kubeconfig --name bootstrap --kubeconfig kind-bootstrap.kubeconfig
255+
256+
clusterctl init --infrastructure metal-stack --kubeconfig kind-bootstrap.kubeconfig
257+
clusterctl generate cluster $CLUSTER_NAME --infrastructure metal-stack > cluster-$CLUSTER_NAME.yaml
258+
kubectl apply -n $NAMESPACE -f cluster-$CLUSTER_NAME.yaml
259+
260+
# once the control plane node is in phoned home
261+
metalctl machine consolepassword $firewall_id
262+
metalctl machine console --ipmi $firewall_id
263+
# sudo systemctl restart frr
264+
# ~.
265+
266+
kubectl --kubeconfig kind-bootstrap.kubeconfig -n $NAMESPACE get metalstackmachines.infrastructure.cluster.x-k8s.io
267+
export control_plane_machine_id=
268+
metalctl machine console --ipmi $control_plane_machine_id
269+
# ip r
270+
# sudo systemctl restart kubeadm
271+
# crictl ps
272+
# ~.
273+
274+
clusterctl get kubeconfig > capms-cluster.kubeconfig
275+
276+
# metal-ccm
277+
cat $repo_path/config/target-cluster/metal-ccm.yaml | envsubst | kubectl --kubeconfig capms-cluster.kubeconfig apply -f -
278+
279+
# cni
280+
kubectl --kubeconfig=capms-cluster.kubeconfig create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.2/manifests/tigera-operator.yaml
281+
cat <<EOF | kubectl --kubeconfig=capms-cluster.kubeconfig create -f -
282+
apiVersion: operator.tigera.io/v1
283+
kind: Installation
284+
metadata:
285+
name: default
286+
spec:
287+
# Configures Calico networking.
288+
calicoNetwork:
289+
bgp: Disabled
290+
ipPools:
291+
- name: default-ipv4-ippool
292+
blockSize: 26
293+
cidr: 10.240.0.0/12
294+
encapsulation: None
295+
mtu: 1440
296+
cni:
297+
ipam:
298+
type: HostLocal
299+
type: Calico
300+
EOF
301+
302+
watch kubectl -n $NAMESPACE --kubeconfig kind-bootstrap.kubeconfig get cluster,metalstackcluster,machine,metalstackmachine,kubeadmcontrolplanes,kubeadmconfigs
303+
# until everything is ready
304+
```
305+
306+
Now you are able to move the cluster resources as you wish:
307+
308+
```bash
309+
clusterctl init --infrastructure metal-stack --kubeconfig capms-cluster.kubeconfig
310+
311+
clusterctl move -n $NAMESPACE --kubeconfig kind-bootstrap.kubeconfig --to-kubeconfig capms-cluster.kubeconfig
312+
# everything as expected
313+
kubectl --kubeconfig -n $NAMESPACE kind-bootstrap.kubeconfig get cluster,metalstackcluster,machine,metalstackmachine,kubeadmcontrolplanes,kubeadmconfigs
314+
kubectl --kubeconfig -n $NAMESPACE capms-cluster.kubeconfig get cluster,metalstackcluster,machine,metalstackmachine,kubeadmcontrolplanes,kubeadmconfigs
315+
```

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ metalctl network allocate --description "<description>" --name <name> --project
6262
export METAL_NODE_NETWORK_ID=$(metalctl network list --name <name> -o template --template '{{ .id }}')
6363
```
6464

65-
A firewall needs to be created with appropriate firewall rules. An example can be found at [firewall-rules.yaml](capi-lab/firewall-rules.yaml).
65+
A firewall needs to be created with appropriate firewall rules. An example can be found at [firewall-rules.yaml](config/target-cluster/firewall-rules.yaml).
6666
```bash
6767
# export environment variable for the firewall image and size
6868
export FIREWALL_MACHINE_IMAGE=<firewall-image>
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# used for metalctl firewall create --firewall-rules-file
3+
egress:
4+
- comment: allow outgoing HTTP and HTTPS traffic
5+
ports:
6+
- 80
7+
- 443
8+
protocol: TCP
9+
to:
10+
- 0.0.0.0/0
11+
- comment: allow outgoing DNS traffic via TCP
12+
ports:
13+
- 53
14+
protocol: TCP
15+
to:
16+
- 0.0.0.0/0
17+
- comment: allow outgoing traffic to control plane for ccm
18+
ports:
19+
- 8080
20+
protocol: TCP
21+
to:
22+
- 0.0.0.0/0 # could be more specific
23+
- comment: allow outgoing DNS and NTP traffic via UDP
24+
ports:
25+
- 53
26+
- 123
27+
protocol: UDP
28+
to:
29+
- 0.0.0.0/0
30+
ingress:
31+
- comment: allow incoming HTTP and HTTPS traffic
32+
ports:
33+
- 80
34+
- 443
35+
protocol: TCP
36+
from:
37+
- 0.0.0.0/0 # could be more specific
38+
to:
39+
- 0.0.0.0/0 # could be more specific

0 commit comments

Comments
 (0)