Basic use of package manager helm in container choreography system k8s (2)

Linux-1874 2021-01-21 18:47:13
basic use package manager helm


We introduced helm Related terms and use of helm Install and uninstall apps , Please refer to :https://www.cnblogs.com/qiuhom-1874/p/14305902.html; Today, let's talk about customization chart And packing chart,helm Other commands use and private helm Warehouse building related topics ;

Next blog , We know how to use helm stay k8s Install apps on , Uninstall app , And warehouse add delete update and so on ; about helm chart Come on , It's just a packaged file , Take the configuration list we need to use , Publish it as a template , When users use , According to values.yaml The file defines the value of the corresponding attribute from the line , You can also use it --set Option to specify the values of the properties of the individual configuration manifest ; So we use helm Command to install the application from the repository , Where is the corresponding package file ? By default, we use helm Command installation application , It will put the corresponding application chart The packaged files are stored in the home directory of the current user .cache/helm/repository/ Under the table of contents , With .tgz A package at the end ; as follows

Tips : As long as we have used the above catalogue helm install Command installation application , Corresponding chart All packaged files will be downloaded here ;

View the corresponding packing directory structure

[root@master01 ~]# ll .cache/helm/repository/
total 6520
-rw-r--r-- 1 root root 865 Jan 21 02:23 bitnami-charts.txt
-rw-r--r-- 1 root root 6555926 Jan 21 02:23 bitnami-index.yaml
-rw-r--r-- 1 root root 4381 Jan 20 23:19 redis
-rw-r--r-- 1 root root 31909 Jan 20 22:54 redis-10.5.7.tgz
-rw-r--r-- 1 root root 72791 Jan 21 02:26 redis-12.6.2.tgz
[root@master01 ~]# cp .cache/helm/repository/redis-12.6.2.tgz .
[root@master01 ~]# ls
redis-12.6.2.tgz
[root@master01 ~]# tar xf redis-12.6.2.tgz
[root@master01 ~]# ls
redis redis-12.6.2.tgz
[root@master01 ~]# tree redis
redis
├── Chart.lock
├── charts
│   └── common
│   ├── Chart.yaml
│   ├── README.md
│   ├── templates
│   │   ├── _affinities.tpl
│   │   ├── _capabilities.tpl
│   │   ├── _errors.tpl
│   │   ├── _images.tpl
│   │   ├── _ingress.tpl
│   │   ├── _labels.tpl
│   │   ├── _names.tpl
│   │   ├── _secrets.tpl
│   │   ├── _storage.tpl
│   │   ├── _tplvalues.tpl
│   │   ├── _utils.tpl
│   │   ├── validations
│   │   │   ├── _cassandra.tpl
│   │   │   ├── _mariadb.tpl
│   │   │   ├── _mongodb.tpl
│   │   │   ├── _postgresql.tpl
│   │   │   ├── _redis.tpl
│   │   │   └── _validations.tpl
│   │   └── _warnings.tpl
│   └── values.yaml
├── Chart.yaml
├── ci
│   ├── default-values.yaml
│   ├── extra-flags-values.yaml
│   └── production-sentinel-values.yaml
├── img
│   ├── redis-cluster-topology.png
│   └── redis-topology.png
├── README.md
├── templates
│   ├── configmap-scripts.yaml
│   ├── configmap.yaml
│   ├── headless-svc.yaml
│   ├── health-configmap.yaml
│   ├── _helpers.tpl
│   ├── metrics-prometheus.yaml
│   ├── metrics-svc.yaml
│   ├── networkpolicy.yaml
│   ├── NOTES.txt
│   ├── pdb.yaml
│   ├── prometheusrule.yaml
│   ├── psp.yaml
│   ├── redis-master-statefulset.yaml
│   ├── redis-master-svc.yaml
│   ├── redis-node-statefulset.yaml
│   ├── redis-rolebinding.yaml
│   ├── redis-role.yaml
│   ├── redis-serviceaccount.yaml
│   ├── redis-slave-statefulset.yaml
│   ├── redis-slave-svc.yaml
│   ├── redis-with-sentinel-svc.yaml
│   └── secret.yaml
├── values.schema.json
└── values.yaml
7 directories, 53 files
[root@master01 ~]#

