Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using structured kustomize document on infra-selection #105

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy_apps/tks-ingress-controller-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ spec:
- name: list
value: |
[
{ "app_group": "tks-cluster-common", "path": "ingress-nginx", "namespace": "taco-system", "target_cluster": "" }
{ "app_group": "tks-cluster", "path": "ingress-nginx", "namespace": "taco-system", "target_cluster": "" }
]
21 changes: 10 additions & 11 deletions github_repo/create-cluster-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ spec:
git clone https://$(echo -n $TOKEN)@github.com/${USERNAME}/${CONTRACT_ID}.git

# Get cluster-api infra provider in the template
infra_provider_group="$(ls ${CONTRACT_ID}/$TEMPLATE_NAME | grep -v tks-cluster-common | grep tks-cluster)"
INFRA_PROVIDER=${infra_provider_group#tks-cluster-}
INFRA_PROVIDER="$(cat ${CONTRACT_ID}/$TEMPLATE_NAME/tks-cluster/kustomization.yaml | grep /infra/ | awk -F \/ '{print $3}')"
echo ${INFRA_PROVIDER} | tee /mnt/out/infra_provider.txt

cp -r ${CONTRACT_ID}/${TEMPLATE_NAME} ${CLUSTER_ID}/${CLUSTER_ID}
Expand All @@ -48,7 +47,7 @@ spec:
echo $CLUSTER_INFO

## Replace site-values with fetched params ##
sed -i "s/clusterName:\ cluster.local/clusterName:\ $CLUSTER_ID/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-common/site-values.yaml
sed -i "s/clusterName:\ cluster.local/clusterName:\ $CLUSTER_ID/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
case $INFRA_PROVIDER in
aws)
## Fetch cluster params from cluster_info file ##
Expand All @@ -61,17 +60,17 @@ spec:
val_max_size=$(echo $CLUSTER_INFO | sed 's/.*\(max_size_per_az:\ \S*\).*/\1/' | cut -d ':' -f2 | xargs)
echo "max_size_per_az: $val_max_size"

sed -i "s/clusterName:\ cluster.local/clusterName:\ $CLUSTER_ID/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/sshKeyName:\ CHANGEME/sshKeyName: $val_ssh_key/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/clusterRegion:\ CHANGEME/clusterRegion: $val_region/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/mdNumOfAz:\ CHANGEME/mdNumOfAz: $val_num_of_az/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/mdMinSizePerAz:\ CHANGEME/mdMinSizePerAz: $val_min_size/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/mdMaxSizePerAz:\ CHANGEME/mdMaxSizePerAz: $val_max_size/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/mdMachineType:\ CHANGEME/mdMachineType: $val_machine_type/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-aws/site-values.yaml
sed -i "s/clusterName:\ cluster.local/clusterName:\ $CLUSTER_ID/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/sshKeyName:\ CHANGEME/sshKeyName: $val_ssh_key/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/clusterRegion:\ CHANGEME/clusterRegion: $val_region/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/mdNumOfAz:\ CHANGEME/mdNumOfAz: $val_num_of_az/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/mdMinSizePerAz:\ CHANGEME/mdMinSizePerAz: $val_min_size/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/mdMaxSizePerAz:\ CHANGEME/mdMaxSizePerAz: $val_max_size/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/mdMachineType:\ CHANGEME/mdMachineType: $val_machine_type/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
;;

byoh)
sed -i "s/clusterName:\ cluster.local/clusterName:\ $CLUSTER_ID/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster-byoh/site-values.yaml
sed -i "s/clusterName:\ cluster.local/clusterName:\ $CLUSTER_ID/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
echo "BYOH"
;;

Expand Down
8 changes: 4 additions & 4 deletions github_repo/render-manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ spec:

