Skip to content

Commit

Permalink
use a different secret for workload kubeconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
zugwan committed Feb 14, 2023
1 parent 7387927 commit d551966
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,27 @@ spec:
cp /kube/value kubeconfig_adm
export KUBECONFIG=kubeconfig_adm
kubectl wait --for=condition=Available --timeout=600s kcp -n $CLUSTER_ID $CLUSTER_ID-control-plane
KUBECONFIG_WORKLOAD=$(kubectl get secret -n $CLUSTER_ID $CLUSTER_ID-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$KUBECONFIG_WORKLOAD" > kubeconfig_workload
case $INFRA_PROVIDER in
aws)
# check whether this workload cluster is managed or not
kcp_count=$(kubectl get kcp -n $CLUSTER_ID $CLUSTER_ID | wc -l)
awsmcp_count=$(kubectl get awsmcp -n $CLUSTER_ID $CLUSTER_ID | wc -l)
if [ $kcp_count = 1 ]; then
kubectl wait --for=condition=Available --timeout=600s kcp -n $CLUSTER_ID $CLUSTER_ID
KUBECONFIG_WORKLOAD=$(kubectl get secret -n $CLUSTER_ID $CLUSTER_ID-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
elif [ $awsmcp_count = 1]; then
kubectl wait --for=condition=Available --timeout=600s awsmcp -n $CLUSTER_ID $CLUSTER_ID
KUBECONFIG_WORKLOAD=$(kubectl get secret -n $CLUSTER_ID $CLUSTER_ID-user-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
else
echo "Wrong AWS Cluster type!"
exit 1
fi
cat <<< "$KUBECONFIG_WORKLOAD" > kubeconfig_workload
echo "Wait for machinepool $CLUSTER_ID-mp-$TKS_NODE_NAME generated"
while [ $(kubectl get machinepool -n $CLUSTER_ID $CLUSTER_ID-mp-$TKS_NODE_NAME --ignore-not-found | wc -l) == 0 ]
do
Expand All @@ -261,7 +275,10 @@ spec:
;;
byoh)
echo "BYOH"
kubectl wait --for=condition=Available --timeout=600s kcp -n $CLUSTER_ID $CLUSTER_ID
KUBECONFIG_WORKLOAD=$(kubectl get secret -n $CLUSTER_ID $CLUSTER_ID-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$KUBECONFIG_WORKLOAD" > kubeconfig_workload
;;
*)
Expand Down

0 comments on commit d551966

Please sign in to comment.