Skip to content

Commit

Permalink
lma: Using endpoint secret if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sungil committed Oct 23, 2023
1 parent 573aee2 commit e374d99
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 183 deletions.
45 changes: 2 additions & 43 deletions deploy_apps/tks-lma-federation-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,48 +269,6 @@ spec:
default: "Something wrong"
path: /mnt/out/managed_cluster.txt

- name: GetMyThanosScEndpoint
inputs:
parameters:
- name: target_namespace
outputs:
parameters:
- name: my_thanos_sc_ep
valueFrom:
path: /mnt/out/thanos_sc_ep.txt
volumes:
- name: out
emptyDir: {}
container:
name: 'get-thanos-ep'
image: harbor.taco-cat.xyz/tks/hyperkube:v1.18.6
envFrom:
- secretRef:
name: "git-svc-token"
env:
- name: TARGET_NAMESPACE
value: '{{inputs.parameters.target_namespace}}'
volumeMounts:
- name: out
mountPath: /mnt/out
command:
- /bin/bash
- '-c'
- |
kube_secret=$(kubectl get secret -n {{workflow.parameters.cluster_id}} {{workflow.parameters.cluster_id}}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
echo -e "kube_secret:\n$kube_secret" | head -n 5
cat <<< "$kube_secret" > /etc/kubeconfig
THANOS_SC_PORT='10901'
THANOS_SC_SVC='lma-thanos-external'
thanos_sc_ep=$(kubectl --kubeconfig=/etc/kubeconfig get svc ${THANOS_SC_SVC} -n ${TARGET_NAMESPACE} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
if [[ -z "$thanos_sc_ep" ]]; then
echo "Error: could not retrieve thanos sidecar endpoint from service resource."
exit 1
else
echo "$thanos_sc_ep:$THANOS_SC_PORT" > /mnt/out/thanos_sc_ep.txt
fi
- name: create-keycloak-client
activeDeadlineSeconds: 600
inputs:
Expand Down Expand Up @@ -358,7 +316,8 @@ spec:
sleep 5
done
grafana_ep_secret=${kubectl --kubeconfig=kubeconfig get secret -n taco-system tks-endpoint-secret -o jsonpath='{.data.grafana}'| base64 -d }
grafana_ep_secret=$(kubectl get secret -n ${cluster_id} tks-endpoint-secret -o jsonpath='{.data.grafana}'| base64 -d )
if [ grafana_ep_secret == "" ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]; do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath='{.spec.type}')" != "LoadBalancer" ]; then
Expand Down
244 changes: 144 additions & 100 deletions deploy_apps/tks-primary-cluster.yaml

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions deploy_apps/tks-remove-lma-federation-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ spec:
- - name: set-primary-cluster-on-tks-info
templateRef:
name: tks-primary-cluster
template: sub-set-primay-cluster-on-tks-info
template: sub-set-primary-cluster-on-tks-info
arguments:
parameters:
- name: cluster_id
Expand Down Expand Up @@ -201,7 +201,6 @@ spec:
TKS_API_URL = "{{workflow.parameters.tks_api_url}}"
CLUSTER_ID = "{{workflow.parameters.cluster_id}}"
def getToken() :
data = {
'organizationId' : os.environ['ORGANIZATION_ID'],
Expand Down Expand Up @@ -336,7 +335,7 @@ spec:
sleep 5
done
grafana_ep_secret=${kubectl --kubeconfig=kubeconfig get secret -n taco-system tks-endpoint-secret -o jsonpath='{.data.grafana}'| base64 -d }
grafana_ep_secret=${kubectl get secret -n ${cluster_id} tks-endpoint-secret -o jsonpath='{.data.grafana}'| base64 -d }
if [ grafana_ep_secret == "" ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]; do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath='{.spec.type}')" != "LoadBalancer" ]; then
Expand Down
24 changes: 15 additions & 9 deletions git-repo/create-cluster-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,31 @@ spec:
## Replace site-values with fetched params ##
yq -i e ".global.clusterName=\"$CLUSTER_ID\"" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
val_tksCpNode=$(echo $CLUSTER_INFO | jq -r '.tksCpNode')
val_tksInfraNode=$(echo $CLUSTER_INFO | jq -r '.tksInfraNode')
val_tksUserNode=$(echo $CLUSTER_INFO | jq -r '.tksUserNode')
yq -i e ".global.tksCpNode=$val_tksCpNode" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksInfraNode=$val_tksInfraNode" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksUserNode=$val_tksUserNode" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
echo $INFRA_PROVIDER
case $INFRA_PROVIDER in
aws)
## Fetch cluster params from cluster_info file ##
val_ssh_key=$(echo $CLUSTER_INFO | jq -r '.sshKeyName')
val_region=$(echo $CLUSTER_INFO | jq -r '.clusterRegion')
val_tksCpNode=$(echo $CLUSTER_INFO | jq -r '.tksCpNode')
val_tksInfraNode=$(echo $CLUSTER_INFO | jq -r '.tksInfraNode')
val_tksInfraNodeMax=$(echo $CLUSTER_INFO | jq -r '.tksInfraNodeMax')
val_tksInfraNodeType=$(echo $CLUSTER_INFO | jq -r '.tksInfraNodeType')
val_tksUserNode=$(echo $CLUSTER_INFO | jq -r '.tksUserNode')
val_tksUserNodeMax=$(echo $CLUSTER_INFO | jq -r '.tksUserNodeMax')
val_tksUserNodeType=$(echo $CLUSTER_INFO | jq -r '.tksUserNodeType')
yq -i e ".global.sshKeyName=\"$val_ssh_key\"" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.clusterRegion=\"$val_region\"" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksCpNode=$val_tksCpNode" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksInfraNode=$val_tksInfraNode" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksInfraNodeMax=$val_tksInfraNodeMax" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksInfraNodeType=\"$val_tksInfraNodeType\"" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksUserNode=$val_tksUserNode" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksUserNodeMax=$val_tksUserNodeMax" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.tksUserNodeType=\"$val_tksUserNodeType\"" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
Expand All @@ -126,7 +128,11 @@ spec:
;;
byoh)
echo "BYOH"
cluster_endpoint_host=$(echo $CLUSTER_INFO | jq -r '.byoClusterEndpointHost')
cluster_endpoint_port=$(echo $CLUSTER_INFO | jq -r '.byoClusterEndpointPort')
yq -i e ".global.clusterEndpointHost=\"$cluster_endpoint_host\"" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
yq -i e ".global.clusterEndpointPort=$cluster_endpoint_port" $CLUSTER_ID/$CLUSTER_ID/tks-cluster/site-values.yaml
;;
*)
Expand Down Expand Up @@ -195,7 +201,7 @@ spec:
path: /mnt/out/infra_provider.txt
- name: managed_cluster
valueFrom:
default: "Something wrong"
default: "false"
path: /mnt/out/managed_cluster.txt

