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

[Dev] User Cluster를 삭제하는 워크플로우 개발 #7

Closed
bluejayA opened this issue Aug 18, 2021 · 13 comments
Closed

[Dev] User Cluster를 삭제하는 워크플로우 개발 #7

bluejayA opened this issue Aug 18, 2021 · 13 comments
Assignees
Labels
backlogged Approved as an official feature development enhancement New feature or request type: kubernetes feature related to kubernetes cluster management type: tks-service feature related to tks service management

Comments

@bluejayA
Copy link
Contributor

bluejayA commented Aug 18, 2021

Describe the Story

- [ ] A clear and concise description of what this story is.

클러스터 삭제 workflow template 개발 (주관님 코멘트 내용 병합)
(App 삭제 워크플로우 (LMA/Service-mesh)는 LCM에서 별도 호출하니 제외)

  • argocd cluster APP auto-sync disable
  • Cross-plane 에서 생성한 자원 삭제 워크플로우 (ELB, route53 데이터 ... )
  • ... 추가...로 k8s 자원 삭제 (혹은 다른 워크플로우에서 미진한 부분 검증 후 해당 워크플루우 수정)
  • cluster-api 'cluster' CR 제거: 연관 자원들은 CAPI 컨트롤러가 제거함
  • argocd cluster APP 삭제
  • tks-info에 cluster 상태 업데이트
  • Git repo 삭제 워크 플로우 ( contract 는 남겨두고 cluster 만? )
  • AWS VPC 삭제

Acceptance criteria (Validation Scenario)

- [ ] This is something that can be verified to show that this story is satisfied.
- [ ] This should have information for QA to validate this story

산출물: Argo Workflow template

Additional information (Optional)

서비스 삭제 : https://github.com/openinfradev/tks-issues/issues/97
GIt repo 삭제: https://github.com/openinfradev/tks-issues/issues/166

@bluejayA bluejayA added backlogged Approved as an official feature development enhancement New feature or request type: kubernetes feature related to kubernetes cluster management type: tks-service feature related to tks service management labels Aug 18, 2021
@zugwan
Copy link

zugwan commented Feb 11, 2022

아래 단계로 작업을 수행하거나 다른 워크플로우를 호출하는 워크플로우 개발

  1. argocd cluster APP auto-sync disable
  2. App 삭제 워크플로우 (LMA/Service-mesh)
  3. Cross-plane 에서 생성한 자원 삭제 워크플로우
  4. ... 추가...로 k8s 자원 삭제 (혹은 다른 워크플로우에서 미진한 부분 검증 후 해당 워크플루우 수정)
  5. cluster api 'cluster' 제거: 연관 자원들은 CAPI 컨트롤러가 제거함
  6. argocd cluster APP 삭제
  7. Git 저장소 자원 삭제 워크 플로우

@robertchoi80
Copy link

robertchoi80 commented Feb 28, 2022

우선 가장 기본적인 ArgoCD App 삭제 및 DB 삭제를 위한 코드 추가 진행 중

  • tks-proto의 cluster-lcm에 deleteCluster RPC 정의 추가
  • tks-info 에서 RPC 구현 (-> 태규님이 I/F 변환 없이 updatedTime 만 추가로 DB 입력하기로..)
  • tks-flow에서 workflow 구현

@robertchoi80
Copy link

robertchoi80 commented Feb 28, 2022

혹시 cluster 삭제시 DB 값은 삭제하지 않고 status만 변경하기로 했었는지 확인 필요
-> 그렇게 하는 것으로 확인!

@ktkfree
Copy link

ktkfree commented Mar 2, 2022

tks-proto 및 tks-info 의 delete cluster API 는 아래 티켓에서 제가 처리하면 되겠습니다.

proto I/F 는 작업후 공유 드리겠습니다.

이 티켓에서는 delete workflow 만 처리하면 될 것 같아요.

@robertchoi80
Copy link

tks-proto 및 tks-info 의 delete cluster API 는 아래 티켓에서 제가 처리하면 되겠습니다.

proto I/F 는 작업후 공유 드리겠습니다.

이 티켓에서는 delete workflow 만 처리하면 될 것 같아요.

openinfradev/tks-proto#28 올려놓긴 했는데, 어떻게 할까요??

@ktkfree
Copy link

ktkfree commented Mar 2, 2022

tks-proto 및 tks-info 의 delete cluster API 는 아래 티켓에서 제가 처리하면 되겠습니다.

proto I/F 는 작업후 공유 드리겠습니다.
이 티켓에서는 delete workflow 만 처리하면 될 것 같아요.

openinfradev/tks-proto#28 올려놓긴 했는데, 어떻게 할까요??

lint 에러가 발생하고 있네요. WIP 으로 올리셨으니 close 하시면, 제가 lint 확인 및 다시 PR 올리겠습니다.

아울러 아래 flow 로 삭제를 생각하고 있는데, 한번 확인 부탁 드립니다. ( 생성 과 삭제가 살짝 다릅니다. )

cluster 생성 Flow
. tks-cluster-lcm :: cluster 관련 DB data 생성
. tks-cluster-lcm :: cluster 상태 변경 ( running )
. tks-cluster-lcm :: 생성 workflow 호출
. workflow :: tks-info cluster 상태 변경 ( complete or fail )

cluster 삭제 Flow
. tks-cluster-lcm :: tks-info cluster 상태 변경 ( deleting )
. tks-cluster-lcm :: 삭제 workflow 호출
. workflow :: tks-info cluster 상태 변경 ( deleted or fail )

