kubernetes 集群_ClusterOps:使用GitOps管理Kubernetes集群

kubernetes 集群

Within its 6 years of existence, Kubernetes has been the centerpiece of the Cloud Native landscape, elevating a pluggable system that contributed to the diversification of the entire ecosystem. As a result, multiple areas have been developed in the industry, galvanizing solutions for components such as network, runtime, storage, as well as cluster provisioning. One of the pivotal tools in the management of cross-public cloud infrastructure has been Cluster API, leading a unique and radical stance for Kubernetes distribution. In association with a model such as GitOps, Cluster API assembles a mechanism that leverages the concept of a cluster as a resource.

在存在的6年中,Kubernetes一直是Cloud Native景观的核心,提升了可插拔系统,为整个生态系统的多样化做出了贡献。 结果,该行业已经开发了多个领域,为诸如网络,运行时,存储以及集群配置之类的组件提供了镀锌解决方案。 集群API是跨公共云基础架构管理中的关键工具之一,在Kubernetes发行方面具有独特而激进的立场。 与诸如GitOps之类的模型相关联,Cluster API组合了一种机制,该机制利用了群集作为资源的概念。

This blog post aims to outline how ClusterOps can be modeled with Cluster API manifests and automated using GitOps tools such as ArgoCD and Flux.

这篇博客文章旨在概述如何使用Cluster API清单对ClusterOps进行建模,以及如何使用GitOps工具(例如ArgoCD和Flux)自动进行。

理论上 (The Theoretical)

When it comes to cluster creation, numerous solutions and distributions have been put into place to simplify the Kubernetes bootstrapping process across cloud providers. However, one of the tools that stand out in the open-source landscape is Cluster API, as it facilitates a common interface for platform creation across existing vendors (e.g. GCP, AWS, Azure, Alibaba Cloud, Packet).

在创建集群方面,已经采用了许多解决方案和发行版来简化跨云提供商的Kubernetes引导过程。 但是,在开放源代码领域中脱颖而出的工具之一是Cluster API,因为它为现有供应商(例如GCP,AWS,Azure,阿里云,Packet)之间的平台创建提供了一个通用接口。

Note: For a full introduction of Cluster API, refer to this blog post .

注意:有关Cluster API的完整介绍,请参阅此博客文章

Cluster API reduces the infrastructure definition to a couple of manifests, making the best use of Kubernetes building blocks or CRDs. Since its latest release (v1alpha3), Cluster API introduces 5 custom resources:

Cluster API将基础架构定义简化为两个清单,从而充分利用了Kubernetes构建块或CRD。 自最新版本(v1alpha3)起,Cluster API引入了5种自定义资源:

Image for post
Cluster API CRDs
群集API CRD
  • Cluster — contains the details required by the infrastructure provider to create a Kubernetes cluster (e.g. CIDR blocks for pods, services)

    集群 -包含基础架构提供商创建Kubernetes集群所需的详细信息(例如,用于Pod,服务的CIDR块)

  • ControlPlane — outlines a declarative control plane lifecycle management mechanism with Kubeadm

    ControlPlane —概述了Kubeadm的声明性控制平面生命周期管理机制

  • Machine — encapsulated the configuration of a Kubernetes node (e.g. kubelet version)

    机器 —封装了Kubernetes节点的配置(例如kubelet版本)

  • MachineSet — ensure the desired number of Machine resources are up and running at all times (similar to ReplicaSet)

    MachineSet-确保始终启动并运行所需数量的计算机资源(类似于ReplicaSet)

  • MachineDeployment — reconciles changes to the Machine resources, by having a solid rolling-out strategy between MachineSets configurations (similar to Deployments)

    MachineDeployment —通过在MachineSet配置之间采用可靠的部署策略来协调对Machine资源的更改(类似于Deployment)

Consequently, a new concept is contoured identifying clusters as custom resources (CaaCRD or CaaR). With Cluster API the Kubernetes control and data plane are outlined with CRDs and stored as YAML manifests.

因此,概述了一个新概念,将群集标识为自定义资源(CaaCRD或CaaR)。 使用Cluster API,将使用CRD概述Kubernetes控件和数据平面并将其存储为YAML清单。

The next organic step in platform generation is templating and automation. By default, a set of manifests can be parametrized and packaged with Helm and Kustomize. This enables the tailoring of clusters with pre-defined technical requirements across different regions and cloud providers. Additionally, it is worth mentioning that it is good practice to store the existing manifests, charts, and templates within a git repository. This unlocks the integration of GitOps tools, which solutionizes the automation part of cluster generation.

