首页 > 其他分享 >801-806 Helm 工具介绍 8.1-8.6

801-806 Helm 工具介绍 8.1-8.6

时间:2023-10-28 16:55:33浏览次数:40  
标签:8.1 helm 8.6 -- redis cluster mysql Helm bitnami

一、Helm工具介绍

1.1 了解Helm

Helm是Kubernetes中查找、分享、构建应用的最佳方式。

Helms 是一个Kubernetes应用的包管理工具,用来管理chart(一种预先配置的安装包资源)。

官网地址:

官网地址: https://helm.sh/
github地址:https://github.com/helm/helm/releases

1.2 Helm核心概念

  1. Chart:Chart是helm package,包含了一个k8s应用运行起来的所有要素。比如service、deployment、configmap、serviceaccount、rbac等,这些要素以template文件的形式存在,结合values文件,最终渲染出能被k8ss执行的yaml文件。
  2. Respository:仓库是charts集合,方便进行分享和分发。
  3. Hub:不同个人和组织提供的公共仓库(Respository)形成分散和分布的Helm仓库,不利于查找,私有官方提供Helm Hub,各公共仓库可以注册到Helm Hub,Helm只是分布式的仓库的几种展示中心。仓库注册到Helm Hub时,会将Chart清单文件向Helm Hub同步一份,这样可以在Helm Hub集中展示仓库列表和各仓库中的Chart列表。
    Chart包也就是tgz文件实际上存储在各仓库中。Helm Hub并不实际存储Chart包。Helm只是在查询Chart时和Helm Hub有交互,其它操作都是和仓库直接交互的。
  4. Realase:Release是Helm Chart在Kubernetes的一个运行实例,这个release 名字会出现在k8s,其中service 和deploy的名字跟这个release 名字一致。

1.3 Helm版本和Kubernetes 版本要求

参考:https://helm.sh/zh/docs/topics/version_skew/

二、Helm工具用法

2.1 安装Helm

官网下载地址:https://github.com/helm/helm/releases

wget https://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gz

解压并做软链接

tar zxf helm-v3.12.3-linux-amd64.tar.gz  -C /opt/
mv /opt/linux-amd64/  /opt/helm
ln -s /opt/helm/helm  /bin/

2.2 Helm常用命令

node-1-134 配置kubectl

 

添加仓库

#helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
#helm repo add helm_sh https://charts.helm.sh/stable

#helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"aliyun" has been added to your repositories

更新仓库列表到本地

# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "aliyun" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈

查看仓库列表

# helm repo list
NAME   	URL                                                   
bitnami	https://charts.bitnami.com/bitnami                    
aliyun 	https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

在本地仓库搜索所有chart

helm search repo 

在本地仓库搜索mysql

# helm search repo mysql
NAME                         	CHART VERSION	APP VERSION	DESCRIPTION                                       
aliyun/mysql                 	0.3.5        	           	Fast, reliable, scalable, and easy to use open-...
bitnami/mysql                	9.14.1       	8.0.35     	MySQL is a fast, reliable, scalable, and easy t...
aliyun/percona               	0.3.0        	           	free, fully compatible, enhanced, open source d...
aliyun/percona-xtradb-cluster	0.0.2        	5.7.19     	free, fully compatible, enhanced, open source d...
bitnami/phpmyadmin           	13.0.0       	5.2.1      	phpMyAdmin is a free software tool written in P...
aliyun/gcloud-sqlproxy       	0.2.3        	           	Google Cloud SQL Proxy                            
aliyun/mariadb               	2.1.6        	10.1.31    	Fast, reliable, scalable, and easy to use open-...
bitnami/mariadb              	14.1.0       	11.1.2     	MariaDB is an open source, community-developed ...
bitnami/mariadb-galera       	10.0.3       	11.1.2     	MariaDB Galera is a multi-primary database clus...

在公共的hub搜索chart

helm search hub mysql  
helm search hub mysql  --list-repo-url  ##查看对应repo的url
helm search hub mysql  --max-col-width 100 #可以设置每一列的宽度,这样可以显示所有的描述信息

查看某个chat 详细信息

# helm show chart bitnami/mysql
 # helm show chart bitnami/mysql
annotations:
  category: Database
  images: |
    - name: mysql
      image: docker.io/bitnami/mysql:8.0.35-debian-11-r0
    - name: mysqld-exporter
      image: docker.io/bitnami/mysqld-exporter:0.15.0-debian-11-r70
    - name: os-shell
      image: docker.io/bitnami/os-shell:11-debian-11-r90
  licenses: Apache-2.0
apiVersion: v2
appVersion: 8.0.35
dependencies:
- name: common
  repository: oci://registry-1.docker.io/bitnamicharts
  tags:
  - bitnami-common
  version: 2.x.x
description: MySQL is a fast, reliable, scalable, and easy to use open source relational
  database system. Designed to handle mission-critical, heavy-load production applications.
home: https://bitnami.com
icon: https://bitnami.com/assets/stacks/mysql/img/mysql-stack-220x234.png
keywords:
- mysql
- database
- sql
- cluster
- high availability
maintainers:
- name: VMware, Inc.
  url: https://github.com/bitnami/charts
