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

Examples of using helm tools in K8s

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

Share

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

For more information about installing helm tools, please refer to the blog post: installation and configuration Helm tool for K8s

This blog post is just a simple note. The arrangement is not in place, please forgive me.

1. Four installation methods supported by helm install the chart package in the warehouse. Command example: helm install stable/xxx; is installed through the tar package, command example: helm install xxx-1.tgz (not recommended) Through the chart local directory installation, command example: helm install xxx/xxx (generally use helm fetch stable/xxxxx to download the corresponding template, and then use tar zxf to extract, modify the value of the valumes.yaml file in the directory after decompression, is the custom service, this way is more commonly used); through URL installation, less commonly used, command example: helm install https://xxxx/charts/xxx-1.gz. 2. Custom Chart package example [root@master ~] # helm create testchart # create testchar package # if there is no "tree" command, you can use "yum-y install tree" to install [root@master ~] # tree-C testchart/ # you can see that all kinds of templates are available in the generated directory Testchart/ ├── charts ├── Chart.yaml ├── templates ├── deployment.yaml │ ├── _ helpers.tpl │ ├── ingress.yaml │ ├── NOTES.txt │ ├── service.yaml │ └── tests │ └── test-connection.yaml └── values.yaml [root@master ~] # helm install testchart/-dry-run-- Debug# "--dry-run": simulated installation "--debug": test output # after executing the above command, you can output the yaml file content of the directory template [root@master ~] # helm lint testchart/ # to check the syntax of the directory content. Testchart is the directory name = = > Linting testchart/ [INFO] Chart.yaml: icon is recommended1 chart (s) linted, no failures

Additional: https://hub.helm.sh/, this is a helm template repository website, there are a large number of helm templates, you can view.

Run a MySQL service for example 1. Deploy the NFS service [root@master ~] # yum-y install nfs-utils [root@master ~] # vim / etc/exports/nfsdata * (rw,sync) No_root_squash) [root@master ~] # systemctl start rpcbind [root@master ~] # systemctl start nfs-server [root@master ~] # showmount-eExport list for master:/nfsdata * 2, Create a PV [root@master ~] # vim mysql-pv.yaml # write the yaml file apiVersion: v1kind: PersistentVolumemetadata: name: mysql-pvspec: accessModes:-ReadWriteOnce capacity: storage: 8Gi persistentVolumeReclaimPolicy: Retain nfs: path: / nfsdata/mysql-pv # specify the local mount directory server: 192.168.20.6 [root@master ~] # mkdir-p / nfsdata/mysql-pv # create the local directory of nfs [root@master ~] # kubectl apply-f mysql-pv.yaml # execute the yaml file [root@master ~] # kubectl get pv # confirm that the pv status is normal and the NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGEmysql-pv 8Gi RWO Retain Available 73s# status is "Available" means that the pv is normal. 3. Helm deployment MySQL [root@master ~] # helm install stable/mysql-- set mysqlRootPassword=123.com-n test-mysql# online installation MySQL And set the root password of mysql to 123.com "- n" means to specify its name # View its pod [root@master ~] # helm list # use helm to view NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACEtest-mysql 1 Sun Dec 1 21:22:56 2019 DEPLOYED mysql-0.3.5 default [root@master ~] # kubectl get pod-o wide # View the podNAME corresponding to mysql READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATEStest-mysql-mysql-dfb9b6944-4kmgv 1bat 1 Running 0 9m16s 10.244.2.2 node02 # can log in to the database for testing [root@master] # kubectl exec-it test-mysql-mysql-dfb9b6944-4kmgv-- mysql- uroot-p123.com

When install is installed, some prompts are output, including the command to view the MySQL database password. If you do not use the "--set" command to set the database root password, you can use this command to view the default database root and user password. The prompt command is as follows:

You can also view detailed status information about test-mysql instances with the following command

[root@master ~] # helm status test-mysql # View the instance information of test-mysql

Upgrade MySQL mirroring operation online

[root@master ~] # helm upgrade-set imageTag=5.7.16 test-mysql stable/mysql# where test-mysql is the instance name; # you still need to specify the stable/mysql file specified in the first run, and if you specify a directory in the first run, change it to a directory # verify whether the image has been updated successfully [root@master ~] # kubectl describe pod test-mysql-mysql-68484cd8db-59wm5

After the above command is executed, the output is as follows (you can see that the version of the image has been updated):

[root@master ~] # helm list # look at the instance again and find that the "REVISION" field is 2, but when the instance is created for the first time, it is listed as "1Jing # each update" This value will be + 1.NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACEtest-mysql 2 Sun Dec 1 21:53:00 2019 DEPLOYED mysql-0.3.5 default [root@master ~] # helm history test-mysql # to view the historical version of the instance REVISION UPDATED STATUS CHART DESCRIPTION 1 Sun Dec 1 21:22:56 2019 SUPERSEDED mysql-0.3.5 Install complete2 Sun Dec 1 21:53:00 2019 DEPLOYED mysql-0.3.5 Upgrade complete

Perform a version rollback of the test-mysql instance

[root@master ~] # helm rollback test-mysql 1 # rollback to version 1Rollback was a success. [root@master ~] # helm list # check again You can see that the value of "REVISION" becomes 3NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACEtest-mysql 3 Sun Dec 1 22:12:25 2019 DEPLOYED mysql-0.3.5 default # View the container details corresponding to MySQL [root@master ~] # kubectl describe pod test-mysql-mysql-dfb9b6944-8hfj4

The returned information is as follows. You can see that the version of the image has been rolled back to the version created for the first time, as follows:

-this is the end of this article. Thank you for reading-

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