@robertchoi80
Copy link

robertchoi80 commented Mar 2, 2022

@ktkfree 더이상 커밋할 내용은 없어서 WIP 문구는 제거하였습니다.
lint 에러는 로그를 보니 proto 코드의 문제는 아니고 lint action 자체의 문제인 듯 보이네요. 그것도 언젠가 고치긴 해야겠지만요.
일단 올린거 아까우니 머지하고 혹시 향후 추가할 내용 있으시면 추가 PR 올리시면 어떨까요??

올리신 flow는 동의합니다

@robertchoi80
Copy link

아래 브랜치에 workflow 초안 작성해서 올리고 테스트 중입니다.
https://github.com/openinfradev/tks-flow/blob/remove-usercluster-wf/tks-cluster/remove-usercluster-wftpl.yaml

cluster CR 삭제가 예상과 달리 비동기 방식으로 진행되므로, busy-waiting 로직 추가하여 다시 테스트 예정.

@ktkfree
Copy link

ktkfree commented Mar 2, 2022

@ktkfree 더이상 커밋할 내용은 없어서 WIP 문구는 제거하였습니다. lint 에러는 로그를 보니 proto 코드의 문제는 아니고 lint action 자체의 문제인 듯 보이네요. 그것도 언젠가 고치긴 해야겠지만요. 일단 올린거 아까우니 머지하고 혹시 향후 추가할 내용 있으시면 추가 PR 올리시면 어떨까요??

올리신 flow는 동의합니다

넵, 해당 PR 이 linter version 문제라서 super-linter v4 로 올리도록 매니저님 branch 에 수정했고, merge 했습니다 ^^

@ktkfree
Copy link

ktkfree commented Mar 3, 2022

아래 브랜치에 workflow 초안 작성해서 올리고 테스트 중입니다. https://github.com/openinfradev/tks-flow/blob/remove-usercluster-wf/tks-cluster/remove-usercluster-wftpl.yaml

cluster CR 삭제가 예상과 달리 비동기 방식으로 진행되므로, busy-waiting 로직 추가하여 다시 테스트 예정.

tks-cluster-lcm 에 api 를 추가했습니다.
. openinfradev/tks-cluster-lcm#29

tks-admin-v2 에서 테스트 가능할까요?

@robertchoi80
Copy link

robertchoi80 commented Mar 4, 2022

테스트 진행하다가 ArgoCD 앱 삭제 단계에서, cluster-api 를 제외한 csi-driver 등의 app들이 삭제되지 않고 hang 걸리는 증상이 발생했고, 에러는 다음과 같습니다.

Get "https://wf0hwx02z1ljdqr093h5c20k0u1r-k8s-1455462617.ap-northeast-2.elb.amazonaws.com:6443/apis/rbac.authorization.k8s.io/v1?timeout=32s": dial tcp: lookup wf0hwx02z1ljdqr093h5c20k0u1r-k8s-1455462617.ap-northeast-2.elb.amazonaws.com on 10.96.0.10:53: no such host

k8s-API 에 접근하지 못하는 에러인 걸로 보아, 이 앱들을 먼저 삭제하고 cluster를 가장 마지막에 삭제해야할 것 같습니다.

기존 코드에 간단히 argocd app delete 명령 추가해서 지워보려 했더니, app delete도 비동기 방식이라 삭제 후 busy-waitiing 구문 넣어서 삭제 완료된 것 확인하고 넘어가야 하네요. 결국 'by-label'로 동작하는 기존의 delete-apps 외에 개별 app 삭제가 가능한 WF도 추가로 만들어야겠습니다. (마침 승규님도 오늘 개별 앱 삭제가 필요하다 요청 주셨으니..)

@robertchoi80
Copy link

robertchoi80 commented Mar 4, 2022

openinfradev/decapod-flow#77

위와 같이 delete-apps 부분 확장하고, 이 template 호출해서 addon 및 csi-driver app 삭제를 각각 진행하도록 했는데, 이번엔 단일 app 내에서 deployment 나 daemonset 이 삭제가 제대로 안되고 hang 걸리는 증상이 있습니다.

kubelet  error killing pod: failed to "KillPodSandbox" for "8093cc40-ac3f-4113-a851-c3fa4d706c5f" with KillPodSandboxError: "rpc error: code = Unknown desc = failed to destroy network for sandbox \"859d24604be78cdf1ab3628d33b439c997f441edbc42810a3173e2f22886147d\": error getting ClusterInformation: connection is unauthorized: Unauthorized"

prometheus CR 처럼 삭제 순서의 문제일 수도 있지만, 에러 메세지상 다른 원인이 있을지 모르니 확인이 필요할듯 합니다.

@robertchoi80
Copy link

에러 메세지를 차분히 보니 분명 CNI 와 관련된 에러로 보였고, 실제 app 삭제 시에도 calico daemonset 이 삭제된 후 위의 에러가 발생하는 것으로 보여서, 삭제 순서를 다음과 같이 바꾸니 해결되었습니다

  • "csi-driver" argoCD app 삭제
  • calico controller deployment만 수동으로 삭제
  • "k8s-addons"(=calico) argocd app 삭제 (이때 calico daemonset 및 기타 리소스 지워짐)

그 이후 cluster(=cluster-api-aws) app 까지 무사히 삭제됩니다! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlogged Approved as an official feature development enhancement New feature or request type: kubernetes feature related to kubernetes cluster management type: tks-service feature related to tks service management
Projects
None yet
Development

No branches or pull requests

5 participants