Skip to content

Commit

Permalink
docs: Update examples to be clusterctl templates
Browse files Browse the repository at this point in the history
Provides easier integration with CAPI e2e testing libraries.
  • Loading branch information
jimmidyson committed Feb 14, 2024
1 parent 17fa13f commit a1aa75a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
name: examples-sync
entry: make examples.sync
language: system
files: "^hack/examples/"
files: "^(hack/)?examples/"
pass_filenames: false
- id: apis-sync
name: apis-sync
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ stringData:
EOF
```

To create a cluster, update `clusterConfig` variable and run:
To create an example cluster:

```shell
kubectl apply --server-side -f examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml
clusterctl generate cluster docker-quick-start-helm-addon-cilium \
--from examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml \
--kubernetes-version v1.29.1 \
--worker-machine-count 1 | \
kubectl apply --server-side -f -
```

Wait until control plane is ready:
Expand All @@ -92,7 +96,7 @@ If you are not on Linux, you will also need to fix the generated kubeconfig's `s
```shell
kubectl config set-cluster docker-quick-start-helm-addon-cilium \
--kubeconfig docker-kubeconfig \
--server=https://$(docker port docker-quick-start-helm-addon-cilium-lb 6443/tcp)
--server=https://$(docker container port docker-quick-start-helm-addon-cilium-lb 6443/tcp)
```

Wait until all nodes are ready (this indicates that CNI has been deployed successfully):
Expand Down
12 changes: 6 additions & 6 deletions examples/capi-quick-start/aws-cluster-calico-crs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ kind: Cluster
metadata:
labels:
cluster.x-k8s.io/provider: aws
name: aws-quick-start-crs-calico
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
- ${POD_CIDR:-192.168.0.0/16}
serviceDomain: cluster.local
services:
cidrBlocks:
- 10.128.0.0/12
- ${SERVICE_CIDR:-10.128.0.0/12}
topology:
class: aws-quick-start
controlPlane:
replicas: 1
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: clusterConfig
value:
Expand All @@ -31,9 +31,9 @@ spec:
nfd: {}
aws:
region: us-west-2
version: v1.27.5
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: 1
replicas: ${WORKER_MACHINE_COUNT}
12 changes: 6 additions & 6 deletions examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ kind: Cluster
metadata:
labels:
cluster.x-k8s.io/provider: aws
name: aws-quick-start-helm-addon-calico
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
- ${POD_CIDR:-192.168.0.0/16}
serviceDomain: cluster.local
services:
cidrBlocks:
- 10.128.0.0/12
- ${SERVICE_CIDR:-10.128.0.0/12}
topology:
class: aws-quick-start
controlPlane:
replicas: 1
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: clusterConfig
value:
Expand All @@ -31,9 +31,9 @@ spec:
nfd: {}
aws:
region: us-west-2
version: v1.27.5
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: 1
replicas: ${WORKER_MACHINE_COUNT}
2 changes: 1 addition & 1 deletion examples/capi-quick-start/aws-cluster-identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: AWSClusterStaticIdentity
metadata:
labels:
cluster.x-k8s.io/provider: aws
name: aws-quick-start
name: ${CLUSTER_NAME}
spec:
allowedNamespaces:
list:
Expand Down
12 changes: 6 additions & 6 deletions examples/capi-quick-start/docker-cluster-cilium-crs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ kind: Cluster
metadata:
labels:
cluster.x-k8s.io/provider: docker
name: docker-quick-start-crs-cilium
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
- ${POD_CIDR:-192.168.0.0/16}
serviceDomain: cluster.local
services:
cidrBlocks:
- 10.128.0.0/12
- ${SERVICE_CIDR:-10.128.0.0/12}
topology:
class: docker-quick-start
controlPlane:
metadata: {}
replicas: 1
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: clusterConfig
value:
Expand All @@ -27,9 +27,9 @@ spec:
strategy: ClusterResourceSet
nfd: {}
docker: {}
version: v1.27.5
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: 1
replicas: ${WORKER_MACHINE_COUNT}
12 changes: 6 additions & 6 deletions examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ kind: Cluster
metadata:
labels:
cluster.x-k8s.io/provider: docker
name: docker-quick-start-helm-addon-cilium
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
- ${POD_CIDR:-192.168.0.0/16}
serviceDomain: cluster.local
services:
cidrBlocks:
- 10.128.0.0/12
- ${SERVICE_CIDR:-10.128.0.0/12}
topology:
class: docker-quick-start
controlPlane:
metadata: {}
replicas: 1
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: clusterConfig
value:
Expand All @@ -27,9 +27,9 @@ spec:
strategy: HelmAddon
nfd: {}
docker: {}
version: v1.27.5
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: 1
replicas: ${WORKER_MACHINE_COUNT}
12 changes: 3 additions & 9 deletions hack/examples/kustomization.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@ patches:
patch: |-
- op: "add"
path: "/spec/topology/version"
value: "${KUBERNETES_VERSION}"
value: "$${KUBERNETES_VERSION}"
- op: "add"
path: "/spec/clusterNetwork/pods"
value:
cidrBlocks:
- "192.168.0.0/16"
- "$${POD_CIDR:-192.168.0.0/16}"
- op: "add"
path: "/spec/clusterNetwork/services"
value:
cidrBlocks:
- "10.128.0.0/12"
- "$${SERVICE_CIDR:-10.128.0.0/12}"
- op: "add"
path: "/spec/clusterNetwork/serviceDomain"
value: "cluster.local"
- op: "add"
path: "/spec/topology/controlPlane/replicas"
value: 1
- op: "add"
path: "/spec/topology/workers/machineDeployments/0/replicas"
value: 1
4 changes: 3 additions & 1 deletion hack/examples/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ kustomize build ./hack/examples |
) \
>/dev/null

sed -i'' "s/^ name: .\+$/ name: \${CLUSTER_NAME}/" "${EXAMPLE_CLUSTERS_DIR}"/*.yaml

# TODO Remove once CAPA templates default to using external cloud provider.
sed -i'' s/cloud-provider:\ aws/cloud-provider:\ external/g "${EXAMPLE_CLUSTERCLASSES_DIR}/aws-cluster-class.yaml"
sed -i'' 's/cloud-provider:\ aws/cloud-provider:\ external/g' "${EXAMPLE_CLUSTERCLASSES_DIR}/aws-cluster-class.yaml"

0 comments on commit a1aa75a

Please sign in to comment.