Skip to content

Commit db8c954

Browse files
committed
docs: simplify running examples in README
1 parent f85024a commit db8c954

File tree

8 files changed

+78
-42
lines changed

8 files changed

+78
-42
lines changed

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ EOF
7272
To create an example cluster:
7373

7474
```shell
75-
clusterctl generate cluster docker-quick-start-helm-addon-cilium \
76-
--from examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml \
75+
export CLUSTER_NAME=docker-cluster-cilium-helm-addon
76+
export CLUSTER_FILE=examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml
77+
```
78+
79+
```shell
80+
clusterctl generate cluster ${CLUSTER_NAME} \
81+
--from ${CLUSTER_FILE} \
7782
--kubernetes-version v1.29.1 \
7883
--worker-machine-count 1 | \
7984
kubectl apply --server-side -f -
@@ -82,33 +87,33 @@ clusterctl generate cluster docker-quick-start-helm-addon-cilium \
8287
Wait until control plane is ready:
8388

8489
```shell
85-
kubectl wait clusters/docker-quick-start-helm-addon-cilium --for=condition=ControlPlaneInitialized --timeout=5m
90+
kubectl wait clusters/${CLUSTER_NAME} --for=condition=ControlPlaneInitialized --timeout=5m
8691
```
8792

8893
To get the kubeconfig for the new cluster, run:
8994

9095
```shell
91-
clusterctl get kubeconfig docker-quick-start-helm-addon-cilium > docker-kubeconfig
96+
clusterctl get kubeconfig ${CLUSTER_NAME} > ${CLUSTER_NAME}.conf
9297
```
9398

9499
If you are not on Linux, you will also need to fix the generated kubeconfig's `server`, run:
95100

96101
```shell
97-
kubectl config set-cluster docker-quick-start-helm-addon-cilium \
98-
--kubeconfig docker-kubeconfig \
99-
--server=https://$(docker container port docker-quick-start-helm-addon-cilium-lb 6443/tcp)
102+
kubectl config set-cluster ${CLUSTER_NAME} \
103+
--kubeconfig ${CLUSTER_NAME}.conf \
104+
--server=https://$(docker container port ${CLUSTER_NAME}-lb 6443/tcp)
100105
```
101106

102107
Wait until all nodes are ready (this indicates that CNI has been deployed successfully):
103108

104109
```shell
105-
kubectl --kubeconfig docker-kubeconfig wait nodes --all --for=condition=Ready --timeout=5m
110+
kubectl --kubeconfig ${CLUSTER_NAME}.conf wait nodes --all --for=condition=Ready --timeout=5m
106111
```
107112

108113
Show that Cilium is running successfully on the workload cluster:
109114

110115
```shell
111-
kubectl --kubeconfig docker-kubeconfig get daemonsets -n kube-system cilium
116+
kubectl --kubeconfig ${CLUSTER_NAME}.conf get daemonsets -n kube-system cilium
112117
```
113118

114119
Deploy kube-vip to provide service load-balancer:
@@ -122,29 +127,29 @@ kubectl create configmap \
122127
--namespace kube-system kubevip \
123128
--from-literal "range-global=${kind_subnet_prefix}100.0-${kind_subnet_prefix}100.20" \
124129
--dry-run=client -oyaml |
125-
kubectl --kubeconfig docker-kubeconfig apply --server-side -n kube-system -f -
130+
kubectl --kubeconfig ${CLUSTER_NAME}.conf apply --server-side -n kube-system -f -
126131

127132
helm upgrade kube-vip-cloud-provider kube-vip/kube-vip-cloud-provider --version 0.2.2 \
128133
--install \
129134
--wait --wait-for-jobs \
130135
--namespace kube-system \
131-
--kubeconfig docker-kubeconfig \
136+
--kubeconfig ${CLUSTER_NAME}.conf \
132137
--set-string=image.tag=v0.0.6
133138

134139
helm upgrade kube-vip kube-vip/kube-vip --version 0.4.2 \
135140
--install \
136141
--wait --wait-for-jobs \
137142
--namespace kube-system \
138-
--kubeconfig docker-kubeconfig \
143+
--kubeconfig ${CLUSTER_NAME}.conf \
139144
--set-string=image.tag=v0.6.0
140145
```
141146

142147
Deploy traefik as a LB service:
143148

