Skip to content

Commit

Permalink
create-tks-usercluster: enable cluster-autoscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
zugwan committed Mar 21, 2022
1 parent 62cbf52 commit 042e497
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
value: "tks-info.tks.svc"

volumes:
- name: config
- name: kubeconfig-adm
secret:
secretName: tks-admin-kubeconfig-secret
- name: artifacts
Expand Down Expand Up @@ -63,12 +63,21 @@ spec:
"path": "cluster-api-aws",
"namespace": "argo",
"target_cluster": "tks-admin"
},
{
"app_group": "tks-cluster-aws",
"path": "cluster-autoscaler-rbac",
"namespace": "argo",
"target_cluster": "tks-admin"
}
]
- - name: wait-for-clster-to-be-registered
template: wait-for-cluster-registration

- - name: prepare-cluster-autoscaler
template: prepare-cluster-autoscaler

- - name: install-addons
templateRef:
name: create-application
Expand Down Expand Up @@ -100,6 +109,10 @@ spec:
"app_group": "tks-cluster-aws",
"path": "metrics-server",
"namespace": "taco-system",
},
{
"path": "cluster-autoscaler",
"namespace": "kube-system",
"target_cluster": ""
}
]
Expand Down Expand Up @@ -137,3 +150,31 @@ spec:
env:
- name: target
value: "{{workflow.parameters.cluster_id}}"

- name: prepare-cluster-autoscaler
container:
name: prepare-cluster-autoscaler
image: 'k8s.gcr.io/hyperkube:v1.18.6'
command:
- /bin/bash
- '-cx'
- |
cp /kube/value kubeconfig-adm
CLUSTER=tks-admin-v2
ADMIN_USER=tks-admin-v2-admin
TOKEN=$(kubectl get secrets -n {{workflow.parameters.cluster_id}} "$(kubectl get sa cluster-autoscaler -n {{workflow.parameters.cluster_id}} -o=jsonpath={.secrets[0].name})" -o=jsonpath={.data.token} | base64 -d)
kubectl --kubeconfig kubeconfig-adm config set-credentials cluster-autoscaler --token=$TOKEN
kubectl --kubeconfig kubeconfig-adm config set-context cluster-autoscaler --cluster=$CLUSTER --user=cluster-autoscaler
kubectl --kubeconfig kubeconfig-adm config use-context cluster-autoscaler
kubectl --kubeconfig kubeconfig-adm config delete-context "$ADMIN_USER@$CLUSTER"
kubectl --kubeconfig kubeconfig-adm config delete-user "$ADMIN_USER"
KUBECONFIG_WORKLOAD=$(kubectl get secret -n {{workflow.parameters.cluster_id}} {{workflow.parameters.cluster_id}}-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
echo -e "kubeconfig_workload:\n$KUBECONFIG_WORKLOAD" | head -n 5
cat <<< "$KUBECONFIG_WORKLOAD" > kubeconfig_workload
kubectl --kubeconfig kubeconfig_workload -n kube-system create secret generic mgmt-kubeconfig --from-file=kubeconfig-adm
volumeMounts:
- name: kubeconfig-adm
mountPath: "/kube"

0 comments on commit 042e497

Please sign in to comment.