Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit bf11775

Browse files
michal-gubrickychess-knight
authored andcommitted
Update config/cspo/secret.yaml
Co-authored-by: Roman Hros <[email protected]> Signed-off-by: Michal Gubricky <[email protected]>
1 parent 1effa1a commit bf11775

File tree

7 files changed

+63
-7
lines changed

7 files changed

+63
-7
lines changed

.envrc.sample

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export KUBECONFIG=$PWD/.mgt-cluster-kubeconfig.yaml
2-
export K8S_VERSION=1-27
32
export GIT_PROVIDER_B64=Z2l0aHVi
43
export GIT_ACCESS_TOKEN_B64=mybase64encodedtoken
54
export GIT_ORG_NAME_B64=U292ZXJlaWduQ2xvdWRTdGFjaw==

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ builder-image-push: ## Build $(CONTROLLER_SHORT)-builder to a new version. For m
572572
create-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL)
573573
cat .cluster.yaml | $(ENVSUBST) - | $(KUBECTL) apply -f -
574574

575+
delete-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL)
576+
cat .cluster.yaml | $(ENVSUBST) - | $(KUBECTL) delete -f -
577+
578+
get-kubeconfig-workload-cluster:
579+
./hack/get-kubeconfig-of-workload-cluster.sh
580+
575581
.PHONY: tilt-up
576582
tilt-up: env-vars-for-wl-cluster $(ENVSUBST) $(KUBECTL) $(KUSTOMIZE) $(TILT) cluster ## Start a mgt-cluster & Tilt. Installs the CRDs and deploys the controllers
577583
EXP_CLUSTER_RESOURCE_SET=true $(TILT) up --port=10351

Tiltfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def prepare_environment():
8888
if not os.path.exists('.cluster.yaml'):
8989
local("cp config/cspo/cluster.yaml .cluster.yaml")
9090

91-
if not os.path.exists('.clusterstacktemplate.yaml'):
92-
local("cp config/cspo/clusterstacktemplate.yaml .clusterstacktemplate.yaml")
91+
if not os.path.exists('.cspotemplate.yaml'):
92+
local("cp config/cspo/cspotemplate.yaml .cspotemplate.yaml")
9393

9494
def patch_args_with_extra_args(namespace, name, extra_args):
9595
args_str = str(local("kubectl get deployments {} -n {} -o jsonpath='{{.spec.template.spec.containers[0].args}}'".format(name, namespace)))
@@ -203,8 +203,8 @@ def create_secret():
203203
cmd = "cat .secret.yaml | {} | kubectl apply -f -".format(envsubst_cmd)
204204
local_resource('supersecret', cmd, labels=["clouds-yaml-secret"])
205205

206-
def clusterstack_template():
207-
cmd = "cat .clusterstacktemplate.yaml | {} | kubectl apply -f -".format(envsubst_cmd)
206+
def cspo_template():
207+
cmd = "cat .cspotemplate.yaml | {} | kubectl apply -f -".format(envsubst_cmd)
208208
local_resource('cspotemplate', cmd, labels=["cspo-template"])
209209

210210
def clusterstack():
@@ -242,6 +242,7 @@ def waitforsystem():
242242
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capi-kubeadm-bootstrap-system")
243243
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capi-kubeadm-control-plane-system")
244244
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capi-system")
245+
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capo-system")
245246

246247
def deploy_observability():
247248
k8s_yaml(blob(str(local("{} build {}".format(kustomize_cmd, "./hack/observability/"), quiet = True))))
@@ -282,11 +283,18 @@ prepare_environment()
282283

283284
create_secret()
284285

285-
clusterstack_template()
286+
cspo_template()
286287

287288
cmd_button(
288289
"create workload cluster",
289290
argv=["make", "create-workload-cluster-openstack"],
290291
location=location.NAV,
291292
icon_name="add_circle",
292293
)
294+
295+
cmd_button(
296+
"delete workload cluster",
297+
argv=["make", "delete-workload-cluster-openstack"],
298+
location=location.NAV,
299+
icon_name="cancel",
300+
)

config/cspo/secret.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ data:
33
clouds.yaml: ${ENCODED_CLOUDS_YAML}
44
kind: Secret
55
metadata:
6+
labels:
7+
clusterctl.cluster.x-k8s.io/move: "true"
68
name: "${SECRET_NAME}"
79
namespace: cluster

docs/develop.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,22 @@ make tilt-up
2626
2727
You should make sure that everything in the UI looks green. If not, you can trigger the Tilt workflow again. In the case of the `cspotemplate`, this might be necessary, as it cannot be applied right after the startup of the cluster and fails. Tilt unfortunately does not include a waiting period.
2828

29+
If everything is green, then you can already check for your clusterstack that has been deployed. You can use a tool like k9s to have a look at the management cluster and its custom resources.
30+
31+
In case your clusterstack shows that it is ready, you can deploy a workload cluster. This could be done through the Tilt UI, by pressing the button in the top right corner `Create Workload Cluster`. This triggers the `make create-workload-cluster-openstack`, which uses the environment variables and the cluster-template.
32+
33+
To interact with your freshly created workload cluster, you can use these commands:
34+
35+
```shell
36+
make get-kubeconfig-workload-cluster #KUBECONFIG for the workload cluster is placed here: ".workload-cluster-kubeconfig.yaml"
37+
export KUBECONFIG=$PWD/.workload-cluster-kubeconfig.yaml
38+
```
39+
2940
In case you want to change some code, you can do so and see that Tilt triggers on save. It will update the container of the operator automatically.
3041

3142
If you want to change something in your ClusterStack or Cluster custom resources, you can have a look at `.cluster.yaml` and `.clusterstack.yaml`, which Tilt uses.
3243

33-
To tear down the workload cluster press the "Delete Workload Cluster" button. After a few minutes, the resources should be deleted.
44+
To tear down the workload cluster, click on the `Delete Workload Cluster` button in the top right corner of the Tilt UI. This action triggers the execution of `make delete-workload-cluster-openstack`. After a few minutes, the resources should be successfully deleted.
3445

3546
To tear down the kind cluster, use:
3647

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
if [ -z "$CLUSTER_NAME" ]; then
18+
echo "env var CLUSTER_NAME is missing. Failed to get kubeconfig of workload cluster"
19+
exit 1
20+
fi
21+
namespace=$(kubectl get cluster -A| grep "${CLUSTER_NAME}" | head -1 | cut -d' ' -f1)
22+
kubeconfig=".workload-cluster-kubeconfig.yaml"
23+
kubectl get secrets -n "$namespace" "${CLUSTER_NAME}-kubeconfig" -ojsonpath='{.data.value}' | base64 -d > "$kubeconfig"
24+
25+
if [ ! -s "$kubeconfig" ]; then
26+
echo "failed to get kubeconfig of workload cluster"
27+
exit 1
28+
fi
29+
30+
chmod a=,u=rw $kubeconfig

0 commit comments

Comments
 (0)