Skip to content

Commit faae886

Browse files
committed
build: use clusterctl version for examples
Changed to a consistent "quick-start" usage and fixed the README
1 parent 91ece90 commit faae886

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@ make SKIP_BUILD=true dev.run-on-kind
2626
To create the ClusterClass and it's Templates with this runtime extension enabled, run:
2727

2828
```shell
29-
kubectl apply --server-side -f examples/capi-quickstart/cluster-class.yaml
29+
kubectl apply --server-side -f examples/capi-quick-start/capd-cluster-class.yaml
3030
```
3131

3232
To create a cluster, update `clusterConfig` variable and run:
3333

3434
```shell
35-
kubectl apply --server-side -f examples/capi-quickstart/cluster.yaml
35+
kubectl apply --server-side -f examples/capi-quick-start/capd-cluster.yaml
3636
```
3737

3838
Wait until control plane is ready:
3939

4040
```shell
41-
kubectl wait clusters/capi-quickstart --for=condition=ControlPlaneInitialized --timeout=5m
41+
kubectl wait clusters/capd-quick-start --for=condition=ControlPlaneInitialized --timeout=5m
4242
```
4343

4444
To get the kubeconfig for the new cluster, run:
4545

4646
```shell
47-
clusterctl get kubeconfig capi-quickstart > capd-kubeconfig
47+
clusterctl get kubeconfig capd-quick-start > capd-kubeconfig
4848
```
4949

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

5252
```shell
53-
kubectl config set-cluster capi-quickstart \
53+
kubectl config set-cluster capd-quick-start \
5454
--kubeconfig capd-kubeconfig \
55-
--server=https://$(docker port capi-quickstart-lb 6443/tcp)
55+
--server=https://$(docker port capd-quick-start-lb 6443/tcp)
5656
```
5757

5858
Wait until all nodes are ready (this indicates that CNI has been deployed successfully):
@@ -117,7 +117,7 @@ watch -n 0.5 kubectl --kubeconfig capd-kubeconfig get service/traefik
117117
To delete the workload cluster, run:
118118

119119
```shell
120-
kubectl delete cluster capi-quickstart
120+
kubectl delete cluster capd-quick-start
121121
```
122122

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

hack/examples/bases/capd/kustomization.yaml renamed to hack/examples/bases/capd/kustomization.yaml.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ configurations:
88
- kustomizeconfig.yaml
99

1010
resources:
11-
- https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.1/clusterclass-quick-start.yaml
12-
- https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.1/cluster-template-development.yaml
11+
- https://github.com/kubernetes-sigs/cluster-api/releases/download/$CLUSTERCTL_VERSION/clusterclass-quick-start.yaml
12+
- https://github.com/kubernetes-sigs/cluster-api/releases/download/$CLUSTERCTL_VERSION/cluster-template-development.yaml
1313

1414
namePrefix: capd-
1515

hack/examples/sync.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 D2iQ, Inc. All rights reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
set -euo pipefail
7+
IFS=$'\n\t'
8+
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
readonly SCRIPT_DIR
11+
12+
CAPD_KUSTOMIZATION_FILE="${SCRIPT_DIR}/bases/capd/kustomization.yaml"
13+
14+
# download the quick-start files that match the clusterctl version
15+
trap 'rm -rf ${CAPD_KUSTOMIZATION_FILE}' EXIT
16+
CLUSTERCTL_VERSION=$(clusterctl version -o short 2>/dev/null) envsubst \
17+
<"${SCRIPT_DIR}/bases/capd/kustomization.yaml.tmpl" >"${CAPD_KUSTOMIZATION_FILE}"
18+
19+
mkdir -p examples/capi-quick-start
20+
# Sync ClusterClass and all Templates
21+
kustomize build ./hack/examples |
22+
gojq --yaml-input --yaml-output '. | select(.kind != "Cluster")' >examples/capi-quick-start/capd-cluster-class.yaml
23+
# Sync Cluster
24+
kustomize build ./hack/examples |
25+
gojq --yaml-input --yaml-output '. | select(.kind == "Cluster")' >examples/capi-quick-start/capd-cluster.yaml

make/examples.mk

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
# Copyright 2023 D2iQ, Inc. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
KUBERNETES_VERSION ?= v1.27.5
5-
6-
# gojq mutations:
7-
# - ClusterClass: Add cluster-config external patch
8-
#
9-
# - Cluster: Add CNI label
10-
# - Cluster: Add an empty clusterConfig variable
114
.PHONY: examples.sync
12-
examples.sync: ## Syncs the examples by fetching upstream examples using clusterclt and applying gojq mutations
13-
mkdir -p examples/capi-quickstart
14-
# Sync ClusterClass and all Templates
15-
kustomize build ./hack/examples | \
16-
gojq --yaml-input --yaml-output '. | select(.kind != "Cluster")' > examples/capi-quickstart/capd-cluster-class.yaml
17-
# Sync Cluster
18-
kustomize build ./hack/examples | \
19-
gojq --yaml-input --yaml-output '. | select(.kind == "Cluster")' > examples/capi-quickstart/capd-cluster.yaml
5+
examples.sync: ## Syncs the examples by fetching upstream examples and applying kustomize patches
6+
hack/examples/sync.sh $(KUBERNETES_VERSION)

0 commit comments

Comments
 (0)