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

remove prometheus CR before LMA appgroup removal #73

Merged
merged 2 commits into from
Mar 2, 2022

Conversation

robertchoi80
Copy link
Contributor

@robertchoi80 robertchoi80 commented Feb 25, 2022

아래 버그 픽스하는 PR 입니다.
https://github.com/openinfradev/tks-issues/issues/182

관련된 openinfradev/tks-flow#41 도 함께 리뷰 부탁드립니다

@robertchoi80
Copy link
Contributor Author

TKS 쪽에 적용시 한가지 이슈가 있어, 내용 수정이 필요하니 아직 merge하지 말아주세요

@robertchoi80
Copy link
Contributor Author

기본 decapod 처럼 single cluster 에서 사용되는 경우와, TKS처럼 multi-cluster에서 사용되는 경우를 구분하다 보니 수정 사항이 많아졌습니다. 많은 테스트를 거쳐 두가지 case 모두 잘 동작하도록 만들었습니다.

@robertchoi80 robertchoi80 changed the title [WIP] remove prometheus CR before LMA appgroup removal remove prometheus CR before LMA appgroup removal Feb 27, 2022
@robertchoi80
Copy link
Contributor Author

이렇게 kubeconfig secret을 사전에 mount하지 않고, bash block 내에서 if 조건에 따라 읽어오도록 하니 굳이 두 케이스를 별도 step으로 나눌 필요 없이 간단히 해결되네요. 이 방향이 더 낫지 않을까 생각됩니다.

  - name: removePrometheusCr
    inputs:
      parameters:
        - name: namespace
    container:
      name: remove-prometheus-cr
      image: k8s.gcr.io/hyperkube:v1.18.6
      command:
        - /bin/bash
        - '-c'
        - |
          echo "Deleting prometheus CRs..."

          kube_params=""

          if [[ -n "{{workflow.parameters.cluster_id}}" ]]; then
            kube_secret=$(kubectl get secret -n argo {{workflow.parameters.cluster_id}}-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
            echo "kube_secret: $kube_secret"
            cat <<< "$kube_secret" > /etc/kubeconfig

            kube_params+="--kubeconfig=/etc/kubeconfig"
          fi

          kubectl $kube_params delete prometheus --all -n {{inputs.parameters.namespace}}
          kubectl $kube_params delete alertmanager --all -n {{inputs.parameters.namespace}}

@robertchoi80
Copy link
Contributor Author

위에 말한 방향으로 코드 수정 및 테스트까지 완료하였고, 커밋들도 1개로 합쳤습니다. 이제 리뷰해주시면 됩니다.

Copy link
Contributor

@intelliguy intelliguy left a comment

Choose a reason for hiding this comment

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

네임스페이스 관련 변경요청

@robertchoi80 robertchoi80 merged commit ec2f245 into openinfradev:main Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants