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

The usage of charts and the creation of Repo Warehouse

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Develop your own chare package [root@master ~]# helm create mychare//Create a chare package named mychare [root@master ~]# tree -C mychare//View the chare package mychare/$> ─ ─ charts <$── Chart.yaml <$── templates ├── deployment.yaml│ ├── _helpers.tpl│ ├── ingress.yaml│ ├── NOTES.txt│ ├── service.yaml│ └── tests│ ── test-connection.yaml

[root@master mychare]# helm install stable/redis//安装(2)通过tar包安装[root@master ~]# helm fetch stable/redis//直接下载chare包[root@master ~]# tar -zxf redis-1.1.15.tgz//解压下载的chare包[root@master ~]# tree -C redisredis├── Chart.yaml├── README.md├── templates│ ├── deployment.yaml│ ├── _helpers.tpl│ ├── networkpolicy.yaml│ ├── NOTES.txt│ ├── pvc.yaml│ ├── secrets.yaml│ └── svc.yaml└── values.yaml(3)通过chare本地目录安装[root@master ~]# helm fetch stable/redis//直接下载chare包[root@master ~]# tar -zxf redis-1.1.15.tgz//解压下载的chare包[root@master ~]# helm install redis(4)通过URL安装[root@master ~]# helm install https://example.com/charts/foo-1.2.3.tgz创建自己的Repo仓库1)创建helm的私有仓库,以自己的名字命名。1、node01启动一个httpd的容器[root@node01 ~]# mkdir /var/xgp//创建一个目录[root@node01 ~]# docker pull httpd//下载httpd镜像[root@node02 ~]# docker run -d -p 8080:80 -v /var/xgp:/usr/local/apache2/htdocs httpd//启动一个httpd的容器3、生成仓库的index文件。[root@master ~]# mkdir xgprepo//创建一个目录存放打包的chare[root@master ~]# helm repo index xgprepo/ --url http://192.168.1.22:8080/charts//生成仓库的index文件4、将生成的index.yaml上传到node01的/var/www/charts目录下.node01创建目录[root@node01 ~]# mkdir /var/xgp/chartsmaster移动动到[root@master ~]# scp xgprepo/* node01:/var/xgp/charts/node01查看一下[root@node01 ~]# ls /var/xgp/charts/index.yaml 5、添加新的repo仓库[root@master ~]# helm repo add xgp http://192.168.1.22:8080/charts[root@master ~]# helm repo list

2) 自定义一个chart包,要求这个包运行一个httpd的服务,使用私有镜像v1版本。3个副本Pod,service类型更改为NodePort,端口指定为:30000自定义一个chart包[root@master ~]# helm create wsd//创建一个名为wsd的chares包按照要求修改配置文件[root@master ~]# cd wsd///进入这个chart包[root@master wsd]# vim values.yaml//修改wsd的配置文件replicaCount: 3 #三个副本image: repository: 192.168.1.21:5000/web #更改镜像为私有镜像 tag: v1 #镜像标签v1 pullPolicy: IfNotPresent imagePullSecrets: []nameOverride: ""fullnameOverride: ""service: type: NodePort #修改模式为映射端口 port: 80 nodePort: 30000 #添加端口[root@master wsd]# vim templates/service.yaml apiVersion: v1kind: Servicemetadata: name: {{ include "wsd.fullname" . }} labels:{{ include "wsd.labels" . | indent 4 }}spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} targetPort: http protocol: TCP name: http nodePort: {{ .Values.service.nodePort }} #"添加"能让服务识别到nodePort的端口 selector: app.kubernetes.io/name: {{ include "wsd.name" . }} app.kubernetes.io/instance: {{ .Release.Name }}测试一下[root@master ~]# helm install -n wsd wsd/ -f wsd/values.yaml

[root@master ~]# kubectl get deployments. -o wide

Visit [root@master ~]# curl 127.0.0.1:30000

3)Update instances to require mirroring of production v2 versions.

Private image upgrade is different from official image upgrade. For official image upgrade, you only need to change the label by (helm upgrade --set imageTag="label" service name charts package name), while private image upgrade is more troublesome by changing the label in values.yaml.

1. Modify values.yaml[root@master ~]# vim wsd/values.yaml # Default values for wsd.# This is a YAML-formatted file.# Declare variables to be passed into your templates.replicaCount: 3image: repository: 192.168.1.21:5000/web tag: v2 #modify the label to v2 pullPolicy: IfNotPresent[root@master ~]# helm upgrade wsd wsd/ -f wsd/values.yaml//refresh wsd service based on configuration file View [root@master ~]# kubectl get deployments. -o wide

Visit [root@master ~]# curl 127.0.0.1:30000

2. Use edit to update the version

Make sure wsd this service is enabled

[root@master ~]# kubectl edit deployments. wsd

Check out [root@master ~]# kubectl get deployments. -o wide

Visit [root@master ~]# curl 127.0.0.1:30000

4) Redefine a chart package named new-test, upload this package to the private repository above, and update the local index file with helm repo update command. [root@master ~]# helm repo list

[root@master ~]# helm create xgp-wsd//Create a charts package named xgp-wsd [root@master ~]# helm package xgp-wsd//Package xgp-wsd in the current directory [root@master ~]# mv xgp-wsd-@.1.0.tgz xgprepo///Put the package file in the repository directory [root@master ~]# helm repo index xgprepo/ --url http://192.168.1.22:8080/charts//Record the newly added charts package information in the repository directory in index.yaml, so that other hosts can recognize the charts package of the repository [root@master ~]# scp xgprepo/* node01:/var/xgp/charts//Move the files in the repository directory to httpd service so that each host can access them, download the charts package of the repository [root@master ~]# helm repo update //Update the chart repository [root@master myrepo]# helm install http://192.168.1.22:8080/charts/xgp-wsd-0.1.0.tgz//Create a service based on the xgp-wsd-0.1.0.tgz package of the repository View [root@master ~]# helm search xgp-wsd

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