Tips :charts The directory is mainly used to store the corresponding chart Others on which to rely chart file ;chart.yaml The file is mainly used to describe the corresponding chart Metadata information , such as chart Version of , name , Introduction information and so on ;ci Directory is used to store all kinds of environment values.yaml file , By default... Is not specified values file , The corresponding effect is values.yaml file ;img The directory is mainly used to store the corresponding chart The corresponding icon in the warehouse ;README.md The file is used to describe the chart How to use , Deployment manuals and so on ;template The directory is mainly used to store the chart Deploy as release All required resource manifest files , The resource list file in this directory is not the resource list file we used earlier , The format in it is through go A list of resources written in template language , When use , We have to combine values.yaml The value defined in , It can only be used normally after rendering by template engine ;values.yaml The file is mainly used to describe the default values of the corresponding attributes in the corresponding resource template list , In general, we do not specify values file ,chart The applied values all come from values.yaml file , Of course, users can use --set To specify the value of the corresponding property , You can also edit it manually values file , use --values perhaps -f Option to specify the corresponding value file ;

Create custom chart Order help

[root@master01 ~]# helm create -h
This command creates a chart directory along with the common files and
directories used in a chart.
For example, 'helm create foo' will create a directory structure that looks
something like this:
foo/
├── .helmignore # Contains patterns to ignore when packaging Helm charts.
├── Chart.yaml # Information about your chart
├── values.yaml # The default values for your templates
├── charts/ # Charts that this chart depends on
└── templates/ # The template files
└── tests/ # The test files
'helm create' takes a path for an argument. If directories in the given path
do not exist, Helm will attempt to create them as it goes. If the given
destination exists and there are files in that directory, conflicting files
will be overwritten, but other files will be left alone.
Usage:
helm create NAME [flags]
Flags:
-h, --help help for create
-p, --starter string the name or absolute path to Helm starter scaffold
Global Flags:
--debug enable verbose output
--kube-apiserver string the address and the port for the Kubernetes API server
--kube-as-group stringArray group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--kube-as-user string username to impersonate for the operation
--kube-ca-file string the certificate authority file for the Kubernetes API server connection
--kube-context string name of the kubeconfig context to use
--kube-token string bearer token used for authentication
--kubeconfig string path to the kubeconfig file
-n, --namespace string namespace scope for this request
--registry-config string path to the registry config file (default "/root/.config/helm/registry.json")
--repository-cache string path to the file containing cached repository indexes (default "/root/.cache/helm/repository")
--repository-config string path to the file containing repository names and URLs (default "/root/.config/helm/repositories.yaml")
[root@master01 ~]#

Example : Create a myapp Of chart

[root@master01 ~]# helm create myapp
Creating myapp
[root@master01 ~]# ls
myapp redis redis-12.6.2.tgz
[root@master01 ~]# tree myapp/
myapp/
├── charts
├── Chart.yaml
├── templates
│   ├── deployment.yaml
│   ├── _helpers.tpl
│   ├── hpa.yaml
│   ├── ingress.yaml
│   ├── NOTES.txt
│   ├── serviceaccount.yaml
│   ├── service.yaml
│   └── tests
│   └── test-connection.yaml
└── values.yaml
3 directories, 10 files
[root@master01 ~]#

see chart.yaml The contents of the document

[root@master01 ~]# cat myapp/Chart.yaml
apiVersion: v2
name: myapp
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
[root@master01 ~]#

Tips :Chart.yaml The file is mainly used to describe the corresponding chart Related attribute information of , among apiVersion Fields are used to describe the corresponding chart The use of api edition , The default is v2 edition ;name Fields are used to describe the corresponding chart The name of ;description Fields are used to describe the corresponding chart A brief introduction to ;type Field user description corresponds to chart Is it an application or a library file , Application type chart, It can run as a release, But library type chart Cannot run as release, It can only be used as a dependency application Type of chart Used by the ;version Fields are used to describe the corresponding chart edition ;appVersion Fields are used to describe the corresponding chart Version information of internal program ;

View the template file

