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

feature. add site-value for creating stack #163

Merged
merged 2 commits into from
May 2, 2023
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: 2 additions & 0 deletions dockerfiles/Dockerfile.e2e-test
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ COPY tks /usr/local/bin/tks
RUN curl -Lo /usr/bin/kubectl "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
RUN chmod +x /usr/bin/kubectl

RUN yum install -y epel-release
RUN yum install -y jq

CMD ["bash"]
14 changes: 9 additions & 5 deletions git-repo/create-cluster-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ spec:
aws)
## Fetch cluster params from cluster_info file ##
val_ssh_key=$(echo $CLUSTER_INFO | jq -r '.sshKeyName')
val_region=$(echo $CLUSTER_INFO | jq -r '.region')
val_num_of_az=$(echo $CLUSTER_INFO | jq -r '.numOfAz')
val_machine_type=$(echo $CLUSTER_INFO | jq -r '.machineType')
val_min_size=$(echo $CLUSTER_INFO | jq -r '.minSizePerAz')
val_max_size=$(echo $CLUSTER_INFO | jq -r '.maxSizePerAz')
val_region=$(echo $CLUSTER_INFO | jq -r '.clusterRegion')
val_num_of_az=$(echo $CLUSTER_INFO | jq -r '.mdNumOfAz')
val_machine_type=$(echo $CLUSTER_INFO | jq -r '.mdMachineType')
val_min_size=$(echo $CLUSTER_INFO | jq -r '.mdMinSizePerAz')
val_max_size=$(echo $CLUSTER_INFO | jq -r '.mdMaxSizePerAz')
val_mp_replicas=$(echo $CLUSTER_INFO | jq -r '.mpReplicas')
val_mp_machine_type=$(echo $CLUSTER_INFO | jq -r '.mpNodeMachineType')

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
Expand All @@ -91,6 +93,8 @@ spec:
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
sed -i "s/cpReplicas:\ CHANGEME/cpReplicas: 3/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/mpReplicas:\ CHANGEME/mpReplicas: $val_mp_replicas/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
sed -i "s/mpMachineType:\ CHANGEME/mpMachineType: $val_mp_machine_type/g" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml

## multi-tenancy ##
if [ "$CLOUD_ACCOUNT_ID" = "NULL" ]; then
Expand Down
26 changes: 18 additions & 8 deletions tks-cli/tks-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
- name: login-tks-api
container:
name: login-tks-api
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand All @@ -31,7 +31,7 @@ spec:
- name: description
container:
name: create-organization
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -87,9 +87,10 @@ spec:
- name: cloud_account_id
- name: creator
- name: description
- name: infra_conf
container:
name: create-usercluster
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand All @@ -99,13 +100,22 @@ spec:
- |
tks login {{workflow.parameters.tks_api_url}} --organization-id ${ORGANIZATION_ID} --account-id ${ACCOUNT_ID} --password ${PASSWORD}

echo "infra_conf : {{inputs.parameters.infra_conf}}"

CP_NODE_CNT=$(echo "{{inputs.parameters.infra_conf}}" | jq -r '.cpNodeCnt')
TKS_NODE_CNT=$(echo "{{inputs.parameters.infra_conf}}" | jq -r '.tksNodeCnt')
USER_NODE_CNT=$(echo "{{inputs.parameters.infra_conf}}" | jq -r '.userNodeCnt')

CL_NAME="{{inputs.parameters.cluster_name}}"
echo "* Create $CL_NAME cluster"
tks cluster create ${CL_NAME} \
--stack-template-id "{{inputs.parameters.stack_template_id}}" \
--organization-id "{{inputs.parameters.organization_id}}" \
--cloud-account-id "{{inputs.parameters.cloud_account_id}}" \
--description "{{inputs.parameters.description}}"
--description "{{inputs.parameters.description}}" \
--cp-node-cnt $CP_NODE_CNT \
--tks-node-cnt $TKS_NODE_CNT \
--user-node-cnt $USER_NODE_CNT

threshold=30
for i in $(seq 1 $threshold)
Expand Down Expand Up @@ -145,7 +155,7 @@ spec:
- name: cluster_id
container:
name: delete-usercluster
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -188,7 +198,7 @@ spec:
- name: description
container:
name: create-appgroup
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -238,7 +248,7 @@ spec:
- name: appgroup_id
container:
name: delete-appgroup
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -278,7 +288,7 @@ spec:
- name: name
container:
name: get-appgroup-id
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.3
image: harbor-cicd.taco-cat.xyz/tks/tks-e2e-test:v2.1.5
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down
4 changes: 4 additions & 0 deletions tks-stack/tks-stack-create-aws-msa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
value: "aws-msa-reference"
- name: creator
value: ""
- name: infra_conf
value: ""

templates:
- name: main
Expand All @@ -43,6 +45,8 @@ spec:
value: "{{workflow.parameters.creator}}"
- name: description
value: "{{workflow.parameters.description}}"
- name: infra_conf
value: "{{workflow.parameters.infra_conf}}"

- - name: call-create-appgroup-for-LMA
templateRef:
Expand Down
8 changes: 4 additions & 4 deletions tks_info/get-tks-cluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ spec:
return resJson['user']['token']


res = requests.get(TKS_API_URL+"/api/1.0/clusters/" + CLUSTER_ID, headers={"Authorization": "Bearer " + getToken(), "Content-Type" : "application/json"} )
res = requests.get(TKS_API_URL+"/api/1.0/clusters/" + CLUSTER_ID + "/site-values", headers={"Authorization": "Bearer " + getToken(), "Content-Type" : "application/json"} )
if res.status_code != 200 :
sys.exit('Failed to get cluster')

print(res.text)
cluster = res.json()['cluster']
clusterSiteValues = res.json()['clusterSiteValues']

with open("/mnt/out/cluster_info.txt", "w") as f:
#cluster_conf = str(cluster['conf'])
cluster_conf = json.dumps(cluster['conf'])
#cluster_conf = str(clusterSiteValues)
cluster_conf = json.dumps(clusterSiteValues)
print(cluster_conf)
f.write(cluster_conf)