当前位置:网站首页>Explain the kubernetes package management tool Helm

Explain the kubernetes package management tool Helm

2022-06-11 14:49:00 Deep learning and python

author | Ray Elenteny

translator | Winter rain

planning | Chu Xingjuan

When it comes to Helm when , We often make such an analogy :Helm To Kubernetes, It's like apt Based on debian The system of ,yum or rpm To be based on Red Hat It's the same system . In addition to package management ,Helm There is also a lot of built-in configuration management .

Helm Is aimed at Kubernetes A package management tool , At first, a family named Deis Developed by , It was later acquired by Microsoft . Microsoft fully supports Helm, Speed up its development , Now it is the cloud local computing foundation (CNCF) Part of .

picture source :“Helm history”——2018 year 5 month , stay CNCF TOC On Helm Project presentation slides

As CNCF Part of ,Helm It has been actively developed and supported by many organizations , And thus developed a large and active community . Here are Helm By 2021 year 10 Sample project contribution statistics for month :

Table source : China National Petroleum Fund Development Statistics project 《 Overall statistical table of the project 》

1 Why? Kubernetes A package manager is required ?

Most technologies are based on “Hello World” To introduce key concepts ,Kubernetes No exception . In addition to the simplest components , Deploy any component to Kubernetes Clusters need to coordinate across multiple components .

such as , management Kubernetes The process of application deployment outside the cluster is not complicated , However, due to the existence of dependencies and dependent versions 、 Configure workpiece 、 Pre - and post deployment steps 、 Validation etc. , This becomes a tedious task . just as apt and yum Is for Linux Managing the process is the same ,Helm by Kubernetes Deal with this process .

On the whole ,Helm Features have the following features :

  • Kubernetes Manage the deployment lifecycle of components and Applications
  • Template based definitions , Support for cross deployment environments ( for example , Development 、 Quality assurance 、 production ) Portability of
  • The hook mechanism can inject use case specific code at different stages of the deployment lifecycle
  • Deploy the test framework

2 Helm Structure

Use Helm Just install an executable .helm The order provides 20 Multiple parameters , Used to build 、 Deploy 、 Delete 、 Roll back, etc , Deploy application to Kubernetes In the cluster .

Helm Deployment artifacts are Helm Chart.Helm Chart Used by to deploy components or applications to Kubernetes The resource composition of the cluster .Chart The most common resource in is YAML file , It follows the standard Kubernetes Resource description . If you can use it skillfully kubectl create perhaps kubectl apply Command deployment to Kubernetes colony , Then you will feel Helm Chart Medium YAML The file looks familiar .Helm Chart Usually contains additional resources , Such as README file 、 Default parameter files and additional files required for deployment ( Such as certificates ).

Development Helm Chart You need to organize your files using a predefined directory structure . It can be used Helm command helm create Create a Helm chart, It is a predefined directory structure , Contains some sample files . Generated chart There are several YAML file . One Kubernetes Deployment usually requires multiple... To be deployed Kubernetes Resource description , in many instances , These deployments must have a priority order . When deploying manually , You must know the order . and Helm You don't have to , because Helm know Kubernetes Priority of resource description .

Helm A key feature of the deployment process is Chart Hooks. stay Helm Chart In the deployment lifecycle of ,Chart hook Is a mechanism for performing additional tasks .Helm The following points are supported to introduce the graph Chart Hook:

Table source :“ Useful hook ——Chart Hook”,Helm Chart Can depend on other Helm Chart

for example , An application may contain dependencies on a set of microservices , One of the micro services is provided by his own Helm Chart Definition . When the application is deployed ,Helm Will manage these dependencies . To be consistent with the microservice pattern , Each component can be updated independently of other components , So it is still the definition of a collection of cohesive applications .

3 planning Helm Deploy

Helm It can play a role in all aspects of application development and deployment , This requires close cooperation between the engineering and operations teams , To design solutions and answer deployment questions . Through team coordination , Deployment decisions can be made iteratively , To use a single deployment package to support the goals of each environment to accommodate the differences in each deployment environment .

In addition to the hook concept described above ,Helm It also provides a robust template mechanism , Enable teams to address the challenges of a single deployment package . Usually ,Helm Chart Medium YAML The document doesn't look like handwritten YAML Kubernetes Resource description .

contrary ,Helm Chart Medium YAML The file is used Helm Template language development :

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "helm-demo.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    {{- include "helm-demo.labels" . | nindent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ .path }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: {{ $svcPort }}
          {{- end }}
    {{- end }}
  {{- end }}

By the helm create Generated templated ingress Describe examples , Several variables are provided , Used to define and configure ingress resources , Include whether you should create ingress resources . Through templates ,Helm Provide for the right to Kubernetes Extensive control over how resources are deployed . A well planned template pattern can generate a single deployment package , send Helm Chart Be able to successfully deploy , Range from a single node on the developer workstation Kubernetes Cluster to production Kubernetes colony .

4 Helm Chart and CI/CD

Continuous integration as an organization / Continuous delivery of part of the pipeline ,Helm Play the role of facilitator and component . As a promoter , It becomes a cross - environment ( engineering 、 Quality assurance 、 deliver 、 authentication 、 Production etc. ) Mechanisms for deploying applications or components to enhance pipelines . stay CI/CD In the pipeline , Automated Helm Chart Deployment is very simple .

Helm Chart As an application component , It is also iteratively developed and deployed like application code . It means CI/CD The pipeline is verifying Helm Chart Itself is indispensable . in fact ,Helm Chart Should be considered part of the application code , Rather than being a peripheral part of the application development process —— It should even be Helm Chart As part of the application source code . Similar to the way an application builds a versioned container image and pushes it to the mirror registry ,helm package take chart Bind to versioned archive . The generated archive is submitted to Helm Chart The repository , It can be accessed from this repository for deployment .

The above figure highlights the phases in the application software development lifecycle . No matter which mode you use to manage Helm Chart Source code , It's in the app CI/CD The pipeline is as indispensable as the application itself .

5 Conclusion

Helm Has always been a Kubernetes Part of the ecosystem hype curve , With Kubernetes The hype curve began to flatten ,Helm And it's mature .Helm Is the method revolutionary ? Not entirely. .Helm With years of accumulated knowledge of software packages and configuration management tools , Now bring these experiences to Kubernetes. meanwhile ,Helm adopt Helm Chart The idea of defining deployment packages is important to the organization CI/CD The efficiency of the pipeline has a direct impact , The most significant are configuration patterns and deployment flexibility . Well designed Helm Chart Is an important part of effective delivery .

Link to the original text :

https://dzone.com/articles/kubernetes-package-management-with-helm?

原网站

版权声明
本文为[Deep learning and python]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111418150657.html