클러스터에서 Kubernetes 리소스를 배포할 때, 특정 순서로 배포해야 하는 경우가 있습니다. 예를 들어, Custom Resource Definition (CRD)은 해당 유형의 모든 사용자 지정 리소스를 생성하기 전에 존재해야 합니다.
Sveltos를 사용하면 Kubernetes 리소스의 배포 순서를 지정할 수 있어 이 문제를 해결할 수 있습니다.
ClusterProfile 순서
A ClusterProfile is a Kubernetes custom resource definition (CRD) that defines the resources that you want to deploy on a set of Kubernetes clusters.
ClusterProfile을 사용하여 고객이 순서를 정의할 수 있습니다:
- 코드>helmCharts 필드 사용:
helmCharts
필드를 통해 배포해야 할 Helm 차트 목록을 지정할 수 있으며, Sveltos는 이 필드에 나열된 순서대로 Helm 차트를 배포합니다. - 코드>policyRefs 필드 사용:
policyRefs
필드를 통해ConfigMap
및 Secret 리소스 목록을 참조할 수 있으며, 이들의 내용을 배포해야 합니다. Sveltos는 이 필드에 나열된 순서대로 리소스를 배포합니다.
다음은 몇 가지 예시입니다:
- 다음
ClusterProfile
은 먼저 Prometheus Helm 차트를 배포한 후 Grafana Helm 차트를 배폅합니다:
apiVersion: config.projectsveltos.io/v1alpha1
kind: ClusterProfile
metadata:
name: prometheus-grafana
spec:
clusterSelector: env=fv
syncMode: Continuous
helmCharts:
- repositoryURL: https://prometheus-community.github.io/helm-charts
repositoryName: prometheus-community
chartName: prometheus-community/prometheus
chartVersion: 23.4.0
releaseName: prometheus
releaseNamespace: prometheus
helmChartAction: Install
- repositoryURL: https://grafana.github.io/helm-charts
repositoryName: grafana
chartName: grafana/grafana
chartVersion: 6.58.9
releaseName: grafana
releaseNamespace: grafana
helmChartAction: Install
이벤트와 함께 리소스 배포 순서
어떤 경우에는 다른 리소스가 정상 상태가 된 후에만 Kubernetes 리소스를 배포해야 합니다. 예를 들어, 데이터베이스에 테이블을 생성하는 작업은 데이터베이스 배포가 정상이 될 때까지 배포되지 않아야 합니다.
Sveltos는 이벤트를 사용하여 애플리케이션의 롤아웃을 제어할 수 있도록 도와줍니다.
이벤트는 특정 조건이 충족될 때 전송되는 알림입니다. 예를 들어, 데이터베이스 배포가 정상적으로 작동하기 시작할 때 이벤트를 생성할 수 있습니다.
그런 다음 이 이벤트를 사용하여 데이터베이스에 테이블을 생성하는 작업의 배포를 트리거할 수 있습니다.
이벤트를 사용함으로써 애플리케이션이 제어되고 질서 있는 방식으로 롤아웃되는 것을 보장할 수 있습니다.
위의 예에서 Sveltos는 다음과 같이 지시되었습니다:
- PostgreSQL 배포 및 서비스 배포
- PostgreSQL 배포가 준비될 때까지 기다림
- 데이터베이스에 테이블을 생성하는 작업 배포
- 작업이 완료될 때까지 기다림
- PostgreSQL 배포에 접근할 수 있는 todo-app 배포
- todo-app이 정상적으로 작동하기를 기다림
- todo-app을 통해 데이터베이스에 항목을 추가하는 작업 배포
이 예제에 대한 모든 YAML은 projectsveltos 문서에서 찾을 수 있습니다.
이 프로젝트를 지원하세요
I hope you enjoyed this article! If you did, please check out the GitHub repo for the project. The repo contains the code, documentation, and examples, so it’s a great resource for getting started.
도움이 되는 것으로 판단되면 프로젝트에 별을 달아주세요.
읽어주셔서 감사합니다!
Source:
https://dzone.com/articles/deploy-kubernetes-resources-in-a-controlled-and-or