Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Helm2.7.2 in Kubernetes

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to install Helm2.7.2 in Kubernetes, which is very detailed and has certain reference value. Friends who are interested must finish it!

Helm is an open source tool initiated by Deis that helps simplify the deployment and management of Kubernetes applications. This article will introduce the basic concepts and usage of Helm, and demonstrate the use of Helm to deploy applications on Ali Cloud's Kubenetes cluster.

Helm is an open source tool initiated by Deis that helps simplify the deployment and management of Kubernetes applications.

Basic concepts of Helm

Helm can be understood as Kubernetes's package management tool, which makes it easy to discover, share and use applications built for Kubernetes. It contains several basic concepts.

Chart: a Helm package that contains the images, dependencies, and resource definitions needed to run an application. It may also contain service definitions in a Kubernetes cluster, such as formula,APT 's dpkg in Homebrew or Yum's rpm file.

Release: an instance of Chart running on a Kubernetes cluster. A Chart can be installed many times on the same cluster. A new release is created for each installation. For example, a MySQL Chart, if you want to run two databases on the server, you can install the Chart twice. Each installation generates its own Release with its own Release name.

Repository: a repository for publishing and storing Chart.

Helm component

Helm adopts client / server architecture and consists of the following components:

Helm CLI is a Helm client that can be executed locally

Tiller is a server-side component that runs on a Kubernetes cluster and manages the lifecycle of Kubernetes applications

Repository is the Chart repository, and the Helm client accesses the index files and compressed packages of Chart in the warehouse through the HTTP protocol.

15019325767895

Install Helm

The Helm Client installation process is as follows:

Download Helm 2.7.2: https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-linux-amd64.tar.gz

I can't download and upload a copy to Baidu online disk: https://pan.baidu.com/s/1pLPzVS3

Unpack: tar-zxvf helm-v2.7.2-linux-amd64.tgz

Move the helm binaries to the / usr/local/bin directory:

Mv linux-amd64/helm / usr/local/bin/helm

After installing Helm, install Tiller on the Kubernetes cluster by typing the following command:

Helm init-upgrade

In the default configuration, Helm uses the "gcr.io/kubernetes-helm/tiller" image to install and configure Tiller; on the Kubernetes cluster and uses "https://kubernetes-charts.storage.googleapis.com" as the default stable repository address." As domain names such as "gcr.io" and "storage.googleapis.com" may not be accessible in China, Aliyun CCS provides mirror sites for this purpose.

Please execute the following command to configure Helm using Aliyun's image

Helm init-upgrade-I registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.7.2-stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

After the installation completes successfully, you will see the following output:

$helm init-- upgrade$HELM_HOME has been configured at / root/.helm.Tiller (the helm server side component) has been installed into your Kubernetes Cluster.Happy help help basic operation

To view all the Helm charts available in the repository, type:

Helm search

You will see the following output:

[root@cz_fbsdb500_06 templates] # helm searchNAME VERSION DESCRIPTION local/mychart 0.1.0 A Helm chart for Kubernetes stable/acs-engine-autoscaler 2.1.0 Scales worker nodes within agent pools stable/artifactory 6.1.0 Universal Repository Manager supporting all maj...stable/aws-cluster-autoscaler 0.3.1 Scales worker nodes within autoscaling groups. Stable/buildkite 0.2.0 Agent for Buildkite stable/centrifugo 2.0.0 Centrifugo is a real-time messaging server. Stable/chaoskube 0.5.0 Chaoskube periodically kills random pods in you...stable/chronograf 0.3.0 Open-source web application written in Go and R.

To update the charts list for the latest version, type:

Helm repo update

To view a list of Charts installed on the cluster, type:

Helm list

Note: every node of kubernetes must be executed, otherwise you will not be able to connect to port 44134

Yum install socat-y

Since Kubernetes version 1.6, API Server has enabled RBAC authorization. The current Tiller deployment does not define an authorized ServiceAccount, which can cause access to API Server to be denied. We can explicitly add authorization to the Tiller deployment in the following way.

Kubectl create serviceaccount-namespace kube-system tillerkubectl create clusterrolebinding tiller-cluster-rule-clusterrole=cluster-admin-serviceaccount=kube-system:tillerkubectl patch deploy-namespace kube-system tiller-deploy-p'{"spec": {"template": {"spec": {"serviceAccount": "tiller"} 'kubectl create clusterrolebinding add-on-cluster-admin-- clusterrole=cluster-admin-- serviceaccount=kube-system:default

Check that the installation is successful:

[root@cz_fbsdb500_06 tmp] # kubectl-n kube-system get pods | grep tillertiller-deploy-3366552617-sfw20 1 Running 0 14h [root @ cz_fbsdb500_06 tmp] # helm versionClient: & version.Version {SemVer: "v2.7.2", GitCommit: "8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState: "clean"} Server: & version.Version {SemVer: "v2.7.2", GitCommit: "8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState: "clean"}

At this point, the helm has been successfully built, and we have carried out deployment testing.

Create chart

Let's create a chart called mychart and take a look at the file structure of chart.

