建模外包网站,wordpress如何上传源码,企业手机网站建设渠道,海报设计说明200字前言
类似于 Linux 的 YUM、APT#xff0c;Helm 是 K8S 的包管理工具。
Helm#xff0c; 一个二进制工具#xff0c;用来安装、升级、卸载 K8S 中的应用程序。
Helm Chart#xff0c;一个 tgz 包#xff0c;类似安卓的 APK。
K8S 应用打包成 Chart#xff0c;通过 He…前言
类似于 Linux 的 YUM、APTHelm 是 K8S 的包管理工具。
Helm 一个二进制工具用来安装、升级、卸载 K8S 中的应用程序。
Helm Chart一个 tgz 包类似安卓的 APK。
K8S 应用打包成 Chart通过 Helm 安装到 K8S 集群中。
一、安装Helm
用二进制版本安装
每个Helm 版本都提供了各种操作系统的二进制版本这些版本可以手动下载和安装。
下载 需要的版本
wget https://repo.huaweicloud.com/helm/v3.5.4/helm-v3.5.4-linux-amd64.tar.gz
解压
tar -zxvf helm-v3.5.4-linux-amd64.tar.gz
在解压目录中找到helm程序移动到需要的目录中
mv linux-amd64/helm /usr/local/bin/helm
然后就可以执行客户端程序并 添加稳定仓库: helm help
二、配置helm
微软仓库http://mirror.azure.cn/kubernetes/charts/
阿里云仓库https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
推荐仓库https://charts.bitnami.com/bitnami
添加仓库 helm repo add 自定义仓库名 仓库地址 仓库地址就是上面几个网站地址
[rootk8s-master-136 samve]# helm repo add apphub https://charts.bitnami.com/bitnami
删除仓库 helm repo remove 仓库名
更新仓库 helm repo update
查看仓库 helm repo list
搜索仓库的chart helm search repo chart名称
三、使用helm快速部署一个应用
使用搜索命令搜索应用
helm search repo 应用名称
[rootk8s-master-136 samve]# helm search repo nginx
NAME CHART VERSION APP VERSION DESCRIPTION
apphub/nginx 15.3.3 1.25.2 NGINX Open Source is a web server that can be a...
apphub/nginx-ingress-controller 9.9.0 1.9.0 NGINX Ingress Controller is an Ingress controll...
apphub/nginx-intel 2.1.15 0.4.9 DEPRECATED NGINX Open Source for Intel is a lig...
根据搜索内容选择安装
helm install 安装后应用的名称 搜索之后应用的名称
[rootk8s-master-136 samve]# helm install my-nginx apphub/nginx
NAME: my-nginx
LAST DEPLOYED: Thu Oct 12 22:16:31 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 15.3.3
APP VERSION: 1.25.2** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:my-nginx.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 my-nginxexport SERVICE_PORT$(kubectl get --namespace default -o jsonpath{.spec.ports[0].port} services my-nginx)export SERVICE_IP$(kubectl get svc --namespace default my-nginx -o jsonpath{.status.loadBalancer.ingress[0].ip})echo http://${SERVICE_IP}:${SERVICE_PORT}
查看安装之后的状态
helm list
[rootk8s-master-136 samve]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
my-nginx default 1 2023-10-12 22:16:31.191334159 0800 CST deployed nginx-15.3.3 1.25.2
nginx default 1 2023-10-12 21:52:49.36634682 0800 CST deployed nginx-intel-2.1.15 0.4.9
helm status 安装之后应用的名称
[rootk8s-master-136 samve]# helm status my-nginx
NAME: my-nginx
LAST DEPLOYED: Thu Oct 12 22:16:31 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 15.3.3
APP VERSION: 1.25.2** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:my-nginx.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 my-nginxexport SERVICE_PORT$(kubectl get --namespace default -o jsonpath{.spec.ports[0].port} services my-nginx)export SERVICE_IP$(kubectl get svc --namespace default my-nginx -o jsonpath{.status.loadBalancer.ingress[0].ip})echo http://${SERVICE_IP}:${SERVICE_PORT}
当然我们也可以通过kubectl命令查看相关的pod是否创建成功
[rootk8s-master-136 samve]# kubectl get svc,pod
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.10.0.1 none 443/TCP 258d
service/my-nginx LoadBalancer 10.10.200.7 pending 80:32374/TCP 9m37s
service/nginx NodePort 10.10.183.194 none 80:30111/TCP 258d
service/nginx-nginx-intel LoadBalancer 10.10.72.168 pending 80:32756/TCP,443:30799/TCP 33mNAME READY STATUS RESTARTS AGE
pod/my-nginx-8568bb4694-gn5b7 1/1 Running 0 9m37s
pod/nginx-2-69947fd9df-plct2 1/1 Running 2 47h
pod/nginx-6799fc88d8-2jh5z 1/1 Running 2 47h
pod/nginx-nginx-intel-668b58fb4b-8cm6z 0/1 ImagePullBackOff 0 33m
pod/nginx1-b7fb675cb-rhtvn 0/1 CrashLoopBackOff 50 47h
pod/nginx2-74ff6c9fbc-2gb7r 0/1 CrashLoopBackOff 50 47h
四、自定义chart
自定义选项是因为并不是所有的 chart 都能按照默认配置运行成功可能会需要一些环境 依赖例如 PV。 所以我们需要自定义 chart 配置选项安装过程中有两种方法可以传递配置数据 --values或-f指定带有覆盖的 YAML 文件。这可以多次指定最右边的文件 优先--set在命令行上指定替代。如果两者都用--set 优先级高 第一步使用命令创建chart
helm create chart名称
[rootk8s-master-136 samve]# helm create mychart
Creating mychart
[rootk8s-master-136 samve]# ls mychart/
charts Chart.yaml templates values.yaml
[rootk8s-master-136 samve]# cd mychart/
[rootk8s-master-136 mychart]# ls -al
总用量 16
drwxr-xr-x 4 root root 93 10月 12 22:33 .
drwx------. 17 samve samve 4096 10月 12 22:33 ..
drwxr-xr-x 2 root root 6 10月 12 22:33 charts
-rw-r--r-- 1 root root 1143 10月 12 22:33 Chart.yaml
-rw-r--r-- 1 root root 349 10月 12 22:33 .helmignore
drwxr-xr-x 3 root root 162 10月 12 22:33 templates
-rw-r--r-- 1 root root 1899 10月 12 22:33 values.yaml charts普通文件夹刚开始创建为空Chart.yaml用于配置当前chart的属性信息可以作为全局变量提供给模板文件使用templates目标信息文件里面有很多的yaml模板文件我们使用helm创建应用相当于helm帮我去执行这些yaml文件了values.yaml全局变量文件提供给templates里面的yaml文件用。 因为我们需要自己自定义chart因此我们可以修改这些yaml文件也可以删除这些默认生成的yaml文件然后自己重新写。