144149
```shell
145-
helm --kubeconfig docker-kubeconfig repo add traefik https://helm.traefik.io/traefik
150+
helm --kubeconfig ${CLUSTER_NAME}.conf repo add traefik https://helm.traefik.io/traefik
146151
helm repo update &>/dev/null
147-
helm --kubeconfig docker-kubeconfig upgrade --install traefik traefik/traefik \
152+
helm --kubeconfig ${CLUSTER_NAME}.conf upgrade --install traefik traefik/traefik \
148153
--version v10.9.1 \
149154
--wait --wait-for-jobs \
150155
--set ports.web.hostPort=80 \
@@ -155,13 +160,13 @@ helm --kubeconfig docker-kubeconfig upgrade --install traefik traefik/traefik \
155160
Watch for traefik LB service to get an external address:
156161

157162
```shell
158-
watch -n 0.5 kubectl --kubeconfig docker-kubeconfig get service/traefik
163+
watch -n 0.5 kubectl --kubeconfig ${CLUSTER_NAME}.conf get service/traefik
159164
```
160165

161166
To delete the workload cluster, run:
162167

163168
```shell
164-
kubectl delete cluster docker-quick-start-helm-addon-cilium
169+
kubectl delete cluster ${CLUSTER_NAME}
165170
```
166171

167172
Notice that the traefik service is deleted before the cluster is actually finally deleted.

examples/capi-quick-start/aws-cluster-calico-crs.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ spec:
5353
- class: default-worker
5454
name: md-0
5555
replicas: ${WORKER_MACHINE_COUNT}
56+
---
57+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
58+
kind: AWSClusterStaticIdentity
59+
metadata:
60+
labels:
61+
cluster.x-k8s.io/provider: aws
62+
name: ${CLUSTER_NAME}
63+
spec:
64+
allowedNamespaces:
65+
list:
66+
- default
67+
secretRef: aws-quick-start-creds

examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ spec:
5353
- class: default-worker
5454
name: md-0
5555
replicas: ${WORKER_MACHINE_COUNT}
56+
---
57+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
58+
kind: AWSClusterStaticIdentity
59+
metadata:
60+
labels:
61+
cluster.x-k8s.io/provider: aws
62+
name: ${CLUSTER_NAME}
63+
spec:
64+
allowedNamespaces:
65+
list:
66+
- default
67+
secretRef: aws-quick-start-creds

examples/capi-quick-start/aws-cluster-cilium-crs.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ spec:
5353
- class: default-worker
5454
name: md-0
5555
replicas: ${WORKER_MACHINE_COUNT}
56+
---
57+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
58+
kind: AWSClusterStaticIdentity
59+
metadata:
60+
labels:
61+
cluster.x-k8s.io/provider: aws
62+
name: ${CLUSTER_NAME}
63+
spec:
64+
allowedNamespaces:
65+
list:
66+
- default
67+
secretRef: aws-quick-start-creds

examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ spec:
5353
- class: default-worker
5454
name: md-0
5555
replicas: ${WORKER_MACHINE_COUNT}
56+
---
57+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
58+
kind: AWSClusterStaticIdentity
59+
metadata:
60+
labels:
61+
cluster.x-k8s.io/provider: aws
62+
name: ${CLUSTER_NAME}
63+
spec:
64+
allowedNamespaces:
65+
list:
66+
- default
67+
secretRef: aws-quick-start-creds

examples/capi-quick-start/aws-cluster-identity.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

hack/examples/bases/aws/AWSClusterStaticIdentity.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
---
5-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
5+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
66
kind: AWSClusterStaticIdentity
77
metadata:
88
name: "quick-start"

hack/examples/sync.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ mkdir -p "${EXAMPLE_CLUSTERCLASSES_DIR}"
1919
readonly EXAMPLE_CLUSTERS_DIR=examples/capi-quick-start
2020
mkdir -p "${EXAMPLE_CLUSTERS_DIR}"
2121

22-
mkdir -p examples/capi-quick-start
2322
# Sync ClusterClasses (including Templates) and Clusters to separate files.
2423
kustomize build ./hack/examples |
2524
tee \
@@ -68,37 +67,32 @@ kustomize build ./hack/examples |
6867
)' >"${EXAMPLE_CLUSTERCLASSES_DIR}/aws-cluster-class.yaml"
6968
) \
7069
>(
71-
gojq --yaml-input --yaml-output 'select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
70+
gojq --yaml-input --yaml-output 'select((.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
7271
and .kind == "Cluster"
7372
and .spec.topology.variables[0].value.addons.cni.provider == "Calico"
7473
and .spec.topology.variables[0].value.addons.cni.strategy == "ClusterResourceSet"
75-
)' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-calico-crs.yaml"
74+
) or .kind == "AWSClusterStaticIdentity")' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-calico-crs.yaml"
7675
) \
7776
>(
78-
gojq --yaml-input --yaml-output 'select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
77+
gojq --yaml-input --yaml-output 'select((.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
7978
and .kind == "Cluster"
8079
and .spec.topology.variables[0].value.addons.cni.provider == "Calico"
8180
and .spec.topology.variables[0].value.addons.cni.strategy == "HelmAddon"
82-
)' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-calico-helm-addon.yaml"
81+
) or .kind == "AWSClusterStaticIdentity")' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-calico-helm-addon.yaml"
8382
) \
8483
>(
85-
gojq --yaml-input --yaml-output 'select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
84+
gojq --yaml-input --yaml-output 'select((.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
8685
and .kind == "Cluster"
8786
and .spec.topology.variables[0].value.addons.cni.provider == "Cilium"
8887
and .spec.topology.variables[0].value.addons.cni.strategy == "ClusterResourceSet"
89-
)' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-cilium-crs.yaml"
88+
) or .kind == "AWSClusterStaticIdentity")' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-cilium-crs.yaml"
9089
) \
9190
>(
92-
gojq --yaml-input --yaml-output 'select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
91+
gojq --yaml-input --yaml-output 'select((.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
9392
and .kind == "Cluster"
9493
and .spec.topology.variables[0].value.addons.cni.provider == "Cilium"
9594
and .spec.topology.variables[0].value.addons.cni.strategy == "HelmAddon"
96-
)' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-cilium-helm-addon.yaml"
97-
) \
98-
>(
99-
gojq --yaml-input --yaml-output 'select(.metadata.labels["cluster.x-k8s.io/provider"] == "aws"
100-
and .kind == "AWSClusterStaticIdentity"
101-
)' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-identity.yaml"
95+
) or .kind == "AWSClusterStaticIdentity")' >"${EXAMPLE_CLUSTERS_DIR}/aws-cluster-cilium-helm-addon.yaml"
10296
) \
10397
>/dev/null
10498

0 commit comments

Comments
 (0)