helm安装使用
Install helm
官方安装指导请参考:https://helm.sh/docs/intro/install/
- From the Binary Releases
- Download your desired version 地址:https://github.com/helm/helm/releases
- Unpack it (tar -zxvf helm-v3.0.0-linux-amd64.tar.gz)
- move it to its desired destination (mv /usr/local/bin/helm)
- helm version 查看版本
- .sh
- curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
- chmod 700 get_helm.sh
- ./get_helm.sh
- helm version 查看版本
- From Source
You must have a working Go environment.
- $ git clone https://github.com/helm/helm.git
- $ cd helm
- $ make
- helm version 查看版本
Using Helm
官方使用参考:https://helm.sh/docs/topics/charts/
- $ helm create test
- 修改相关文件
官方文档解析:https://helm.sh/docs/topics/charts/
chart.yaml
appVersion: 4.3.3
description: qloudobpquickstartstest .
engine: gotpl
home: http://www.qloudpaas.com
icon: http://mart.csftgroup.com:30024/images/icon/qloudmonitor.jpg
keywords:
- qloudobpquickstartstest
maintainers:
- email: sre@gcstgroup.com
name: sre
name: qloudobpquickstartstest
sources:
- http://www.qloudpaas.com
version: 0.0.1
value.yaml
#【----------------全局变量--------------------】
global:
# # 镜像仓库名称
imageRepositoryName: reg.qloudhub.com
#【----------------镜像配置--------------------】
# 镜像
imageRepository: qloudobp/qloudobpquickstartstest
#版本要求3位数,不写默认从.Chart.appVersion拿
#imageTag: 5.6.10
# 拉取镜像策略
imagePullPolicy: Always
#容器启动命令和参数
containersCommand: {}
containersArgs: {}
#【----------------服务配置--------------------】
#是否启动服务
serviceEnabled: true
# 服务映射端口类型ClusterIP、NodePort
serviceType: ClusterIP
# 服务
serviceName: qloudobpquickstartstest
servicePorts:
# 容器内端口
- port: 8888
protocol: "TCP"
#【----------------部署配置--------------------】
# 部署实例个数
deploymentReplicas: 1
deploymentPorts:
# 容器内端口,protocol协议不写,默认TCP
- containerPort: 8888
protocol: "TCP"
#【----------------环境变量--------------------】
#当env的某个环境变量需要加密处理时,需要在下面的envsecret配置,不用再env中配置了
env:
DISCOVERY_INGRESS: "qloudkernel.service.sd"
DISCOVERY_CLUSTER: "qloudkernel.default"
SERVICE_INGRESS: "qloudobpquickstartstest.service.sd"
SERVICE_NAME: "qloudobpquickstartstest"
SERVER_OPTS: "-Xms512M -Xmx512M"
#通用环境变量,key=SERVICE_CLUSTER,value由服务名+命名空间组成
envcommon: SERVICE_CLUSTER
#【----------------secret配置--------------------】
#1、目前只支持生成一个secret
#是否使用secret,false为不使用,envname为环境变量名字
envsecretEnabled: false
#【----------------设置容器是否运行在特权模式--------------------】
#仅应用到指定的容器
securityContext: false
#【----------------持久卷--------------------】
# Persistent Volume Storage Class
#1、pvc配置,主要配置pv的名称(和创建的pv名字相同)
#2、pvc名字自动生成,为服务名-name
#是否已经存在pvc,存在则不创建,configMap不需要生成pvc
persistenceExistingClaim: false
#是否使用持久卷,false为不使用
persistenceEnabled: false
persistenceAnnotations:
volume.beta.kubernetes.io/storage-class: sas
volume.beta.kubernetes.io/storage-provisioner: flexvolume-huawei.com/fuxivol
persistenceLabels:
failure-domain.beta.kubernetes.io/region: cn-north-1
failure-domain.beta.kubernetes.io/zone: cn-north-1a
#挂载卷时需要配置,mountPath为pod容器中的目录,type为存储类型:secret、gluster、configMap
#1、注意此处如果type是configMap,配置的name名字要和下方的configMap一样
#2、增加items代表一个configMap对应对个配置文件并且可以设置权限,如果不需要可以不加此项
volumeMounts:
- name: data1
mountPath: ""
volume:
- name: data1
type: gluster
volumeSize: Gi
accessModes: ReadWriteMany
#【----------------暴露http服务的方式:ingress----在service 之前加了一层ingress----------------】
ingressEnabled: true
ingressAddns: true
#ingress对应的端口
ingressHosts:
- host: qloudobpquickstartstest
domain: service.sd
paths:
- path:
servicePort: 8888
#【-----------------请求资源限制-------------------】
resourcesRequestsCpu: 0.5
resourcesRequestsMemory: 0.5Gi
resourcesLimitsCpu: 1
resourcesLimitsMemory: 1Gi
nodeSelector: {}
#【-----------------初始化容器-------------------】
#此服务是否需要依赖其他服务,如果是的话,需要配置enabled:true,且需要配置image、command:command为相应的等待命令,image为init容器镜像
#默认等待同一命名空间的服务
initContainersEnabled: false
# initContainersImage: "qloudpaas/alpine-curl-jq:1.0.0"
# initContainersCommand: "until (nc -w 3 qloudkernel:8888 -z) ;do sleep 120; done"
#【-----------------健康检查 K8S提供livenessProbe来检测应用程序是否正常运行,并且对相应状况进行相应的补救措施-------------------】
#此处保留原来的样式,易读性更佳
livenessProbe:
enabled: false
#在没有配置readinessProbe的资源对象中,pod中的容器启动完成后,就认为pod中的应用程序可以对外提供服务,有时一些应用程序启动后,需要较长时间的加载才能对外服务
readinessProbe:
enabled: false
- $ helm package test
- 上传charts管理服务器 :
curl -v --data-binary "@test-0.0.1.tgz" http://192.168.2.20:8080/api/charts