Skip to content

Commit 5669769

Browse files
committed
Error out if $KUBECONFIG is not readable.
Note that we unset KUBECONFIG in each script, avoiding a workload cluster setting from the environment. If the management cluster's kubeconfig is NOT in the default ~/.kube/config, we can override it only on cluster-settings.env. Signed-off-by: Kurt Garloff <kurt@garloff.de>
1 parent 53e2302 commit 5669769

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

02-deploy-capi.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
#!/bin/bash
22
# Rollout ORC, CAPI, CAPO
33
set -e
4+
# We need settings (not really yet)
5+
unset KUBECONFIG
6+
if test -n "$1"; then
7+
SET="$1"
8+
else
9+
if test -e cluster-settings.env; then SET=cluster-settings.env;
10+
else echo "You need to pass a cluster-settings.env file as parameter"; exit 1
11+
fi
12+
fi
13+
# Read settings -- make sure you can trust it
14+
source "$SET"
415
# Set feature flags
516
export CLUSTER_TOPOLOGY=true
617
export EXP_CLUSTER_RESOURCE_SET=true
718
export EXP_RUNTIME_SDK=true
19+
# We must have the management cluster creds in ~/.kub/config
20+
KUBECONFIG=${KUBECONFIG:-~/.kube/config}
21+
if test ! -r $KUBECONFIG; then
22+
echo "ERROR: Must have KUBECONFIG for mgmt cluster in $KUBECONFIG"
23+
echo " You can create a management cluster with 01-kind-cluster.sh"
24+
exit 1
25+
fi
826
# We need ORC these days and clusterctl has chosen to ignore that
927
kubectl apply -f https://github.com/k-orc/openstack-resource-controller/releases/latest/download/install.yaml
1028
# Rollout capi and capo (assuming that orc gets deployed independently)
1129
clusterctl init --infrastructure openstack
1230
# Wait for completion
1331
kubectl -n capi-system rollout status deployment
1432
kubectl -n capo-system rollout status deployment
15-

cluster-settings-template.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#
55
# TODO: Check whether we can make this more compatible with v1 KaaS
66
#
7+
### Management cluster
8+
# You do not normally override it
9+
#KUBECONFIG=~/.kube/config
710
### Per namespace: secrets
811
# The namespace to keep your CS objects for a set of clusters (use e.g. cloud project name)
912
CS_NAMESPACE=clusterns

0 commit comments

Comments
 (0)