Skip to content

Commit

Permalink
feature. create tks-endpoint-secret when cluster creating
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkfree committed Jul 11, 2024
1 parent e77a064 commit ff3e885
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
4 changes: 4 additions & 0 deletions dockerfiles/Dockerfile.e2e-test
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ 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 sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
RUN sed -i s/^#.*baseurl=http/baseurl=https/g /etc/yum.repos.d/*.repo
RUN sed -i s/^mirrorlist=http/#mirrorlist=https/g /etc/yum.repos.d/*.repo

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

Expand Down
18 changes: 10 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.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand All @@ -31,7 +31,7 @@ spec:
- name: description
container:
name: create-organization
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -92,9 +92,10 @@ spec:
- name: cloud_service
- name: cluster_endpoint
- name: policy_ids
- name: cluster_domains
container:
name: create-usercluster
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand All @@ -120,6 +121,7 @@ spec:
--description "{{inputs.parameters.description}}" \
--cloud-service "{{inputs.parameters.cloud_service}}" \
--cluster-endpoint "{{inputs.parameters.cluster_endpoint}}" \
--domains "{{inputs.parameters.cluster_domains}}" \
--stack 1 \
--tks-cp-node $TKS_CP_NODE \
--tks-infra-node $TKS_INFRA_NODE \
Expand Down Expand Up @@ -164,7 +166,7 @@ spec:
- name: organization_id
container:
name: install-usercluster
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -217,7 +219,7 @@ spec:
- name: cluster_id
container:
name: delete-usercluster
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -260,7 +262,7 @@ spec:
- name: description
container:
name: create-appgroup
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -310,7 +312,7 @@ spec:
- name: appgroup_id
container:
name: delete-appgroup
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -350,7 +352,7 @@ spec:
- name: name
container:
name: get-appgroup-id
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.0
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.2.1
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down
60 changes: 60 additions & 0 deletions tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ spec:
]
when: "{{steps.tks-create-cluster-repo.outputs.parameters.infra_provider}} == byoh"

- - name: tks-create-config-secret
template: create-endpoint-secret
arguments:
parameters:
- name: cluster_domains
value: "{{steps.tks-get-cluster-info.outputs.parameters.cluster_domains}}"
- name: cluster_id
value: "{{ workflow.parameters.cluster_id }}"
when: "{{steps.tks-create-cluster-repo.outputs.parameters.infra_provider}} == byoh"

- - name: init-cluster-for-tks
template: init-cluster-for-tks
arguments:
Expand Down Expand Up @@ -839,3 +849,53 @@ spec:
value: "cluster-admin-delete"
- name: group_list
value: '["cluster-admin-delete"]'

- name: create-endpoint-secret
inputs:
parameters:
- name: cluster_domains
- name: cluster_id
container:
name: create-namespace
image: harbor.taco-cat.xyz/tks/hyperkube:v1.18.6
command:
- /bin/bash
- '-c'
- |
CLUSTER_ID={{inputs.parameters.cluster_id}}
GRAFANA_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("grafana"))|.url)'[])
LOKI_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("loki"))|.url)'[])
MINIO_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("minio"))|.url)'[])
PROMETHEUS_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("prometheus"))|.url)'[])
THANOS_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("thanos"))|.url)'[])
KIALI_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("kiali"))|.url)'[])
JAEGER_URL=$(echo $CLUSTER_DOMAINS | jq -r '.[] | map(select(.domainType | contains("jaeger"))|.url)'[])
if [ "$CLUSTER_IP" = "" ]; then
echo "ERROR::Endpoint for the cluster is not given!!!"
exit -1
fi
cat <<EOF > tks-endpoint-secret.yaml
---
apiVersion: v1
kind: Secret
metadata:
name: tks-endpoint-secret
namespace: ${CLUSTER_ID}
data:
grafana: $(echo ${GRAFANA_URL} | base64) # 30001
loki: $(echo ${LOKI_URL}:30002 | base64) # 30002
minio: $(echo ${MINIO_URL}:30003 | base64) # 30003
prometheus: $(echo ${PROMETHEUS_URL}:30004 | base64) # 30004
thanos: $(echo ${THANOS_URL}:30005 | base64) # 30005 (queryfrontend만 합시다...)
kiali: $(echo ${KIALI_URL}:30011 | base64) # 30011
jaeger: $(echo ${JAEGER_URL}:30012 | base64) # 30012
EOF
kubectl apply -f tks-endpoint-secret.yaml
env:
- name: CLUSTER_DOMAINS
value: "{{inputs.parameters.cluster_domains}}"

activeDeadlineSeconds: 30
4 changes: 4 additions & 0 deletions tks-stack/tks-stack-create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ spec:
value: ""
- name: policy_ids
value: ""
- name: cluster_domains
value: ""

templates:
- name: main
Expand Down Expand Up @@ -68,6 +70,8 @@ spec:
value: "{{workflow.parameters.cluster_endpoint}}"
- name: policy_ids
value: "{{workflow.parameters.policy_ids}}"
- name: cluster_domains
value: "{{workflow.parameters.cluster_domains}}"

- - name: call-create-appgroup-for-LMA
templateRef:
Expand Down
8 changes: 8 additions & 0 deletions tks_info/get-tks-cluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
- name: cluster_type
valueFrom:
path: /mnt/out/cluster_type.txt
- name: cluster_domains
valueFrom:
path: /mnt/out/cluster_domains.txt
volumes:
- name: out
emptyDir: {}
Expand Down Expand Up @@ -67,6 +70,7 @@ spec:
print(res.text)
clusterSiteValues = res.json()['clusterSiteValues']
clusterDomains = clusterSiteValues['domains']
with open("/mnt/out/cluster_info.txt", "w") as f:
#cluster_conf = str(clusterSiteValues)
Expand All @@ -77,3 +81,7 @@ spec:
cluster_type = clusterSiteValues['clusterType']
print(cluster_type)
f.write(cluster_type)
with open("/mnt/out/cluster_domains.txt", "w") as f:
cluster_domains = json.dumps(clusterDomains)
print(cluster_domains)
f.write(cluster_domains)

0 comments on commit ff3e885

Please sign in to comment.