平台生成的下一个有机步骤是模板和自动化。 默认情况下,可以对一组清单进行参数设置并与Helm和Kustomize打包在一起。 这使跨不同区域和云提供商的具有预定义技术要求的集群得以定制。 另外,值得一提的是,将现有清单,图表和模板存储在git存储库中是一种很好的做法。 这可以解锁GitOps工具的集成,从而解决了集群生成的自动化部分。

Image for post
ClusterOps with GitOps represented by Cluster API and ArgoCD
由Cluster API和ArgoCD表示的具有GitOps的ClusterOps

GitOps is an application delivery mechanism that has git repositories as a representation of the desired application state. That conveys that the delta between the IDE and cluster deployment is one just PR away. GitOps is associated with an automatic reconciliation of data, meaning that it has a pull system, always watching for new commits.

GitOps是一种应用程序交付机制,它具有git存储库来表示所需的应用程序状态。 这表明,IDE和集群部署之间的差异仅在PR之外。 GitOps与数据自动调节相关联,这意味着它具有拉动系统,始终监视新提交。

Popular implementations of GitOps are showcased by Flux (CNCF sandbox project) and ArgoCD (CNCF incubation project).

Flux (CNCF沙盒项目)和ArgoCD (CNCF孵化项目)展示了GitOps的流行实现。

实用的 (The Practical)

Now that all the technical concepts have been highlighted, the next step is to bring all of these components into the same canvas. The following example targets to outline a guide on how to create a Kubernetes cluster in AWS, using ClusterAPI and ArgoCD.

既然已经强调了所有技术概念,那么下一步就是将所有这些组件都放在同一个画布中。 以下示例旨在概述有关如何使用ClusterAPI和ArgoCD在AWS中创建Kubernetes集群的指南。

To set up Cluster API, a management cluster is necessary, which can be created using Kind (a dockerized version of Kubernetes). Once this requirement is fulfilled, the controller managers can be initialized:

要设置集群API,需要一个管理集群,可以使用Kind(Kubernetes的docker化版本)创建管理集群。 一旦满足此要求,就可以初始化控制器管理器:

# create management cluster
kind create cluster --name demo#initialize the management cluster
#
# Note: clusterctl will need to be installed beforehand
#
# To prepare the environment for K8s provisioning on AWS
# follow the guide here: https://cluster-api.sigs.k8s.io/user/quick-start.html#initialization-for-common-providers
#clusterctl init --infrastructure aws

Once all the Cluster API components are up and running, ArgoCD can be installed:

一旦所有Cluster API组件启动并运行,就可以安装ArgoCD:

kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml# access the ArgoCD portal
kubectl port-forward svc/argocd-server -n argocd 8080:80

The next step is to configure an ArgoCD application, referring to the Helm chart containing the manifests for the platform buildout in AWS.

下一步是配置ArgoCD应用程序,请参考Helm图表 ,该图表包含AWS中平台扩展的清单。

# Note: the Helm chart templates have been created using clusterctl
#
# e.g. clusterctl config cluster capi-quickstart --kubernetes-version v1.17.3 --control-plane-machine-count=3 --worker-machine-count=3 > capi-quickstart.yaml
#
# Example Helm chart can be found here: https://github.com/kgamanji/clusterapi-gitops
# CRD for ArgoCD application
- apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: cluster-api
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
helm:
valueFiles:
- values.yaml
path: .
repoURL: https://github.com/kgamanji/clusterapi-gitops
targetRevision: HEAD
syncPolicy:
automated: {}

And that’s it! With automatic reconciliation in ArgoCD the resources for cluster control and data plane will be identified and applied. Here is a live demo of the entire setup:

就是这样! 通过ArgoCD中的自动协调,将可以识别和应用集群控制和数据平面的资源。 这是整个设置的现场演示:

ClusterOps — generate Kubernetes clusters using GitOps
ClusterOps —使用GitOps生成Kubernetes集群

结论 (Conclusion)

Throughout Kubernetes’ evolution, the community engine was fuelled by initiatives to further simplify the cluster provisioning process, independent of the infrastructure context. Fundamentally, this is the raison d’être of Cluster API, facilitating a robust set of capabilities for a consistent experience for platform deployment. In association with the GitOps technique, this represents the genesis of a powerful strategy for the complete automation of Kubernetes distribution across public cloud vendors.

在Kubernetes的整个发展过程中,社区引擎受到各种举措的推动,这些举措进一步简化了群集的配置过程,而与基础架构无关。 从根本上讲,这是Cluster API的存在理由,它提供了一组强大的功能,以提供一致的平台部署体验。 结合GitOps技术,这代表了一种强大的策略的起源,该策略可以使跨公共云供应商的Kubernetes分发完全自动化。

翻译自: https://medium.com/swlh/clusterops-manage-your-kubernetes-clusters-with-gitops-ac5622f11ac6

kubernetes 集群

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值