k8s-helm-v3 Installation management

https://helm.sh/blog/helm-3-released/ website helm3

https://hub.helm.sh/ helm Warehouse

One Common commands

1 helm install

https://github.com/helm/helm/releases/tag/v3.1.2 Download address

1 download 3.0 Version of , Then decompress , hold helm Command to move to /usr/local/bin Below directory

2 see helm edition

helm version

 

2 Configure download source

 

helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

remove

helm repo remove 127854-hnf

3 View download source

 

[[email protected] helm-v3]# helm repo list
NAME   URL                                                   
stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

 

4 Query for pod

helm search repo weave # Followed by the name of the software you are looking for

helm search repo weave
NAME               CHART VERSION APP VERSION DESCRIPTION                                       
stable/weave-cloud 0.1.2                     Weave Cloud is a add-on to Kubernetes which pro...
stable/weave-scope 0.9.2         1.6.5       A Helm chart for the Weave Scope cluster visual...

 

5 Install a mirror ( service )

helm install ui stable/weave-scope # among ui For the name

 

[[email protected] helm-v3]# helm install ui stable/weave-scope
NAME: ui
LAST DEPLOYED: Fri Apr  3 18:15:36 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
You should now be able to access the Scope frontend in your web browser, by
using kubectl port-forward:
kubectl -n default port-forward $(kubectl -n default get endpoints \
ui-weave-scope -o jsonpath='{.subsets[0].addresses[0].targetRef.name}') 8080:4040
then browsing to http://localhost:8080/.
For more details on using Weave Scope, see the Weave Scope documentation:
https://www.weave.works/docs/scope/latest/introducing/

And then change it svc The type of ,nodeport, Then go to the browser and visit :nodeip+ port

 

Two Create your own mychart

1 establish mychart

 

helm create mychart

Then go in mychart/templates/ Under this directory , To create two basic files ,deployment and service

 

2 helm install tomcat

  • install

Back to follow mychart Execute under the same level directory

[[email protected] helm-v3]# helm install tomcat mychart/
NAME: tomcat
LAST DEPLOYED: Fri Apr  3 18:40:18 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

 

And then check out pod and svc Go to the browser and visit tomcat page

  • Delete

helm delete -f mychart/templtes

 

  • upgrade ( It's over yaml File and then reapply )

helm upgrade tomcat mychart/

 

  • Capacity expansion

helm upgrade web1 --set replicas=3 mychart/

 

3、 ... and Render templates with variables

1 Test whether your template is normal

 

helm install --dry-run tomcat mychart

 

2 Template in templates Inside ,

 

values.yaml As a variable :

 

[[email protected] helm-v3]# cat mychart/values.yaml 
replicas: 2
image: huningfei/tomcat8
tag: v1
label: tomcat
port: 8080

deployment.yaml

 

[[email protected] templates]# cat tomcat.yaml 
apiVersion: apps/v1
kind: Deployment # Controller name
metadata:
  name: {{ .Release.Name }}-dp
spec:
  replicas: {{ .Values.replicas }} # Copy number
  selector:
    matchLabels:
      app:  {{ .Values.label }}
  template:
    metadata:
      labels:
        app: {{ .Values.label }}
    spec:
      containers:
      - name: tomcat
        image:  {{ .Values.image }}:{{ .Values.tag }} # Mirror image 

svc Templates

 

[[email protected] templates]# cat service_tomcat.yaml 
apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}-svc
spec:
  type: NodePort
  ports:
   - port: 8080
     targetPort: {{ .Values.port}}
  selector:
    app: {{ .Values.label }}

The variables in both files are from values.yaml From inside

Release.Name representative helm install The name behind it

 

3 Capacity expansion, capacity reduction, and rollback

helm upgrade web1 --set replicas=3 mychart/

 

Before rolling back helm list Check out the next version , And then roll back

helm rollback tomcat1 1 # Name plus version

 

4 Delete

helm delete name

3 Version does not exist, completely deleted , You can't view the deleted