name: mysql
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/mysql
version: 9.14.1

 

查看某个chart values

helm show values bitnami/mysql

安装chart (示例:安装nginx)

helm search repo nginx ##先搜一下

helm install nginx-test  bitnami/nginx   #这个nginx-test就是release名字,同时也是service和deployment/statefulset以及pod前缀,当然你也可以不去定义release name,让Helm帮忙定义,那么命令就要改为
# helm install nginx-test  bitnami/nginx 
NAME: nginx-test
LAST DEPLOYED: Fri Oct 27 22:09:29 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 15.3.5
APP VERSION: 1.25.3

** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:

    nginx-test.default.svc.cluster.local (port 80)

To access NGINX from outside the cluster, follow the steps below:

1. Get the NGINX URL by running these commands:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w nginx-test'

    export SERVICE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].port}" services nginx-test)
    export SERVICE_IP=$(kubectl get svc --namespace default nginx-test -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo "http://${SERVICE_IP}:${SERVICE_PORT}"


# helm install   bitnami/nginx --generate-name
NAME: nginx-1698415932
LAST DEPLOYED: Fri Oct 27 22:12:14 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 15.3.5
APP VERSION: 1.25.3

** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:

    nginx-1698415932.default.svc.cluster.local (port 80)

To access NGINX from outside the cluster, follow the steps below:

1. Get the NGINX URL by running these commands:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w nginx-1698415932'

    export SERVICE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].port}" services nginx-1698415932)
    export SERVICE_IP=$(kubectl get svc --namespace default nginx-1698415932 -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo "http://${SERVICE_IP}:${SERVICE_PORT}"
# helm list -A
NAME            	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART       	APP VERSION
nginx-1698415932	default  	1       	2023-10-27 22:12:14.460723372 +0800 CST	deployed	nginx-15.3.5	1.25.3     



install过程中会自动生成缓存目录: ~/.cache/helm/repository/

安装完成后 查看helm安装过的chart

# helm list -A
NAME      	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART       	APP VERSION
nginx-test	default  	1       	2023-10-27 22:09:29.007263045 +0800 CST	deployed	nginx-15.3.5	1.25.3     

卸载

# helm uninstall nginx-test
release "nginx-test" uninstalled

下载chart 包

helm pull bitnami/mysql

使用本地chart包安装

# helm pull bitnami/mysql
[root@node-1-234 helm]# ll
总用量 48
-rw-r--r-- 1 root root 46714 10月 27 22:13 mysql-9.14.1.tgz
[root@node-1-234 helm]# tar zxf mysql-9.14.1.tgz
[root@node-1-234 helm]# cd  mysql
[root@node-1-234 mysql]# helm install test-mysql .
NAME: test-mysql
LAST DEPLOYED: Fri Oct 27 22:13:49 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 9.14.1
APP VERSION: 8.0.35

** Please be patient while the chart is being deployed **

Tip:

  Watch the deployment status using the command: kubectl get pods -w --namespace default

Services:

  echo Primary: test-mysql.default.svc.cluster.local:3306

Execute the following to get the administrator credentials:

  echo Username: root
  MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default test-mysql -o jsonpath="{.data.mysql-root-password}" | base64 -d)

To connect to your database:

  1. Run a pod that you can use as a client:

      kubectl run test-mysql-client --rm --tty -i --restart='Never' --image  docker.io/bitnami/mysql:8.0.35-debian-11-r0 --namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash

  2. To connect to primary service (read/write):

      mysql -h test-mysql.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"

三、Helm工具实践

3.1 安装redis-cluster

先搭建一个NFS的SC

下载redis-cluster的chart包

helm pull bitnami/redis-cluster  --untar

修改values.yaml

cd redis-cluster
vi values.yaml # 定义sc和密码
  storageClass: "nfs-client"
  redis:
    password: "helm123"

安装

# helm install redis-cluster . 
NAME: redis-cluster
LAST DEPLOYED: Fri Oct 27 22:15:37 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: redis-cluster
CHART VERSION: 9.0.13
APP VERSION: 7.2.2** Please be patient while the chart is being deployed **


To get your password run:
    export REDIS_PASSWORD=$(kubectl get secret --namespace "default" redis-cluster -o jsonpath="{.data.redis-password}" | base64 -d)

You have deployed a Redis® Cluster accessible only from within you Kubernetes Cluster.INFO: The Job to create the cluster will be created.To connect to your Redis® cluster:

1. Run a Redis® pod that you can use as a client:
kubectl run --namespace default redis-cluster-client --rm --tty -i --restart='Never' \
 --env REDIS_PASSWORD=$REDIS_PASSWORD \
--image docker.io/bitnami/redis-cluster:7.2.2-debian-11-r0 -- bash

2. Connect using the Redis® CLI:

redis-cli -c -h redis-cluster -a $REDIS_PASSWORD

查看redis状态

# helm status  redis-cluster
NAME: redis-cluster
LAST DEPLOYED: Fri Oct 27 22:15:37 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: redis-cluster
CHART VERSION: 9.0.13
APP VERSION: 7.2.2** Please be patient while the chart is being deployed **


