Skip to content

Commit

Permalink
Update config/cspo/secret.yaml
Browse files Browse the repository at this point in the history
Co-authored-by: Roman Hros <roman.hros@dnation.cloud>
Signed-off-by: Michal Gubricky <michal.gubricky@dnation.cloud>
  • Loading branch information
2 people authored and matofeder committed Jan 15, 2024
1 parent 1effa1a commit bf11775
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
1 change: 0 additions & 1 deletion .envrc.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export KUBECONFIG=$PWD/.mgt-cluster-kubeconfig.yaml
export K8S_VERSION=1-27
export GIT_PROVIDER_B64=Z2l0aHVi
export GIT_ACCESS_TOKEN_B64=mybase64encodedtoken
export GIT_ORG_NAME_B64=U292ZXJlaWduQ2xvdWRTdGFjaw==
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ builder-image-push: ## Build $(CONTROLLER_SHORT)-builder to a new version. For m
create-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL)
cat .cluster.yaml | $(ENVSUBST) - | $(KUBECTL) apply -f -

delete-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL)
cat .cluster.yaml | $(ENVSUBST) - | $(KUBECTL) delete -f -

get-kubeconfig-workload-cluster:
./hack/get-kubeconfig-of-workload-cluster.sh

.PHONY: tilt-up
tilt-up: env-vars-for-wl-cluster $(ENVSUBST) $(KUBECTL) $(KUSTOMIZE) $(TILT) cluster ## Start a mgt-cluster & Tilt. Installs the CRDs and deploys the controllers
EXP_CLUSTER_RESOURCE_SET=true $(TILT) up --port=10351
18 changes: 13 additions & 5 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def prepare_environment():
if not os.path.exists('.cluster.yaml'):
local("cp config/cspo/cluster.yaml .cluster.yaml")

if not os.path.exists('.clusterstacktemplate.yaml'):
local("cp config/cspo/clusterstacktemplate.yaml .clusterstacktemplate.yaml")
if not os.path.exists('.cspotemplate.yaml'):
local("cp config/cspo/cspotemplate.yaml .cspotemplate.yaml")

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

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

def clusterstack():
Expand Down Expand Up @@ -242,6 +242,7 @@ def waitforsystem():
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capi-kubeadm-bootstrap-system")
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capi-kubeadm-control-plane-system")
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capi-system")
local("kubectl wait --for=condition=ready --timeout=300s pod --all -n capo-system")

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

create_secret()

clusterstack_template()
cspo_template()

cmd_button(
"create workload cluster",
argv=["make", "create-workload-cluster-openstack"],
location=location.NAV,
icon_name="add_circle",
)

cmd_button(
"delete workload cluster",
argv=["make", "delete-workload-cluster-openstack"],
location=location.NAV,
icon_name="cancel",
)
File renamed without changes.
2 changes: 2 additions & 0 deletions config/cspo/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ data:
clouds.yaml: ${ENCODED_CLOUDS_YAML}
kind: Secret
metadata:
labels:
clusterctl.cluster.x-k8s.io/move: "true"
name: "${SECRET_NAME}"
namespace: cluster
13 changes: 12 additions & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ make tilt-up
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.

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.

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.

To interact with your freshly created workload cluster, you can use these commands:

```shell
make get-kubeconfig-workload-cluster #KUBECONFIG for the workload cluster is placed here: ".workload-cluster-kubeconfig.yaml"
export KUBECONFIG=$PWD/.workload-cluster-kubeconfig.yaml
```

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.

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.

To tear down the workload cluster press the "Delete Workload Cluster" button. After a few minutes, the resources should be deleted.
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.

To tear down the kind cluster, use:

Expand Down
30 changes: 30 additions & 0 deletions hack/get-kubeconfig-of-workload-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [ -z "$CLUSTER_NAME" ]; then
echo "env var CLUSTER_NAME is missing. Failed to get kubeconfig of workload cluster"
exit 1
fi
namespace=$(kubectl get cluster -A| grep "${CLUSTER_NAME}" | head -1 | cut -d' ' -f1)
kubeconfig=".workload-cluster-kubeconfig.yaml"
kubectl get secrets -n "$namespace" "${CLUSTER_NAME}-kubeconfig" -ojsonpath='{.data.value}' | base64 -d > "$kubeconfig"

if [ ! -s "$kubeconfig" ]; then
echo "failed to get kubeconfig of workload cluster"
exit 1
fi

chmod a=,u=rw $kubeconfig

0 comments on commit bf11775

Please sign in to comment.