一、Helm
![](https://i-blog.csdnimg.cn/blog_migrate/bea860934e6eebd9df2fd00d8596578c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d580a9e5633d6bd9e1c52a2bab69af0e.png)
二、helm概述
~~~ helm官网地址:
### --- 之前方式部署应用基本操作
~~~ 部署一个nginx应用;导出为yaml文件
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx -o yaml
### --- 对外暴露端口,创建一个services
[root@k8s-master ~]# kubectl expose deployment nginx --port=80 --target-port=80 --type=NodePort
[root@k8s-master ~]# kubectl get pods # 查看Pod
[root@k8s-master ~]# kubectl get svc # 查看services
一、helm快速部署应用:helm官网地址:https://helm.sh/docs/intro/quickstart/
![](https://i-blog.csdnimg.cn/blog_migrate/08b170dedd1c1e805145a4520fe7b4cb.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e6f7e3e135c9abca8fab607ea3bcfdda.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cf67ad9103b461460cf9a3321489739a.png)
三、使用helm部署应用
### --- 将helm-v3.0.0-linux-amd64.tar.gz该软件包上传到服务器并解压
[root@k8s-master ~]# tar -zxvf helm-v3.0.0-linux-amd64.tar.gz
### --- 将helm执行文件放到可以执行目录下
[root@k8s-master linux-amd64]# mv helm /usr/bin/
~~~ 验证helm是否可以使用,只要有输出内容,说明输出正常
[root@k8s-master linux-amd64]# helm
### --- 配置helm仓库
~~~ 添加微软的仓库地址
[root@k8s-master linux-amd64]# helm repo add stable http://mirror.azure.cn/kubernetes/charts #仓库名称+仓库地址
"stable" has been added to your repositories
~~~ 查看仓库地址
[root@k8s-master linux-amd64]# helm repo list
NAME URL
stable http://mirror.azure.cn/kubernetes/charts
~~~ 添加aliyun的仓库地址
[root@k8s-master linux-amd64]# helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"aliyun" has been added to your repositories
[root@k8s-master linux-amd64]# helm repo list
NAME URL
stable http://mirror.azure.cn/kubernetes/charts
aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
~~~ 可以更新仓库包
[root@k8s-master linux-amd64]# helm repo update
~~~ 删除仓库源地址
[root@k8s-master linux-amd64]# helm repo remove aliyun
"aliyun" has been removed from your repositories
~~~ 查看仓库源后结构,只有微软的仓库源
[root@k8s-master linux-amd64]# helm repo list
stable http://mirror.azure.cn/kubernetes/charts
### --- 使用helm快速部署应用
~~~ # 第一步:使用命令搜索应用
~~~ 命令格式:helm search repo 名称 (weave)
[root@k8s-master ~]# helm search repo weave
NAME CHART VERSION APP VERSION DESCRIPTION
stable/weave-cloud 0.3.9 1.4.0 DEPRECATED - Weave Cloud is a add-on to Kuberne...
stable/weave-scope 1.1.12 1.12.0 DEPRECATED - A Helm chart for the Weave Scope c...
~~~ # 根据所索到的内容进行选择安装
~~~ 命令格式:helm install 安装之后名称 搜索之后应用的名称
[root@k8s-master ~]# helm install ui stable/weave-scope
NAME: ui
LAST DEPLOYED: Tue Feb 23 19:32:04 2021
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/
~~~ # 查看它的状态
~~~ 命令格式:helm list
~~~ 命令格式某个具体的:helm status 安装之后名称:
~~~ 查看安装状态
[root@k8s-master ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
ui default 1 2021-02-23 19:32:04.316266249 +0800 CST deployed weave-scope-1.1.12 1.12.0
~~~ 查看详细信息
[root@k8s-master ~]# helm status ui
NAME: ui
LAST DEPLOYED: Tue Feb 23 19:32:04 2021
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/
### --- 通过kubectl查看部署的应用
[root@k8s-master ~]# kubectl get pods
weave-scope-agent-ui-6cfhf 1/1 Running 0 3m13s
weave-scope-agent-ui-gfkbh 1/1 Running 0 3m13s
weave-scope-agent-ui-sjmrw 1/1 Running 0 3m13s
weave-scope-cluster-agent-ui-7498b8d4f4-ck66v 1/1 Running 0 3m13s
weave-scope-frontend-ui-649c7dcd5d-kxptj 1/1 Running 0 3m13s
~~~ 查看没有对外暴露端口
[root@k8s-master ~]# kubectl get svc
ui-weave-scope ClusterIP 10.98.111.244 <none> 80/TCP 4m2s
~~~ 修改对外暴露端口
[root@k8s-master ~]# kubectl edit svc ui-weave-scope
service/ui-weave-scope edited
spec:
clusterIP: 10.98.111.244
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app: weave-scope
component: frontend
release: ui
sessionAffinity: None
type: NodePort # 修改对外暴露端口
~~~ # 端口号暴露配置完成
[root@k8s-master ~]# kubectl get svc
ui-weave-scope NodePort 10.98.111.244 <none> 80:32212/TCP 6m35s