Helm takes you flying

Time:2021-7-27

Article catalog

catalogue

Not in useHelmBefore, toK8STo deploy applications, we need to deploy them in turndeploymentsvcThe steps are cumbersome. Moreover, with the microservicing of many projects, the deployment and management of complex applications in containers become more complex,HelmThrough packaging, it supports release version management and control, which greatly simplifies theK8SApplication deployment and management

1、 Introduction to Helm

HelmThe essence is to letK8SApplication management of(DeploymentServiceEtc.) configurable and can be generated dynamically. Through dynamic generationK8SResource manifest file(deployment.yamlservice.yaml)。 Then callKubectlAutomatic executionK8SResource deployment.

HelmSimilar to officialYUMThe package manager is the process encapsulation of the deployment environment.HelmThere are two important concepts:chartandrelease

  • chartIs to create an application information collection, including variousKubernetesObject configuration template, parameter definition, dependency, document description, etc.chartIs a self-contained logical unit for application deployment. CanchartImagineaptyumSoftware installation package in
  • releaseyeschartThe running instance of represents a running application. WhenchartInstalled toKubernetesCluster, generate areleasechartIt can be installed to the same cluster multiple times, and each installation is onerelease

HelmContains two components:HelmClient andTillerServer, as shown in the figure below:

HelmClient responsiblechartandreleaseCreation and management of andTillerInteraction.TillerServer running onK8SIn a cluster, it handlesHelmClient requests, andKubernetes API Serverinteractive

2、 Helm deployment

downloadhelmclient:

[[email protected] helm]

[[email protected] helm]

becauseapi serverIt’s onRBACAccess control, so you need to createtillerUsedservice accountAnd assign appropriate roles to it so that it can be accessedapi server, the details can be viewedhelmIn the documentRole-based Access Control。 For simplicity, direct allocationcluster- adminThis cluster is built-inClusterRoleGive it, createrbac-config.yamlFile:

[[email protected] helm]
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system

[[email protected] helm]

[[email protected] ~]

[[email protected] helm]

[[email protected] helm]
tiller-deploy-6d47785b7c-jbdv7   1/1     Running   0          1h

[[email protected] helm]
Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}

3、 Helm custom template

[[email protected] helm]

[[email protected] hello-world]
name: hello-world
version: 1.0.0

[[email protected] templates]

[[email protected] templates]
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-world
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
        - name: hello-world
          image: hub.hc.com/library/myapp:v1
          ports:
            - containerPort: 80
              protocol: TCP

[[email protected] templates]
apiVersion: v1
kind: Service
metadata:
  name: hello-world
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  selector:
    app: hello-world

[[email protected] hello-world]

[[email protected] hello-world]
NAME         	REVISION	UPDATED                 	STATUS  	CHART            	APP VERSION	NAMESPACE
dunking-manta	2       	Tue Aug 18 10:04:27 2020	DEPLOYED	hello-world-1.0.0	           	default

[[email protected] templates]

[[email protected] templates]

[[email protected] templates]
NAME         	REVISION	UPDATED                 	STATUS 	CHART            	APP VERSION	NAMESPACE
dunking-manta	2       	Tue Aug 18 10:04:27 2020	DELETED	hello-world-1.0.0	           	default

[[email protected] templates]
REVISION	UPDATED                 	STATUS    	CHART             DESCRIPTION
1       	Tue Aug 18 09:49:45 2020	SUPERSEDED	hello-world-1.0.0 Install complete
2       	Tue Aug 18 10:04:27 2020	SUPERSEDED	hello-world-1.0.0 Deletion complete

[[email protected] templates]

[[email protected] templates]

Dynamic switching version:

[[email protected] hello-world]
image:
  repository: wangyanglinux/myapp
  tag: 'v2'

[[email protected] ~]
Hello MyApp | Version: v1 | Pod Name

[[email protected] hello-world]

[[email protected] ~]
Hello MyApp | Version: v2 | Pod Name

[[email protected] ~]

[[email protected] ~]
Hello MyApp | Version: v1 | Pod Name

Debug

[[email protected] ~]

4、 Deploying dashboard using Helm

[[email protected] ~]
fbdfe08b001c: Loading layer  122.3MB/122.3MB
Loaded image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1

[[email protected] Dashboard]
[[email protected] Dashboard]
[[email protected] Dashboard]
[[email protected] Dashboard]
NAME  	URL
local 	http://127.0.0.1:8879/charts
stable	https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

[[email protected] Dashboard]
[[email protected] Dashboard]
[[email protected] kubernetes-dashboard]
image:
  repository: k8s.gcr.io/kubernetes-dashboard-amd64
  tag: v1.10.1
ingress:
  enabled: true
  hosts:
    - k8s.frognew.com
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
  tls:
    - secretName: frognew-com-tls-secret
      hosts:
      - k8s.frognew.com
rbac:
  clusterAdminRole: true

[[email protected] kubernetes-dashboard]
> -n kubernetes-dashboard \
> --namespace kube-system  \
> -f k8s-dashboard.yaml

[[email protected] kubernetes-dashboard]
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
kubernetes-dashboard   ClusterIP   10.105.124.175           443/TCP                  3m39s

[[email protected] kubernetes-dashboard]

[[email protected] kubernetes-dashboard]
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
kubernetes-dashboard   NodePort    10.105.124.175           443:30186/TCP            9m5s

5、 Deploying applications using dashboard

Access with Firefox browserhttps://192.168.182.100:30186, select the token and enter the token found belowtoken

querydashboard-token

[[email protected] kubernetes-dashboard]
kubernetes-dashboard-token-5lgp8                 kubernetes.io/service-account-token   3      27m

[[email protected] kubernetes-dashboard]

Enter intodashboardAfter the panel, click Create Application:

The parameters for creating an application are as follows. Click deploy

Container deployment succeeded:

Wechat search: Xiao Liu of the whole stack, get the PDF version of the article

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]