当前位置:网站首页>Cross cluster deployment of helm applications using karmada
Cross cluster deployment of helm applications using karmada
2022-06-28 16:57:00 【Huawei cloud developer Alliance】
Abstract : With the help of Karmada Native API The ability to support ,Karmada Can use Flux Make it easy Helm Cross cluster deployment of applications .
This article is shared from Huawei cloud community 《 Use Karmada Realization Helm Cross cluster deployment of applications 【 Cloud native open source 】》, author : Huawei cloud's native open source team .
background
By using Kubernetes Native API And provide advanced scheduling function ,Karmada It has implemented the... In the multi cluster scenario Kubernetes resources ( Include CRD) Distribution and management of . However, the current multi cluster application is often not a single resource form , Use Helm The use scenario of packaging applications is also very common .
With the help of Karmada Native API The ability to support ,Karmada Can use Flux Make it easy Helm Cross cluster deployment of applications .
Deploy Karmada
To deploy Karmada, You can refer to the community installation documentation (https://github.com/karmada-io/karmada/blob/master/docs/installation/installation.md). If you want to experience it quickly Karmada, We propose to adopt hack/local-up-karmada.sh Construct a Karmada Development environment of .
Deploy Flux
stay Karmada In control surface , You need to install Flux Of CRD, But there is no need to install Flux The controller is based on CRD Created CR object , They are considered resource templates , Not specific resource instances . be based on Karmada Of work API, They will be encapsulated as a work Object to the member cluster , Finally, the members in the cluster Flux The controller is tuned .
kubectl apply -k github.com/fluxcd/flux2/manifests/crds?ref=main --kubeconfig ~/.kube/karmada.configIn a member cluster , You can install the complete... Based on the following command Flux Components .
flux install --kubeconfig ~/.kube/members.config --context member1flux install --kubeconfig ~/.kube/members.config --context member2You can refer to the documentation here (https://fluxcd.io/docs/installation/) For more detailed installation Flux The details of the .
Tips : If you want to manage all your clusters based on HelmRelease Application , You need to install... In all your member clusters Flux.
Helm release distribution
Ready for work , Next, we will use a podinfo As an example, it demonstrates how to complete Helm chart distribution .
1. stay Karmada Define a in the control plane Flux Of HelmRepository CR Object and a HelmRelease CR object . They will be treated as resource templates .
apiVersion: source.toolkit.fluxcd.io/v1beta2kind: HelmRepositorymetadata: name: podinfospec: interval: 1m url: https://stefanprodan.github.io/podinfo ---
apiVersion: helm.toolkit.fluxcd.io/v2beta1kind: HelmReleasemetadata: name: podinfospec: interval: 5m chart: spec: chart: podinfo version: 5.0.3 sourceRef: kind: HelmRepository name: podinfo2. Define a Karmada Of PropagationPolicy Object to distribute their resource instances to the member cluster :
apiVersion: policy.karmada.io/v1alpha1kind: PropagationPolicymetadata: name: helm-repospec: resourceSelectors: - apiVersion: source.toolkit.fluxcd.io/v1beta2 kind: HelmRepository name: podinfo placement: clusterAffinity: clusterNames: - member1 - member2---
apiVersion: policy.karmada.io/v1alpha1kind: PropagationPolicymetadata: name: helm-releasespec: resourceSelectors: - apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease name: podinfo placement: clusterAffinity: clusterNames: - member1 - member2The above configuration will make Flux The resource object of is distributed to the member cluster member1 and member2 in .
3. Submit the above objects to Karmada-apiserver:
kubectl apply -f ../helm/ --kubeconfig ~/.kube/karmada.configYou will get the following output :
helmrelease.helm.toolkit.fluxcd.io/podinfo createdhelmrepository.source.toolkit.fluxcd.io/podinfo createdpropagationpolicy.policy.karmada.io/helm-release createdpropagationpolicy.policy.karmada.io/helm-repo created4. Switch to the member cluster to verify whether the application is successfully distributed
helm --kubeconfig ~/.kube/members.config --kube-context member1 listYou will get the following output :

be based on Karmada Of PropagationPolicy, You have the flexibility to Helm The application is published to the cluster you expect .
Customize for a specific cluster Helm application
The above example shows how the same Helm Application distribution to Karmada Multiple clusters in . Besides , You can still use it Karmada Of OverridePolicy Customize for a specific cluster Helm application . for example , The above applications include a Pod copy , If you just want to change member1 The applications in the cluster contain Pod replications , You can refer to the following OverridePolicy Strategy .
1. Define a Karmada Of OverridePolicy object .
apiVersion: policy.karmada.io/v1alpha1kind: OverridePolicymetadata: name: example-override namespace: defaultspec: resourceSelectors: - apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease name: podinfo overrideRules: - targetCluster: clusterNames: - member1 overriders: plaintext: - path: "/spec/values" operator: add value: replicaCount: 22. Submit the above objects to Karmada-apiserver:
kubectl apply -f example-override.yaml --kubeconfig ~/.kube/karmada.configYou will get the following output :
overridepolicy.policy.karmada.io/example-override created3. stay Karmada After applying the above strategy in the control plane , You'll find that member1 Members in the cluster Pod The number of instances has been changed to 2, but member2 Those in the cluster remain the same .
kubectl --kubeconfig ~/.kube/members.config --context member1 get poYou will get the following output :
NAME READY STATUS RESTARTS AGEpodinfo-68979685bc-6wz6s 1/1 Running 0 6m28spodinfo-68979685bc-dz9f6 1/1 Running 0 7m42sReference documents :
https://github.com/karmada-io/karmada/blob/master/docs/working-with-flux.md
attach :Karmada Community technology exchange address
add to Karmada Community assistant wechat k8s2222 Enter the community communication group , and Maintainer Zero distance .
Project address :https://github.com/karmada-io/karmada
Slack Address :https://slack.cncf.io/
Click to follow , The first time to learn about Huawei's new cloud technology ~
边栏推荐
- 高并发、高可用、弹性扩展,天翼云护航企业云上业务
- DPDK 20.11编译安装运行程序
- [random talk] January 31, 2021 Oh Huo
- [force button] 35 Search insert location
- Have you ever encountered the error that the main key of this setting is consistent with the database?
- PMD-源代码分析器介绍
- CODING DevOps 助力中化信息打造新一代研效平台,驱动“线上中化”新未来
- 免费、强大、高颜值的笔记软件评测: OneNote、Heptabase、氢图、FlowUs
- 【Hot100】1. Sum of two numbers
- Batchnorm2d principle, function and explanation of batchnorm2d function parameters in pytorch
猜你喜欢

免费、强大、高颜值的笔记软件评测: OneNote、Heptabase、氢图、FlowUs

批量修改指定字符文件名 bat脚本

浅谈 SAP 软件里的价格折扣设计原理

大促场景下,如何做好网关高可用防护
![[tcapulusdb knowledge base] tcapulusdb technical support introduction](/img/ae/9295c8ae642cde632d06966c28d342.png)
[tcapulusdb knowledge base] tcapulusdb technical support introduction

After the first failure, AMEC rushed to the Hong Kong stock exchange for the second time, and the financial principal changed frequently

【Hot100】1. Sum of two numbers

Cardinality sorting - common sorting method (2/8)

PotPlayer播放百度雲盤視頻

【世界海洋日】TcaplusDB号召你一同保护海洋生物多样性
随机推荐
[tcaplusdb knowledge base] view tcapdir directory server
如何将你的 WordPress 网站置于维护模式
如何备份 WordPress 数据库
[random talk] January 31, 2021 Oh Huo
Yesterday, yuancosmos | meta's "yuancosmos" Department lost $2.96 billion in the first quarter, and Liufu jewelry issued Digital Collections
Practice of curve replacing CEPH in Netease cloud music
O & M - unified gateway is very necessary
如何在网站上安装 WordPress
【Hot100】2. Add two numbers
Use open connector to integrate hubspot and SAP systems
强化 WordPress 的 11 种有效方法
You have a chance to collect wool. Click "earn" and you will have a chance to earn a high commission
With high concurrency, high availability and elastic expansion, Tianyi cloud escorts Enterprise Cloud business
Azure Kinect Microsoft camera unity development summary
The future of platform as code is kubernetes extension
NOIP普及组2006-2018初赛 2019 CSP-J1 2020 CSP-J1 完善程序题
MATLB|可视化学习(plot和bar)
General solution of island problems and DFS framework
【TcaplusDB知识库】TcaplusDB限制条件介绍
PotPlayer播放百度云盘视频