-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from openinfradev/release
main merge ( 20230831 )
- Loading branch information
Showing
2 changed files
with
130 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,12 +147,6 @@ spec: | |
] | ||
when: "{{workflow.parameters.object_store}} == s3" | ||
|
||
# TODO: 전체 완성을 위해서는 아래내역을 구현하여 동적인 bucket을 만드는 방식으로 구현해야 하지만 | ||
# 5월 오픈전 가능한 형상을 위해 협의한 바(아래)에 따라 본부분은 기존 준비됀 것을 사용하는 것으로 구현하고 추후 수정하다. | ||
# 1. 사용자가 생성하는 첫번째 클러스터는 primary cluster | ||
# 2. primary cluster는 계약이 종료되기 전까지 임의 삭제불가 | ||
# 3. 개별 클러스터에서 수행되는 모니터링은 없고 계약단위에서 수행되어야 함 | ||
# 하지만 이부분에 datasource 바꿔주는 부분을 포함하고 있으므로 일단 한번 타야할듯... | ||
- - name: change-target | ||
template: change-logging-target | ||
arguments: | ||
|
@@ -216,6 +210,28 @@ spec: | |
- name: primary_cluster | ||
- name: member_clusters | ||
steps: | ||
|
||
- - name: change-thanos-sidecar | ||
template: sub-change-thanos-sidecar | ||
arguments: | ||
parameters: | ||
- name: primary_cluster | ||
value: '{{inputs.parameters.primary_cluster}}' | ||
- name: member_clusters | ||
value: '{{inputs.parameters.member_clusters}}' | ||
|
||
- - name: render-current-cluster | ||
templateRef: | ||
name: event-gitea-render-manifests | ||
template: main | ||
arguments: | ||
parameters: | ||
- name: decapod_site_repo | ||
value: "{{ workflow.parameters.github_account }}/{{ workflow.parameters.cluster_id }}" | ||
- name: base_repo_branch | ||
value: "{{ workflow.parameters.base_repo_branch }}" | ||
when: "{{steps.change-thanos-sidecar.outputs.parameters.changed}} != 'NO_CHANGE_HERE'" # 이미 변경내역이 반영된 (한번 수행됐던) 클러스터라면 랜더링은 필요없음 | ||
|
||
- - name: sync-organization-changes | ||
template: sub-sync-organization-changes | ||
arguments: | ||
|
@@ -232,10 +248,10 @@ spec: | |
arguments: | ||
parameters: | ||
- name: decapod_site_repo | ||
value: "{{ workflow.parameters.github_account }}/{{steps.sync-organization-changes.outputs.parameters.primary_cluster}}" | ||
value: "{{ workflow.parameters.github_account }}/{{steps.sync-organization-changes.outputs.parameters.changed}}" | ||
- name: base_repo_branch | ||
value: "{{ workflow.parameters.base_repo_branch }}" | ||
when: "{{steps.sync-organization-changes.outputs.parameters.primary_cluster}} != 'NO_CHANGE_HERE'" | ||
when: "{{steps.sync-organization-changes.outputs.parameters.changed}} != 'NO_CHANGE_HERE'" | ||
|
||
####################### | ||
# Template Definition # | ||
|
@@ -258,22 +274,9 @@ spec: | |
retryStrategy: | ||
limit: 2 | ||
|
||
# - name: sub-prepare-bucket | ||
# inputs: | ||
# parameters: | ||
# - name: primary_cluster | ||
# container: | ||
# name: prepare-bucket | ||
# image: harbor.taco-cat.xyz/tks/hyperkube:v1.18.6 | ||
# command: | ||
# - /bin/bash | ||
# - '-c' | ||
# - | | ||
# echo "prepare bucket for the '{{workflow.parameters.organization_id}}' (clusters: '{{inputs.parameters.primary_cluster}}')" | ||
# activeDeadlineSeconds: 900 | ||
# retryStrategy: | ||
# limit: 2 | ||
|
||
# function sub-pre-change-logging-target | ||
# 1. Change endpoint of fluentbit-output (all in org.) | ||
# 2. Change endpoint of thanos-sidecar in prometheus-pod (all in org.) | ||
- name: sub-pre-change-logging-target | ||
inputs: | ||
parameters: | ||
|
@@ -546,6 +549,104 @@ spec: | |
path: /mnt/out/modified_cluster_list.txt | ||
activeDeadlineSeconds: 900 | ||
|
||
- name: sub-change-thanos-sidecar | ||
inputs: | ||
parameters: | ||
- name: primary_cluster | ||
- name: member_clusters | ||
container: | ||
name: logging-target-changer | ||
image: harbor.taco-cat.xyz/tks/shyaml_jq_yq_kubectl_python:3.11 | ||
command: | ||
- /bin/bash | ||
- '-c' | ||
- | | ||
#/bin/bash | ||
set -ex | ||
function log() { | ||
level=$1 | ||
msg=$2 | ||
date=$(date '+%F %H:%M:%S') | ||
echo "[$date] $level $msg" | ||
} | ||
current_cluster={{workflow.parameters.cluster_id}} | ||
primary_cluster={{inputs.parameters.primary_cluster}} | ||
member_clusters="{{inputs.parameters.member_clusters}}" | ||
empty_char= | ||
if [ -z ${primary_cluster} ] || [ "${primary_cluster}" = "$empty_char" ]; then | ||
primary_cluster=${current_cluster} | ||
fi | ||
S3_Service="s3://ap-northeast-2" | ||
cp /kube/value kubeconfig_adm | ||
export KUBECONFIG=kubeconfig_adm | ||
################# | ||
# updates | ||
################# | ||
GIT_ACCOUNT={{workflow.parameters.github_account}} | ||
if [[ $GIT_SVC_URL == https://* ]]; then | ||
repository_base=https://${TOKEN//[$'\t\r\n ']}@${GIT_SVC_URL/http:\/\//}/${GIT_ACCOUNT}/ | ||
else | ||
repository_base=http://${TOKEN//[$'\t\r\n ']}@${GIT_SVC_URL/http:\/\//}/${GIT_ACCOUNT}/ | ||
fi | ||
log "INFO" "##### change the loki target to $LOKI_HOST:$LOKI_PORT and $S3_Service (the current target is ${current_cluster})" | ||
[ -d ${current_cluster} ] || git clone ${repository_base}${current_cluster} | ||
cd ${current_cluster} | ||
yq -i e "del(.charts[] | select(.name == \"thanos-config\").override.objectStorage)" ${current_cluster}/lma/site-values.yaml | ||
yq -i e ".charts |= map(select(.name == \"thanos-config\").override.objectStorage.type=\"s3\")" ${current_cluster}/lma/site-values.yaml | ||
yq -i e ".charts |= map(select(.name == \"thanos-config\").override.objectStorage.rawConfig.endpoint=\"s3.ap-northeast-2.amazonaws.com\")" ${current_cluster}/lma/site-values.yaml | ||
yq -i e ".charts |= map(select(.name == \"thanos-config\").override.objectStorage.rawConfig.region=\"ap-northeast-2\")" ${current_cluster}/lma/site-values.yaml | ||
yq -i e ".charts |= map(select(.name == \"thanos-config\").override.objectStorage.rawConfig.bucket=\"${primary_cluster}-tks-thanos\")" ${current_cluster}/lma/site-values.yaml | ||
yq -i e ".charts |= map(select(.name == \"thanos-config\").override.objectStorage.rawConfig.signature_version2=false)" ${current_cluster}/lma/site-values.yaml | ||
git config --global user.name "tks" | ||
git config --global user.email "[email protected]" | ||
if [[ `git status --porcelain` ]]; then | ||
log "INFO" "##### commit changes on ${current_cluster} to use s3" | ||
cmessage="changes on ${current_cluster} to use s3" | ||
git add ${current_cluster}/lma/site-values.yaml | ||
git commit -m "change loki and thanos endpoints. (by set-primary workflow)" -m "$cmessage" | ||
git push | ||
modified_clusters=${current_cluster} | ||
# echo -n "${current_cluster} " >> /mnt/out/modified_cluster_list.txt | ||
else | ||
log "INFO" "No change on the cluster ${current_cluster}" | ||
echo NO_CHANGE_HERE > /mnt/out/modified_cluster_list.txt | ||
fi | ||
cd - | ||
rm -rf ${current_cluster} | ||
jq -n '$ARGS.positional' --args $modified_clusters > /mnt/out/modified_cluster_list.txt | ||
env: | ||
- name: OBJECT_SOTRE | ||
value: "{{workflow.parameters.object_store}}" | ||
envFrom: | ||
- secretRef: | ||
name: "git-svc-token" | ||
volumeMounts: | ||
- name: kubeconfig-adm | ||
mountPath: "/kube" | ||
- name: out | ||
mountPath: /mnt/out | ||
volumes: | ||
- name: out | ||
emptyDir: {} | ||
outputs: | ||
parameters: | ||
- name: changed | ||
valueFrom: | ||
path: /mnt/out/modified_cluster_list.txt | ||
activeDeadlineSeconds: 900 | ||
|
||
- name: sub-sync-organization-changes | ||
inputs: | ||
parameters: | ||
|
@@ -658,10 +759,10 @@ spec: | |
git add ${primary_cluster}/lma/site-values.yaml | ||
git commit -m "change thanos-query stores. (by set-primary workflow)" -m "$cmessage" | ||
git push | ||
echo ${primary_cluster} > /mnt/out/primary_cluster.txt | ||
echo ${primary_cluster} > /mnt/out/changed.txt | ||
else | ||
log "INFO" "No change on the cluster ${member}" | ||
echo NO_CHANGE_HERE > /mnt/out/primary_cluster.txt | ||
echo NO_CHANGE_HERE > /mnt/out/changed.txt | ||
fi | ||
if [ "$OBJECT_SOTRE" != "s3" ]; then | ||
|
@@ -673,7 +774,7 @@ spec: | |
git add ${primary_cluster}/lma/site-values.yaml | ||
git commit -m "change iamRoles(s3). (by set-primary workflow)" -m "$cmessage" | ||
git push | ||
echo ${primary_cluster} > /mnt/out/primary_cluster.txt | ||
echo ${primary_cluster} > /mnt/out/changed.txt | ||
else | ||
log "INFO" "(iamRoles) No change on the cluster ${member}" | ||
fi | ||
|
@@ -702,9 +803,9 @@ spec: | |
emptyDir: {} | ||
outputs: | ||
parameters: | ||
- name: primary_cluster | ||
- name: changed | ||
valueFrom: | ||
path: /mnt/out/primary_cluster.txt | ||
path: /mnt/out/changed.txt | ||
activeDeadlineSeconds: 900 | ||
|
||
|
||
|