Skip to content

Commit

Permalink
Merge pull request #321 from openinfradev/fix_cluster_autoscaler_chec…
Browse files Browse the repository at this point in the history
…k_admin_type

tks-cluster: fix an admin cluster type check error
  • Loading branch information
ktkfree authored Nov 10, 2023
2 parents 50a943b + 75647b1 commit 7bceb1a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -651,20 +651,19 @@ spec:
kubectl --kubeconfig kubeconfig config delete-context "$ADMIN_CONTEXT"
kubectl --kubeconfig kubeconfig config delete-user "$ADMIN_USER"
}
CURRENT_CONTEXT=$(kubectl --kubeconfig kubeconfig config current-context)
case $INFRA_PROVIDER in
aws)
# check whether admin cluster is managed or not
kcp_count=$(kubectl get kcp -n $CLUSTER_ID $CLUSTER_ID | grep -v NAME | wc -l)
awsmcp_count=$(kubectl get awsmcp -n $CLUSTER_ID $CLUSTER_ID | grep -v NAME | wc -l)
kcp_count=$(kubectl get kcp -n default $CLUSTER | grep -v NAME | wc -l)
awsmcp_count=$(kubectl get awsmcp -n default $CLUSTER | grep -v NAME | wc -l)
if [ $kcp_count = 1 ]; then # Self-managed control plane cluster
create_cluster_autoscaler_kubeconfig "$CLUSTER-admin@$CLUSTER" "$CLUSTER-admin"
create_cluster_autoscaler_kubeconfig "$CURRENT_CONTEXT" "$CLUSTER-admin"
elif [ $awsmcp_count = 1 ]; then # EKS cluster
CURRENT_CONTEXT=$(kubectl --kubeconfig kubeconfig config current-context)
create_cluster_autoscaler_kubeconfig "$CURRENT_CONTEXT" "$CURRENT_CONTEXT"
create_cluster_autoscaler_kubeconfig "$CURRENT_CONTEXT" "$CLUSTER-user"
else
echo "Wrong AWS Cluster type!"
exit 1
Expand Down

0 comments on commit 7bceb1a

Please sign in to comment.