diff --git a/README.md b/README.md index 259170eb7..7cfacf67b 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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): diff --git a/examples/capi-quick-start/aws-cluster-calico-crs.yaml b/examples/capi-quick-start/aws-cluster-calico-crs.yaml index 9dd133b04..3744299cc 100644 --- a/examples/capi-quick-start/aws-cluster-calico-crs.yaml +++ b/examples/capi-quick-start/aws-cluster-calico-crs.yaml @@ -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: @@ -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} diff --git a/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml b/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml index 74c7a7661..5c93f52b5 100644 --- a/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml +++ b/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml @@ -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: @@ -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} diff --git a/examples/capi-quick-start/aws-cluster-identity.yaml b/examples/capi-quick-start/aws-cluster-identity.yaml index 2f2d521a8..55a8bd851 100644 --- a/examples/capi-quick-start/aws-cluster-identity.yaml +++ b/examples/capi-quick-start/aws-cluster-identity.yaml @@ -3,7 +3,7 @@ kind: AWSClusterStaticIdentity metadata: labels: cluster.x-k8s.io/provider: aws - name: aws-quick-start + name: ${CLUSTER_NAME} spec: allowedNamespaces: list: diff --git a/examples/capi-quick-start/docker-cluster-cilium-crs.yaml b/examples/capi-quick-start/docker-cluster-cilium-crs.yaml index afb40e19f..045cae5a9 100644 --- a/examples/capi-quick-start/docker-cluster-cilium-crs.yaml +++ b/examples/capi-quick-start/docker-cluster-cilium-crs.yaml @@ -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: @@ -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} diff --git a/examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml b/examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml index 124632994..0e9fe26ae 100644 --- a/examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml +++ b/examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml @@ -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: @@ -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} diff --git a/hack/examples/kustomization.yaml.tmpl b/hack/examples/kustomization.yaml.tmpl index 1116ac95f..4dcd8acef 100644 --- a/hack/examples/kustomization.yaml.tmpl +++ b/hack/examples/kustomization.yaml.tmpl @@ -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 diff --git a/hack/examples/sync.sh b/hack/examples/sync.sh index a62a8fb3e..784aa483e 100755 --- a/hack/examples/sync.sh +++ b/hack/examples/sync.sh @@ -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"