To get your password run:
    export REDIS_PASSWORD=$(kubectl get secret --namespace "default" redis-cluster -o jsonpath="{.data.redis-password}" | base64 -d)

You have deployed a Redis® Cluster accessible only from within you Kubernetes Cluster.INFO: The Job to create the cluster will be created.To connect to your Redis® cluster:

1. Run a Redis® pod that you can use as a client:
kubectl run --namespace default redis-cluster-client --rm --tty -i --restart='Never' \
 --env REDIS_PASSWORD=$REDIS_PASSWORD \
--image docker.io/bitnami/redis-cluster:7.2.2-debian-11-r0 -- bash

2. Connect using the Redis® CLI:

redis-cli -c -h redis-cluster -a $REDIS_PASSWORD

测试

3.2 应用的升级和回滚

安装好的应用,如果再次修改values.yaml(比如修改密码为:helm456,则需要做升级处理

helm upgrade  redis-cluster  .

查看升级历史

helm history redis-cluster

回滚

helm rollback redis-cluster 1

 

标签:8.1,helm,8.6,--,redis,cluster,mysql,Helm,bitnami
From: https://www.cnblogs.com/pythonlx/p/17790396.html

相关文章

  • helm部署kafka鉴权以及ACL
    官方文档https://github.com/bitnami/charts/tree/main/bitnami/kafkahttps://blog.csdn.net/u011618288/article/details/129105777(包含zookeeper与broker认证、鉴权流程)一.修改values.yaml文件按通用部署方案拉下来kafka安装包,修改values.yaml文件,开启scram鉴权,ACL以......
  • KubeSphere v3.4.0 创建Mysql 8.1.0 数据库主从记录
    主要讲下KubeSphere中创建【有状态】的【工作负载】需要注意的配置问题。这里的创建过程也不详细描述,网上简单找一找也有。重点在使用存储里面的配置字典:1、先创建一个配置字典,参考名:mysql-config2、创建一主一从的配置项,键(主库):master-1.cnf值(主库):[mysqld]port......
  • VMware Aria Operations for Logs 8.14 发布下载 - 集中式日志管理
    VMwareAriaOperationsforLogs8.14发布下载-集中式日志管理请访问原文链接:https://sysin.org/blog/vmware-aria-operations-for-logs/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org集中式日志管理VMwareAriaOperationsforLogs(以前称为vRealizeLogI......
  • VMware Aria Suite Lifecycle 8.14 发布下载 - 应用生命周期管理
    VMwareAriaSuiteLifecycle8.14发布下载-应用生命周期管理请访问原文链接:https://sysin.org/blog/vmware-aria-suite-lifecycle/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org应用生命周期管理VMwareAriaSuiteLifecycle(以前称为vRealizeSuiteLifecyc......
  • VMware Aria Automation Orchestrator 8.14 发布下载 - 现代工作流程自动化平台
    VMwareAriaAutomationOrchestrator8.14发布下载-现代工作流程自动化平台请访问原文链接:https://sysin.org/blog/vmware-aria-automation-orchestrator/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org现代工作流程自动化平台VMwareAriaAutomationOrchestra......
  • VMware Aria Operations 8.14 发布下载 - 多云 IT 运维管理
    VMwareAriaOperations8.14发布下载-多云IT运维管理通过统一的高性能平台,实现跨私有云、混合云和多云环境的IT运维管理。请访问原文链接:https://sysin.org/blog/vmware-aria-operations/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org自动驾驶式IT运维......
  • VMware Aria Automation 8.14 发布下载 - 现代基础架构自动化平台
    VMwareAriaAutomation8.14发布下载-现代基础架构自动化平台请访问原文链接:https://sysin.org/blog/vmware-aria-automation/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org现代基础架构自动化平台VMwareAriaAutomation(以前称为vRealizeAutomation)借助现......
  • VMware Aria Suite 8.14 发布 - 云管理解决方案 (下载索引)
    VMwareAriaSuite8.14-云管理解决方案(下载索引)请访问原文链接:https://sysin.org/blog/vmware-aria-suite/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org云管理套包VMwareAriaSuite(以前称为vRealizeSuite)和vCloudSuiteVMwareAriaSuite(vRealizeSu......
  • Helm使用小技巧
    1、背景Helm 是一个 Kubernetes 的包管理工具,有点类似于 Mac 上的 brew,Python 中的 PIP;可以很方便的帮我们直接在 kubernetes 中安装某个应用。比如我们可以直接使用以下命令方便的在k8s集群安装和卸载 MySQL:helminstallmy-sqloci://registry-1.docker.io/bit......
  • 18.1 Socket 原生套接字抓包
    原生套接字抓包的实现原理依赖于Windows系统中提供的ioctlsocket函数,该函数可将指定的网卡设置为混杂模式,网卡混杂模式(PromiscuousMode)是常用于计算机网络抓包的一种模式,也称为监听模式。在混杂模式下,网卡可以收到经过主机的所有数据包,而非只接收它所对应的MAC地址的数据包。一......