[root@cz_fbsdb500_06 chart_data] # helm create mychartCreating Mychart [root @ cz_fbsdb500_06 chart_data] # tree mychartmychart ├── charts ├── Chart.yaml ├── templates │ ├── deployment.yaml │ ├── _ helpers.tpl │ ├── ingress.yaml │ ├── NOTES.txt │ └── service.yaml └── values.yaml2 directories, 7 files template

Under the Templates directory is the template for the yaml file, following the Go template syntax. Anyone who has used Hugo's static site generation tool should be familiar with this.

Let's look at the contents of the deployment.yaml file.

ApiVersion: extensions/v1beta1kind: Deploymentmetadata: name: {{template "fullname". }} labels: chart: "{{.Chart.Name}}-{{.Chart.Version | replace" + "_"} "spec: replicas: {{.Values.replicaCount} template: metadata: labels: app: {{template" fullname ". }} spec: containers:-name: {{.Chart.Name}} image: "{{.Values.image.repository}}: {{.Values.image.tag}}" imagePullPolicy: {{.Values.image.pullPolicy}} ports:-containerPort: {{.Values.ser vice.internalPort}} livenessProbe: httpGet: Path: / port: {{.Values.service.servicPort}} readinessProbe: httpGet: path: / port: {{.Values.service.servicPort}} resources: {{toYaml .Values.resources | indent 12}}

This is the yaml configuration file for the Deployment of the application, in which the double curly braces are expanded by Go template, where the Values is defined in the values.yaml file:

# Default values for mychart.# This is a YAML-formatted file.# Declare variables to be passed into your templates.replicaCount: 1image: repository: nginx tag: stable pullPolicy: IfNotPresentservice: name: nginx type: ClusterIP externalPort: 80 internalPort: 80resources: limits: cpu: 100m memory: 128Mi requests: cpu: 100m memory: 128Mi

For example, the container image image defined in Deployment.yaml: "{{.Values.image.repository}}: {{.Values.image.tag}}":

.Values.image.repository is nginx

.Values.image.tag is stable

The above two variable values are the default values that are automatically generated during create chart.

We changed the default image address and tag to our own image.

10.0.0.162/library/nginx:1.9

Check whether the configuration and template are valid [root@cz_fbsdb500_06 chart_data] # helm install-- debug mychart [debug] Created tunnel using local port: '39156' [debug] SERVER: "127.0.0.1 debug mychart 39156" [debug] Original chart version: "" [debug] CHART PATH: / tmp/chart_data/mychartNAME: ardent-otterREVISION: 1RELEASED: Fri Dec 22 10:31:45 2017CHART: mychart-0.1.0USER-SUPPLIED VALUES: { } COMPUTED VALUES:image: pullPolicy: IfNotPresent repository: nginx tag: stableingress: annotations: null enabled:-chart-example.local tls: 1resources: {} service: externalPort: 80 internalPort: 80 name: nginx type: ClusterIPHOOKS:MANIFEST:---# Source: mychart/templates/service.yamlapiVersion: v1kind: Servicemetadata: name: ardent-otter-mychart labels: app: mychart chart: mychart-0.1.0 release: ardent-otter heritage: Tillerspec: type: ClusterIP ports: -port: 80 targetPort: 80 protocol: TCP name: nginx selector: app: ardent-otter---# Source: mychart/templates/deployment.yamlapiVersion: extensions/v1beta1kind: Deploymentmetadata: name: ardent-otter-mychart labels: app: mychart chart: mychart-0.1.0 release: ardent-otter heritage: Tillerspec: replicas: 1 template: metadata: labels: app: mychart release: ardent-otter Spec: containers:-name: mychart image: "10.0.0.162/library/nginx:1.9" imagePullPolicy: IfNotPresent ports:-containerPort: 80 livenessProbe: httpGet: path: / port: 80 readinessProbe: httpGet: Path: / port: 80 resources: {} deploy to kubernetes

From the mychart directory, execute the following command to deploy nginx to the kubernetes cluster.

[root@cz_fbsdb500_06 mychart] # helm install.

Now that nginx has been deployed to the kubernetes cluster, the commands in the local execution prompt access the nginx instance on the local host.

[root@cz_fbsdb500_06 mychart] # helm listNAME REVISION UPDATED STATUS CHART NAMESPACE wishful-alpaca 1 Fri Dec 22 09:28:07 2017 DEPLOYED mychart-0.1.0 default wordpress-test 1 Thu Dec 21 20:05:03 2017 DEPLOYED wordpress-0.6.13 default package sharing

We can modify the helm chart configuration information in Chart.yaml and then package chart into a compressed file using the following command.

Helm package.

Package out the mychart-0.1.0.tgz file.

Installation source

Our previous installation of chart can be provided through HTTP server.

[root@cz_fbsdb500_06 mychart] # helm serve-address 0.0.0.0:8879Regenerating index. This may take a moment.Now serving you on 0.0.0.0:8879

The above is all the contents of the article "how to install Helm2.7.2 in Kubernetes". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report