- name: createRepoCredential
Expand Down Expand Up @@ -249,4 +255,4 @@ spec:
parameter: "{{steps.createClusterRepo.outputs.parameters.infra_provider}}"
- name: managed_cluster
valueFrom:
parameter: "{{steps.createClusterRepo.outputs.parameters.managed_cluster}}"
parameter: "{{steps.createClusterRepo.outputs.parameters.managed_cluster}}"
19 changes: 11 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.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
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.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -90,9 +90,10 @@ spec:
- name: description
- name: infra_conf
- name: cloud_service
- name: cluster_endpoint
container:
name: create-usercluster
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand All @@ -109,13 +110,15 @@ spec:
TKS_USER_NODE=$(echo "{{inputs.parameters.infra_conf}}" | jq -r '.tksUserNode')
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}}" \
--cloud-service "{{inputs.parameters.cloud_service}}" \
--cluster-endpoint "{{inputs.parameters.cluster_endpoint}}" \
--stack 1 \
--tks-cp-node $TKS_CP_NODE \
--tks-infra-node $TKS_INFRA_NODE \
Expand Down Expand Up @@ -159,7 +162,7 @@ spec:
- name: organization_id
container:
name: install-usercluster
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -212,7 +215,7 @@ spec:
- name: cluster_id
container:
name: delete-usercluster
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -255,7 +258,7 @@ spec:
- name: description
container:
name: create-appgroup
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -305,7 +308,7 @@ spec:
- name: appgroup_id
container:
name: delete-appgroup
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down Expand Up @@ -345,7 +348,7 @@ spec:
- name: name
container:
name: get-appgroup-id
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.3
image: harbor.taco-cat.xyz/tks/tks-e2e-test:v3.1.4
envFrom:
- secretRef:
name: "tks-api-secret"
Expand Down
Loading

0 comments on commit e374d99

Please sign in to comment.