[root@master01 ~]# ll myapp/templates/
total 28
-rw-r--r-- 1 root root 1826 Jan 21 14:44 deployment.yaml
-rw-r--r-- 1 root root 1762 Jan 21 14:44 _helpers.tpl
-rw-r--r-- 1 root root 910 Jan 21 14:44 hpa.yaml
-rw-r--r-- 1 root root 1052 Jan 21 14:44 ingress.yaml
-rw-r--r-- 1 root root 1739 Jan 21 14:44 NOTES.txt
-rw-r--r-- 1 root root 316 Jan 21 14:44 serviceaccount.yaml
-rw-r--r-- 1 root root 355 Jan 21 14:44 service.yaml
drwxr-xr-x 2 root root 34 Jan 21 14:44 tests
[root@master01 ~]# cat myapp/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "myapp.fullname" . }}
labels:
{{- include "myapp.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "myapp.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "myapp.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "myapp.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
[root@master01 ~]#

Tips : The deployment manifest template file , It mainly uses go It's written in template language , among {{ include "myapp.fullname" . }} It means taking myapp The full name of ;{{ .Values.image.repository }} This code means to read the values In the document image.repository Value of field ;{{ .Values.image.tag | default .Chart.AppVersion }} For values In file image.tag Or read default.chart In the document AppVersion Value of field ; In short go Template is application correspondence go Template syntax to define the values of related properties ; Usually from values.yaml Load the value of the corresponding field in the file as the value of the related attribute of the template file ;

values The value reference in the file

[root@master01 ~]# cat myapp/values.yaml
# Default values for myapp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
[root@master01 ~]#

Tips : For example, we're going to quote values.yaml In the document image Field tag Value of field , We can write... In the template file {{ .Values.image.tag }}; If you use... On the command line --set We can write it as image.tag; You can edit the corresponding values directly values.yaml The value of the corresponding field in the file , It can also be used directly --set Just specify the corresponding value of the corresponding field ; By default, it is used on the command line --set The value given by the option , Will be replaced directly , There is no given value , The default is to use values.yaml The default value given in the file ;

Example : modify values.yaml Value in file

[root@master01 ~]# cat myapp/values.yaml
# Default values for myapp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: ikubernetes/myapp
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v1"
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
[root@master01 ~]#

Tips : Above values.yaml file , We changed it image.repository The value of is ikubernetes/myapp and image.tag by v1; This means corresponding to chart The image repository of the application is ikubernetes/myapp Warehouse ; Version is v1; And then modified resources Field ; Add the corresponding resource limit configuration ;

Check the correspondence values Is the syntax of the file correct ?

[root@master01 ~]# helm lint ./myapp/
==> Linting ./myapp/
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: unable to parse YAML: error converting YAML to JSON: yaml: line 60: did not find expected key
[ERROR] templates/: cannot load values.yaml: error converting YAML to JSON: yaml: line 60: did not find expected key
[ERROR] : unable to load chart
cannot load values.yaml: error converting YAML to JSON: yaml: line 60: did not find expected key
Error: 1 chart(s) linted, 1 chart(s) failed
[root@master01 ~]#

Tips : Check values File configuration Syntax , have access to helm lint The command specifies the corresponding chart The directory of ; The above examination results tell us that values.yaml Of 60 Configuration problem ;

Tips : Above values In file ,resource The corresponding configuration is given after the field , Corresponding {} It can't be used anymore , Use {} Express the resource Leave the field blank ; So we just need to delete the corresponding braces ;

Delete resource Braces for fields , Check again values The grammar of

[root@master01 ~]# helm lint ./myapp/
==> Linting ./myapp/
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
[root@master01 ~]#

Tips : As long as there is no wrong class information in the above checking process , Express values The grammar is correct ; Now we can use the chart To deploy as a release 了 ;

modify Chart.yaml Information in , take myapp chart Deploy as a release

[root@master01 ~]# cat ./myapp/Chart.yaml
apiVersion: v2
name: myapp
description: web server
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1"
[root@master01 ~]#

application myapp chart

[root@master01 ~]# helm install myapp-v1 ./myapp/
NAME: myapp-v1
LAST DEPLOYED: Thu Jan 21 15:15:52 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=myapp,app.kubernetes.io/instance=myapp-v1" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 ~]#

Tips : Deploy custom chart Use helm install Specify the corresponding release name , as well as chart It's in the directory ;

see release

[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 1 2021-01-21 15:15:52.57286036 +0800 CST deployed myapp-0.1.0 v1
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]#

View correspondence pod Is it working ? Corresponding service Whether it is created normally ?

Tips : You can see the corresponding pod and svc All created normally ;

upgrade release

change Chart.yaml Contents of the file

[root@master01 ~]# cat myapp/Chart.yaml
apiVersion: v2
name: myapp
description: web server
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2"
[root@master01 ~]#

change values.yaml The version of the corresponding image in the file

[root@master01 ~]# cat myapp/values.yaml
# Default values for myapp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: ikubernetes/myapp
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v2"
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
[root@master01 ~]#

Use upgrade Command upgrade release

[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 1 2021-01-21 15:15:52.57286036 +0800 CST deployed myapp-0.1.0 v1
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# helm upgrade --set service.type="NodePort" myapp-v1 ./myapp/
Release "myapp-v1" has been upgraded. Happy Helming!
NAME: myapp-v1
LAST DEPLOYED: Thu Jan 21 15:24:22 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
NOTES:
1. Get the application URL by running these commands:
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services myapp-v1)
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 2 2021-01-21 15:24:22.882236621 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-v1-7c9d7c999f-8k6rm 0/1 Terminating 0 8m47s
myapp-v1-866b6d4cc6-nx87c 1/1 Running 0 16s
redis-demo-master-0 1/1 Running 1 13h
redis-demo-slave-0 1/1 Running 2 13h
redis-demo-slave-1 1/1 Running 7 13h
redis-master-0 1/1 Running 1 12h
redis-slave-0 1/1 Running 1 12h
redis-slave-1 1/1 Running 1 12h
[root@master01 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15h
myapp-v1 NodePort 10.110.153.241 <none> 80:32434/TCP 8m53s
redis-demo-headless ClusterIP None <none> 6379/TCP 13h
redis-demo-master ClusterIP 10.109.45.70 <none> 6379/TCP 13h
redis-demo-slave ClusterIP 10.111.222.218 <none> 6379/TCP 13h
redis-headless ClusterIP None <none> 6379/TCP 12h
redis-master ClusterIP 10.108.35.165 <none> 6379/TCP 12h
redis-slave ClusterIP 10.99.96.166 <none> 6379/TCP 12h
[root@master01 ~]#

Tips : You can see the corresponding myapp-v1pod and svc It's all changed ;

verification : View correspondence pod Version information for

[root@master01 ~]# kubectl describe pods myapp-v1-866b6d4cc6-nx87c |grep Image
Image: ikubernetes/myapp:v2
Image ID: docker-pullable://ikubernetes/myapp@sha256:85a2b81a62f09a414ea33b74fb8aa686ed9b168294b26b4c819df0be0712d358
[root@master01 ~]#

Of course, if the update operation changes less information , We can also use it directly in the command --set Option to specify the value of the corresponding attribute to update , as follows

[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 2 2021-01-21 15:24:22.882236621 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# helm upgrade --set image.tag="v3" myapp-v1 ./myapp/
Release "myapp-v1" has been upgraded. Happy Helming!
NAME: myapp-v1
LAST DEPLOYED: Thu Jan 21 15:29:46 2021
NAMESPACE: default
STATUS: deployed
REVISION: 3
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=myapp,app.kubernetes.io/instance=myapp-v1" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 3 2021-01-21 15:29:46.491467084 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]#

Tips : Manually use the command line options --set to update , We need to put the corresponding Chart The information in will be modified in advance , Otherwise, like above, we did not modify the information in the corresponding file , It retains the original information ;

verification : View correspondence pod Whether the version has been updated ?

[root@master01 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-v1-675d685ddf-nn2zd 1/1 Running 0 106s
redis-demo-master-0 1/1 Running 1 13h
redis-demo-slave-0 1/1 Running 2 13h
redis-demo-slave-1 1/1 Running 7 13h
redis-master-0 1/1 Running 1 13h
redis-slave-0 1/1 Running 1 13h
redis-slave-1 1/1 Running 1 13h
[root@master01 ~]# kubectl describe pods/myapp-v1-675d685ddf-nn2zd |grep Image
Image: ikubernetes/myapp:v3
Image ID: docker-pullable://ikubernetes/myapp@sha256:b8d74db2515d3c1391c78c5768272b9344428035ef6d72158fd9f6c4239b2c69
[root@master01 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15h
myapp-v1 ClusterIP 10.110.153.241 <none> 80/TCP 16m
redis-demo-headless ClusterIP None <none> 6379/TCP 13h
redis-demo-master ClusterIP 10.109.45.70 <none> 6379/TCP 13h
redis-demo-slave ClusterIP 10.111.222.218 <none> 6379/TCP 13h
redis-headless ClusterIP None <none> 6379/TCP 13h
redis-master ClusterIP 10.108.35.165 <none> 6379/TCP 13h
redis-slave ClusterIP 10.99.96.166 <none> 6379/TCP 13h
[root@master01 ~]#

Tips : The above command line option specifies that the version update of the corresponding image is successful ; Corresponding svc Its type is not specified , Also the default type used ;

Roll back release

[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 3 2021-01-21 15:29:46.491467084 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# helm rollback myapp-v1 2
Rollback was a success! Happy Helming!
[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 4 2021-01-21 15:33:58.389015959 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# helm rollback myapp-v1 2
Rollback was a success! Happy Helming!
[root@master01 ~]# helm rollback myapp-v1 1
Rollback was a success! Happy Helming!
[root@master01 ~]# helm history myapp-v1
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu Jan 21 15:15:52 2021 superseded myapp-0.1.0 v1 Install complete
2 Thu Jan 21 15:24:22 2021 superseded myapp-0.2.0 v2 Upgrade complete
3 Thu Jan 21 15:29:46 2021 superseded myapp-0.2.0 v2 Upgrade complete
4 Thu Jan 21 15:33:58 2021 superseded myapp-0.2.0 v2 Rollback to 2
5 Thu Jan 21 15:36:08 2021 superseded myapp-0.2.0 v2 Rollback to 2
6 Thu Jan 21 15:36:26 2021 deployed myapp-0.1.0 v1 Rollback to 1
[root@master01 ~]# helm rollback myapp-v1 1
Rollback was a success! Happy Helming!
[root@master01 ~]# helm history myapp-v1
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu Jan 21 15:15:52 2021 superseded myapp-0.1.0 v1 Install complete
2 Thu Jan 21 15:24:22 2021 superseded myapp-0.2.0 v2 Upgrade complete
3 Thu Jan 21 15:29:46 2021 superseded myapp-0.2.0 v2 Upgrade complete
4 Thu Jan 21 15:33:58 2021 superseded myapp-0.2.0 v2 Rollback to 2
5 Thu Jan 21 15:36:08 2021 superseded myapp-0.2.0 v2 Rollback to 2
6 Thu Jan 21 15:36:26 2021 superseded myapp-0.1.0 v1 Rollback to 1
7 Thu Jan 21 15:38:21 2021 deployed myapp-0.1.0 v1 Rollback to 1
[root@master01 ~]# helm rollback myapp-v1 3
Rollback was a success! Happy Helming!
[root@master01 ~]# helm history myapp-v1
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu Jan 21 15:15:52 2021 superseded myapp-0.1.0 v1 Install complete
2 Thu Jan 21 15:24:22 2021 superseded myapp-0.2.0 v2 Upgrade complete
3 Thu Jan 21 15:29:46 2021 superseded myapp-0.2.0 v2 Upgrade complete
4 Thu Jan 21 15:33:58 2021 superseded myapp-0.2.0 v2 Rollback to 2
5 Thu Jan 21 15:36:08 2021 superseded myapp-0.2.0 v2 Rollback to 2
6 Thu Jan 21 15:36:26 2021 superseded myapp-0.1.0 v1 Rollback to 1
7 Thu Jan 21 15:38:21 2021 superseded myapp-0.1.0 v1 Rollback to 1
8 Thu Jan 21 15:40:38 2021 deployed myapp-0.2.0 v2 Rollback to 3
[root@master01 ~]#

Tips : For the rollback operation, we need to specify the location of the corresponding rollback , This position is represented by a number , This number is the serial number of the corresponding historical version ; For example, roll back to serial number 2 Version of , Just use helm rollback myapp-v1 2; If you roll back to a version, the serial number is 3 Version of , Change the corresponding version serial number to 3 that will do ; Follow this logic to roll back ; View correspondence release Version history of , have access to helm history RELEASE_NAME Check it out. ; In the end, we'll scroll to the serial number 3 Version of , The version of the corresponding application is v3;

verification : View correspondence pod Is the program version v3?

[root@master01 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-v1-675d685ddf-7c8zd 1/1 Running 0 11m
redis-demo-master-0 1/1 Running 1 13h
redis-demo-slave-0 1/1 Running 2 13h
redis-demo-slave-1 1/1 Running 7 13h
redis-master-0 1/1 Running 1 13h
redis-slave-0 1/1 Running 1 13h
redis-slave-1 1/1 Running 1 13h
[root@master01 ~]# kubectl describe pods/myapp-v1-675d685ddf-7c8zd |grep Image
Image: ikubernetes/myapp:v3
Image ID: docker-pullable://ikubernetes/myapp@sha256:b8d74db2515d3c1391c78c5768272b9344428035ef6d72158fd9f6c4239b2c69
[root@master01 ~]#

Tips : You can see the corresponding pod The mirror version used is v3;

see myapp-v1 The state of

[root@master01 ~]# helm status myapp-v1
NAME: myapp-v1
LAST DEPLOYED: Thu Jan 21 15:40:38 2021
NAMESPACE: default
STATUS: deployed
REVISION: 8
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=myapp,app.kubernetes.io/instance=myapp-v1" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 ~]#

Tips :helm status The command is equivalent to the corresponding chart Medium template Under the table of contents NOTES.txt After rendering the file , Output to user ; This content mainly tells users the corresponding chart How to connect and use , Corresponding chart And so on ;

Command view readme The contents of the document ,chart.yaml Document content and values The contents of the document

[root@master01 ~]# helm show readme
[root@master01 ~]# helm show readme myapp/
[root@master01 ~]# helm show chart myapp/
apiVersion: v2
appVersion: v2
description: web server
name: myapp
type: application
version: 0.2.0
[root@master01 ~]# helm show values myapp/
# Default values for myapp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: ikubernetes/myapp
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v2"
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
[root@master01 ~]#

Tips : Corresponding chart There is no README.md file , Corresponding use helm show readme The command can't get the corresponding content ;

see template The contents of the template file in the directory

[root@master01 ~]# helm template myapp/
---
# Source: myapp/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: RELEASE-NAME-myapp
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
---
# Source: myapp/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: RELEASE-NAME-myapp
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
---
# Source: myapp/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: RELEASE-NAME-myapp
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
template:
metadata:
labels:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
spec:
serviceAccountName: RELEASE-NAME-myapp
securityContext:
{}
containers:
- name: myapp
securityContext:
{}
image: "ikubernetes/myapp:v2"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
---
# Source: myapp/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "RELEASE-NAME-myapp-test-connection"
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['RELEASE-NAME-myapp:80']
restartPolicy: Never
[root@master01 ~]#

Tips : The above list is combined with the template engine values The result of rendering with the values defined in the file ;

Download from the warehouse chart File to local

Tips : If you want to download the corresponding chart file , We can use pull command , The command will go to the corresponding warehouse and send the corresponding chart Download the package file to local ; Your server can't connect to the warehouse properly , Please use the proxy ; Above ;

Get the installed release Extended information for

[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-v1 default 8 2021-01-21 15:40:38.060295891 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# helm get values myapp-v1
USER-SUPPLIED VALUES:
image:
tag: v3
[root@master01 ~]# helm get notes myapp-v1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=myapp,app.kubernetes.io/instance=myapp-v1" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 ~]# helm get hooks myapp-v1
---
# Source: myapp/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "myapp-v1-test-connection"
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['myapp-v1:80']
restartPolicy: Never
[root@master01 ~]# helm get manifest myapp-v1
---
# Source: myapp/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: myapp-v1
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
---
# Source: myapp/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: myapp-v1
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
---
# Source: myapp/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-v1
labels:
helm.sh/chart: myapp-0.2.0
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
app.kubernetes.io/version: "v2"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
template:
metadata:
labels:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp-v1
spec:
serviceAccountName: myapp-v1
securityContext:
{}
containers:
- name: myapp
securityContext:
{}
image: "ikubernetes/myapp:v3"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
[root@master01 ~]#

Tips : If you want to get all of the above at once , have access to helm get all Command to get ;

Package custom chart

[root@master01 ~]# ls
logstash-3.0.2.tgz myapp redis redis-12.6.2.tgz
[root@master01 ~]# helm package ./myapp/
Successfully packaged chart and saved it to: /root/myapp-0.2.0.tgz
[root@master01 ~]# ls
logstash-3.0.2.tgz myapp myapp-0.2.0.tgz redis redis-12.6.2.tgz
[root@master01 ~]#

Tips : Pack up chart After file , We can put the corresponding files in the corresponding warehouse and share them with others ;

helm Private warehouse construction

helm A private warehouse is essentially a http File server , We just need to put the corresponding chart Package files , And the metadata information of the corresponding warehouse can be put into the corresponding directory

Find a server to install nginx As helm Private warehouse

[root@docker_registry ~]# yum install -y nginx

Generate Warehouse Metadata Information

[root@master01 ~]# mkdir repo-test
[root@master01 ~]# mv *.tgz repo-test/
[root@master01 ~]# ls
myapp redis repo-test
[root@master01 ~]# cd repo-test/
[root@master01 repo-test]# helm repo index . --url http://192.168.0.99/repo-test
[root@master01 repo-test]# ls
index.yaml logstash-3.0.2.tgz myapp-0.2.0.tgz redis-12.6.2.tgz
[root@master01 repo-test]# cat index.yaml
apiVersion: v1
entries:
logstash:
- annotations:
category: LogManagement
apiVersion: v2
appVersion: 7.10.2
created: "2021-01-21T16:43:51.585642435+08:00"
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 1.x.x
description: Logstash is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to your favorite "stash".
digest: b60ccc7d48acfbfafd6a226b32316fff173f7e17112cee8367c5680012bc37a1
home: https://github.com/bitnami/charts/tree/master/bitnami/logstash
icon: https://bitnami.com/assets/stacks/logstash/img/logstash-stack-220x234.png
keywords:
- logstash
- logging
- elk
maintainers:
- email: containers@bitnami.com
name: Bitnami
name: logstash
sources:
- https://github.com/bitnami/bitnami-docker-logstash
- https://www.elastic.co/products/logstash
urls:
- http://192.168.0.99/repo-test/logstash-3.0.2.tgz
version: 3.0.2
myapp:
- apiVersion: v2
appVersion: v2
created: "2021-01-21T16:43:51.586100842+08:00"
description: web server
digest: 55710394a8f2a8b0770c7212aaa92477adefebfbe72640d8c84e42c7999dd1d9
name: myapp
type: application
urls:
- http://192.168.0.99/repo-test/myapp-0.2.0.tgz
version: 0.2.0
redis:
- annotations:
category: Database
apiVersion: v2
appVersion: 6.0.10
created: "2021-01-21T16:43:51.589712477+08:00"
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 1.x.x
description: Open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
digest: 4208a6eae05c9486dbecc55db3bc6e04960708e0b389adfa1f7e309d3937a451
home: https://github.com/bitnami/charts/tree/master/bitnami/redis
icon: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
keywords:
- redis
- keyvalue
- database
maintainers:
- email: containers@bitnami.com
name: Bitnami
- email: cedric@desaintmartin.fr
name: desaintmartin
name: redis
sources:
- https://github.com/bitnami/bitnami-docker-redis
- http://redis.io/
urls:
- http://192.168.0.99/repo-test/redis-12.6.2.tgz
version: 12.6.2
generated: "2021-01-21T16:43:51.568008766+08:00"
[root@master01 repo-test]#

Copy repo-test Directory to web The server nginx The web root of

[root@master01 repo-test]# cd ..
[root@master01 ~]# scp -r repo-test 192.168.0.99:/usr/share/nginx/html/
root@192.168.0.99's password:
logstash-3.0.2.tgz 100% 26KB 8.8MB/s 00:00
myapp-0.2.0.tgz 100% 3584 406.3KB/s 00:00
redis-12.6.2.tgz 100% 71KB 10.5MB/s 00:00
index.yaml 100% 2548 348.1KB/s 00:00
[root@master01 ~]# ssh 192.168.0.99
root@192.168.0.99's password:
Last login: Thu Jan 21 16:35:28 2021 from 192.168.0.232
[root@docker_registry ~]# ll /usr/share/nginx/html/
total 12
-rw-r--r-- 1 root root 3650 Nov 1 10:01 404.html
-rw-r--r-- 1 root root 3693 Nov 1 10:01 50x.html
lrwxrwxrwx 1 root root 20 Jan 21 16:36 en-US -> ../../doc/HTML/en-US
drwxr-xr-x 2 root root 27 Jan 21 16:36 icons
lrwxrwxrwx 1 root root 18 Jan 21 16:36 img -> ../../doc/HTML/img
lrwxrwxrwx 1 root root 25 Jan 21 16:36 index.html -> ../../doc/HTML/index.html
-rw-r--r-- 1 root root 368 Nov 1 10:01 nginx-logo.png
lrwxrwxrwx 1 root root 14 Jan 21 16:36 poweredby.png -> nginx-logo.png
drwxr-xr-x 2 root root 97 Jan 21 16:45 repo-test
[root@docker_registry ~]#

start-up nginx service

[root@docker_registry ~]# systemctl start nginx
[root@docker_registry ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:20048 *:*
LISTEN 0 5 192.168.122.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 192.168.0.99:631 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 64 *:45725 *:*
LISTEN 0 128 *:36254 *:*
LISTEN 0 64 *:2049 *:*
LISTEN 0 128 :::111 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::20048 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::52761 :::*
LISTEN 0 64 :::2049 :::*
LISTEN 0 64 :::43907 :::*
[root@docker_registry ~]#

verification : Use helm Add private warehouse

[root@master01 ~]# helm repo add repo-test http://192.168.0.99/repo-test
"repo-test" has been added to your repositories
[root@master01 ~]# helm repo list
NAME URL
bitnami https://charts.bitnami.com/bitnami
repo-test http://192.168.0.99/repo-test
[root@master01 ~]# helm search repo repo-test
NAME CHART VERSION APP VERSION DESCRIPTION
repo-test/logstash 3.0.2 7.10.2 Logstash is an open source, server-side data pr...
repo-test/myapp 0.2.0 v2 web server
repo-test/redis 12.6.2 6.0.10 Open source, advanced key-value store. It is of...
[root@master01 ~]#

Tips : You can see... In the corresponding warehouse chart All can be listed normally ;

Install... In the private warehouse chart

[root@master01 ~]# helm install myapp-test repo-test/myapp
NAME: myapp-test
LAST DEPLOYED: Thu Jan 21 16:54:06 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=myapp,app.kubernetes.io/instance=myapp-test" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
myapp-test default 1 2021-01-21 16:54:06.041883984 +0800 CST deployed myapp-0.2.0 v2
myapp-v1 default 8 2021-01-21 15:40:38.060295891 +0800 CST deployed myapp-0.2.0 v2
redis default 1 2021-01-21 02:26:26.13324987 +0800 CST deployed redis-12.6.2 6.0.10
redis-demo default 1 2021-01-21 01:58:18.20798703 +0800 CST deployed redis-12.6.2 6.0.10
[root@master01 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-test-58c57d75fc-s22cn 1/1 Running 0 31s
myapp-v1-675d685ddf-7c8zd 1/1 Running 0 73m
redis-demo-master-0 1/1 Running 1 14h
redis-demo-slave-0 1/1 Running 2 14h
redis-demo-slave-1 1/1 Running 7 14h
redis-master-0 1/1 Running 1 14h
redis-slave-0 1/1 Running 1 14h
redis-slave-1 1/1 Running 1 14h
[root@master01 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 17h
myapp-test ClusterIP 10.108.7.220 <none> 80/TCP 39s
myapp-v1 ClusterIP 10.110.153.241 <none> 80/TCP 98m
redis-demo-headless ClusterIP None <none> 6379/TCP 14h
redis-demo-master ClusterIP 10.109.45.70 <none> 6379/TCP 14h
redis-demo-slave ClusterIP 10.111.222.218 <none> 6379/TCP 14h
redis-headless ClusterIP None <none> 6379/TCP 14h
redis-master ClusterIP 10.108.35.165 <none> 6379/TCP 14h
redis-slave ClusterIP 10.99.96.166 <none> 6379/TCP 14h
[root@master01 ~]# curl 10.108.7.220
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
[root@master01 ~]#

Tips : You can see that using the chart Be able to run normally as a release, Corresponding generated svc Can also be accessed normally ;

Use Alibaba cloud private helm Warehouse

1、 Get into :https://repomanage.rdc.aliyun.com/my/repo?spm=a2c4g.11186623.2.7.7b646b06Zv1cAd, Log in to alicloud account , And register to open cloud effect service , Create a business ;

2、 Create a namespace

 

3、 Add warehouse

4、helm push plug-in unit

[root@master01 ~]# helm plugin install https://github.com/chartmuseum/helm-push
Downloading and installing helm-push v0.9.0 ...
https://github.com/chartmuseum/helm-push/releases/download/v0.9.0/helm-push_0.9.0_linux_amd64.tar.gz
Installed plugin: push
[root@master01 ~]#

5、 Release chart Catalog

[root@master01 ~]# cat myapp/Chart.yaml
apiVersion: v2
name: myapp
description: web server
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2"
[root@master01 ~]# helm push myapp/ $NAMESPACE
Pushing myapp-0.2.0.tgz to 136529-test...
Done.
[root@master01 ~]#

6、 Release chart Package files

[root@master01 ~]# helm push repo-test/myapp-0.2.0.tgz $NAMESPACE
Pushing myapp-0.2.0.tgz to 136529-test...
Done.
[root@master01 ~]#

Tips : If not, customize chart pack , Please use first. helm package CHART_DIR pack ;

7、 Update local warehouse index

[root@master01 ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "repo-test" chart repository
...Successfully got an update from the "bitnami" chart repository
...Successfully got an update from the "136529-test" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@master01 ~]#

verification : Search for myapp, See if the corresponding warehouse can list the corresponding chart?

[root@master01 ~]# helm search repo myapp
NAME CHART VERSION APP VERSION DESCRIPTION
136529-test/myapp 0.2.0 v2 web server
repo-test/myapp 0.2.0 v2 web server
[root@master01 ~]#

View the uploaded chart

verification : install myapp, Look at the corresponding chart Whether it can run as a release?

Tips : You can see from the corresponding helm Download the corresponding chart, And in k8s Run as a release;

版权声明
本文为[Linux-1874]所创,转载请带上原文链接,感谢
https://javamana.com/2021/01/20210121184620005u.html

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云