我是靠谱客的博主 酷酷飞机,最近开发中收集的这篇文章主要介绍K8s(17)——kubernetes之kubernetes资源监控-Helm包管理工具2(部署metrices-server,部署kubeapps(webUI))1、构建一个Helm Chart2、把打包好的helm包上传仓库3、部署metrices-server4、部署kubeapps(webUI),觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
文章目录
- 1、构建一个Helm Chart
- 2、把打包好的helm包上传仓库
- 2.1 配置仓库
- 2.2 仓库拉取helm
- 2.3 增加v2版本(ingress)
- 2.4 回滚更新
- 3、部署metrices-server
- 3.1 拉取metrics-server包,修改values.yaml文件
- 3.2 拉取镜像
- 3.3 清理之前的metrices环境
- 3.4 安装
- 3.5 修改corndns
- 4、部署kubeapps(webUI)
- 4.1 拉取kubeapps包,修改values.yaml文件
- 4.2 下载所需镜像并上传仓库
- 4.3 安装kubeapps,授权,获取密钥登陆web后台
1、构建一个Helm Chart
检查依赖和模板配置是否正确
[root@server2 helm]# helm lint mychart #检查依赖和模板配置是否正确
==> Linting mychart
Error unable to check Chart.yaml file in chart: stat mychart/Chart.yaml: no such file or directory
Error: 1 chart(s) linted, 1 chart(s) failed
创建 mychart
[root@server2 helm]# helm create mychart
Creating mychart
[root@server2 helm]# tree mychart/
-bash: tree: command not found
[root@server2 helm]# yum install -y tree
[root@server2 helm]# tree mychart/
mychart/
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── serviceaccount.yaml
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
编辑清单文件
[root@server2 mychart]# vim Chart.yaml
[root@server2 mychart]# vim values.yaml
[root@server2 ~]# cd helm/
[root@server2 helm]# helm lint mychart/ ##检查语法错误
==> Linting mychart/
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
[root@server2 helm]# helm package mychart/ ##打包
Successfully packaged chart and saved it to: /root/helm/mychart-0.1.0.tgz
helm install demo mychart-0.1.0.tgz ## 安装
helm upgrade demo mychart-0.1.0.tgz --set replicaCount=2
vim Chart.yaml
vim values.yaml
打包
安装
查看信息
2、把打包好的helm包上传仓库
2.1 配置仓库
安装push包
[root@server2 ~]# mkdir -p /root/.local/share/helm/plugins
[root@server2 ~]# cd /root/.local/share/helm/plugins
[root@server2 plugins]# mkdir push
[root@server2 plugins]# cd push/
[root@server2 push]# cd
[root@server2 ~]# tar zxf helm-push_0.9.0_linux_amd64.tar.gz -C /root/.local/share/helm/plugins/push/
查看push帮助
[root@server2 ~]# helm push --help
把加密证书放到全局生效目录下并更新
[root@server2 ~]# cp /etc/docker/certs.d/reg.westos.org/ca.crt /etc/pki/ca-trust/source/anchors/
[root@server2 ~]# update-ca-trust
查看是否添加仓库成功
[root@server2 helm]# helm repo add westos https://reg.westos.org/chartrepo/charts
[root@server2 helm]# helm repo list
NAME URL
bitnami https://charts.bitnami.com/bitnami
westos https://reg.westos.org/chartrepo/charts
上传至仓库
[root@server2 helm]# helm push mychart-0.1.0.tgz westos --insecure -u admin -p Harbor12345
Pushing mychart-0.1.0.tgz to westos...
Done.
2.2 仓库拉取helm
[root@server2 ~]# helm install demo westos/mychart --set replicaCount=3
NAME: demo
LAST DEPLOYED: Fri Mar 5 10:40:15 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=mychart,app.kubernetes.io/instance=demo" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
测试负载均衡:
2.3 增加v2版本(ingress)
[root@server2 mychart]# pwd
/root/helm/mychart
[root@server2 mychart]# vim values.yaml
[root@server2 mychart]# vim Chart.yaml
[root@server2 helm]# helm package mychart
Successfully packaged chart and saved it to: /root/helm/mychart-0.2.0.tgz
[root@server2 helm]# helm push mychart-0.2.0.tgz westos --insecure -u admin -p Harbor12345
Pushing mychart-0.2.0.tgz to westos...
Done.
[root@server2 helm]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "westos" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@server2 helm]# helm search repo mychart -l
NAME CHART VERSION APP VERSION DESCRIPTION
westos/mychart 0.2.0 v2 A Helm chart for Kubernetes
westos/mychart 0.1.0 v1 A Helm chart for Kubernetes
[root@server2 helm]# helm upgrade demo westos/mychart
W0305 10:58:52.982744 19349 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
W0305 10:58:53.053866 19349 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
W0305 10:58:53.113347 19349 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Release "demo" has been upgraded. Happy Helming!
NAME: demo
LAST DEPLOYED: Fri Mar 5 10:58:52 2021
NAMESPACE: default
STATUS: deployed
REVISION: 2
NOTES:
1. Get the application URL by running these commands:
http://demo.westos.org/
kubectl -n ingress-nginx get all ## 查看ingress对应的nodeIP
vim values.yaml
vim Chart.yaml
查看ingress对应的nodeIP
测试:
2.4 回滚更新
[root@server2 helm]# helm history demo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Mar 5 10:42:08 2021 superseded mychart-0.1.0 v1 Install complete
2 Fri Mar 5 10:58:52 2021 deployed mychart-0.2.0 v2 Upgrade complete
[root@server2 helm]# helm rollback demo 1
W0305 11:58:54.397943 2642 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
W0305 11:58:54.403883 2642 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Rollback was a success! Happy Helming!
3、部署metrices-server
1.拉取metrics-server包,修改values.yaml文件
[root@server2 helm]# helm pull bitnami/metrics-server
[root@server2 helm]# tar zxf metrics-server-5.6.0.tgz
[root@server2 helm]# ls
helm-v3.4.1-linux-amd64.tar.gz metrics-server-5.6.0.tgz mychart-0.2.0.tgz
linux-amd64 mychart redis-ha
metrics-server mychart-0.1.0.tgz redis-ha-4.12.9.tgz
[root@server2 helm]# cd metrics-server/
[root@server2 metrics-server]# ls
Chart.lock charts Chart.yaml ci README.md templates values.yaml
[root@server2 kubeapps]# vim values.yaml ##修改values.yaml文件
2. 拉取镜像
[root@server1 harbor]# docker pull bitnami/metrics-server:0.4.2-debian-10-r0
[root@server1 harbor]# docker tag bitnami/metrics-server:0.4.2-debian-10-r0 reg.westos.org/bitnami/metrics-server:0.4.2-debian-10-r0
[root@server1 harbor]# docker push reg.westos.org/bitnami/metrics-server:0.4.2-debian-10-r0
3. 清理之前的metrices环境
[root@server2 metrics-server]# cd
[root@server2 ~]# cd metric-server/
[root@server2 metric-server]# ls
components.yaml
[root@server2 metric-server]# kubectl delete -f components.yaml
serviceaccount "metrics-server" deleted
clusterrole.rbac.authorization.k8s.io "system:aggregated-metrics-reader" deleted
clusterrole.rbac.authorization.k8s.io "system:metrics-server" deleted
rolebinding.rbac.authorization.k8s.io "metrics-server-auth-reader" deleted
clusterrolebinding.rbac.authorization.k8s.io "metrics-server:system:auth-delegator" deleted
clusterrolebinding.rbac.authorization.k8s.io "system:metrics-server" deleted
service "metrics-server" deleted
deployment.apps "metrics-server" deleted
apiservice.apiregistration.k8s.io "v1beta1.metrics.k8s.io" deleted
4. 安装
[root@server2 metric-server]# kubectl create namespace metrics-server
namespace/metrics-server created
[root@server2 metrics-server]# helm install metrics-server . -n metrics-server
## 此时pod起不来,原因是无法解析节点
5.修改corndns
[root@server2 metrics-server]# kubectl -n kube-system edit cm coredns
configmap/coredns edited
[root@server2 metrics-server]# kubectl -n kube-system get pod | grep coredns | awk "[root@server2 metrics-server]# kubectl -n kube-s[r[r[r[r[root@server2 metrics-server]# kubectl -n kube-system get pod | grep coredns | awk '{system("kubectl -n kube-system delete pod "$1"")}'
pod "coredns-7f89b7bc75-ddlmc" deleted
pod "coredns-7f89b7bc75-f5dww" deleted
6. pod成功起来
[root@server2 metrics-server]# kubectl -n metrics-server get pod
NAME READY STATUS RESTARTS AGE
metrics-server-777f7bd69b-pc6lf 1/1 Running 7 10m
3.1 拉取metrics-server包,修改values.yaml文件
3.2 拉取镜像
3.3 清理之前的metrices环境
3.4 安装
3.5 修改corndns
4、部署kubeapps(webUI)
1.拉取kubeapps包,修改values.yaml文件
[root@server2 helm]# helm pull bitnami/kubeapps
[root@server2 helm]# tar zxf kubeapps-5.2.2.tgz
[root@server2 helm]# cd kubeapps/
[root@server2 kubeapps]# ls
Chart.lock Chart.yaml README.md values.schema.json
charts crds templates values.yaml
[root@server2 kubeapps]# vim values.yaml
2.下载所需镜像并上传仓库
[root@server1 ~]# docker load -i kubeapps-2.2.1.tar
[root@server1 ~]# docker images | grep reg.westos.org/bitnami | awk '{system("docker push "$1":"$2"")}'
## 上传
3.安装kubeapps
[root@server2 kubeapps]# helm install kubeapps . -n kubeapps
4.授权
[root@server2 kubeapps]# kubectl create serviceaccount kubeapps-operator -n kubeapps
[root@server2 kubeapps]# kubectl create clusterrolebinding kubeapps-operator --clusterrole=cluster-admin --serviceaccount=kubeapps:kubeapps-operator
5.获取token密钥登陆
[root@server2 kubeapps]# kubectl -n kubeapps get sa
[root@server2 kubeapps]# kubectl -n kubeapps describe sa kubeapps-operator
[root@server2 kubeapps]# kubectl -n kubeapps describe secrets
[root@server2 kubeapps]# kubectl -n kubeapps describe secrets kubeapps-operator-token-2lds6
4.1 拉取kubeapps包,修改values.yaml文件
4.2 下载所需镜像并上传仓库
4.3 安装kubeapps,授权,获取密钥登陆web后台
安装后使用token登陆,浏览器用域名登陆(要给真机做解析)
最后
以上就是酷酷飞机为你收集整理的K8s(17)——kubernetes之kubernetes资源监控-Helm包管理工具2(部署metrices-server,部署kubeapps(webUI))1、构建一个Helm Chart2、把打包好的helm包上传仓库3、部署metrices-server4、部署kubeapps(webUI)的全部内容,希望文章能够帮你解决K8s(17)——kubernetes之kubernetes资源监控-Helm包管理工具2(部署metrices-server,部署kubeapps(webUI))1、构建一个Helm Chart2、把打包好的helm包上传仓库3、部署metrices-server4、部署kubeapps(webUI)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复