diff --git a/tks-cluster/create-usercluster-wftpl.yaml b/tks-cluster/create-usercluster-wftpl.yaml index 1e60abd1..ba9fdba5 100644 --- a/tks-cluster/create-usercluster-wftpl.yaml +++ b/tks-cluster/create-usercluster-wftpl.yaml @@ -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 @@ -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 ;; *)