if [[ ${SITE_NAME} != *"decapod"* ]]; then
log 0 "INFO" "Almost finished: changing namespace for aws-cluster-resouces from argo to cluster-name.."
sed -i "s/ namespace: argo/ namespace: ${site}/g" $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster-aws/cluster-api-aws/*
sed -i "s/ - argo/ - ${site}/g" $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster-aws/cluster-api-aws/*
sed -i "s/ namespace: argo/ namespace: ${site}/g" $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster/cluster-api-aws/*
sed -i "s/- argo/- ${site}/g" $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster/cluster-api-aws/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 PR 과 관련 없지만 추후 byoh 가 추가된다면 여기에도 추가가 되어야겠군요.

# It's possible besides of two above but very tricky!!
# sed -i "s/ argo$/ ${site}/g" $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster-aws/cluster-api-aws/*
# sed -i "s/ argo$/ ${site}/g" $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster/cluster-api-aws/*
echo "---
apiVersion: v1
kind: Namespace
Expand All @@ -152,7 +152,7 @@ spec:
# It bring the secret 'dacapod-argocd-config' using kubed
decapod-argocd-config: enabled
" > Namespace_aws_rc.yaml
mv Namespace_aws_rc.yaml $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster-aws/cluster-api-aws/
mv Namespace_aws_rc.yaml $(pwd)/${OUTPUT_DIR}/${site}/tks-cluster/cluster-api-aws/
fi

done
Expand Down
18 changes: 9 additions & 9 deletions tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
value: |
[
{
"app_group": "tks-cluster-aws",
"app_group": "tks-cluster",
"path": "cluster-api-aws",
"namespace": "argo",
"target_cluster": "tks-admin"
Expand All @@ -88,7 +88,7 @@ spec:
value: |
[
{
"app_group": "tks-cluster-byoh",
"app_group": "tks-cluster",
"path": "cluster-api-byoh",
"namespace": "argo",
"target_cluster": "tks-admin"
Expand All @@ -115,7 +115,7 @@ spec:
value: |
[
{
"app_group": "tks-cluster-common",
"app_group": "tks-cluster",
"path": "cluster-autoscaler-rbac",
"namespace": "argo",
"target_cluster": "tks-admin"
Expand All @@ -138,31 +138,31 @@ spec:
value: |
[
{
"app_group": "tks-cluster-common",
"app_group": "tks-cluster",
"path": "kubernetes-addons",
"namespace": "taco-system",
"target_cluster": ""
},
{
"app_group": "tks-cluster-common",
"app_group": "tks-cluster",
"path": "ingress-nginx",
"namespace": "taco-system",
"target_cluster": ""
},
{
"app_group": "tks-cluster-common",
"app_group": "tks-cluster",
"path": "metrics-server",
"namespace": "kube-system",
"target_cluster": ""
},
{
"app_group": "tks-cluster-common",
"app_group": "tks-cluster",
"path": "cluster-autoscaler",
"namespace": "kube-system",
"target_cluster": ""
},
{
"app_group": "tks-cluster-common",
"app_group": "tks-cluster",
"path": "kubed",
"namespace": "taco-system",
"target_cluster": ""
Expand All @@ -179,7 +179,7 @@ spec:
value: |
[
{
"app_group": "tks-cluster-aws",
"app_group": "tks-cluster",
"path": "aws-ebs-csi-driver",
"namespace": "kube-system",
"target_cluster": ""
Expand Down
3 changes: 1 addition & 2 deletions tks-cluster/remove-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ spec:
git clone https://$(echo -n $TOKEN)@github.com/${USERNAME}/${CLUSTER_ID}.git

# Get cluster-api infra provider in the cluster
infra_provider_group="$(ls ${CLUSTER_ID}/$CLUSTER_ID | grep -v tks-cluster-common | grep tks-cluster)"
INFRA_PROVIDER=${infra_provider_group#tks-cluster-}
INFRA_PROVIDER="$(cat ${CONTRACT_ID}/$TEMPLATE_NAME/tks-cluster/kustomization.yaml | grep /infra/ | awk -F \/ '{print $3}')"
echo ${INFRA_PROVIDER} | tee /mnt/out/infra_provider.txt
envFrom:
- secretRef:
Expand Down