参考
常规操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| helm create mychart
helm install full-coral ./mychart
helm get manifest full-coral
helm install clunky-serval ./mychart --namespace mynamespace
helm install --debug --dry-run goodly-guppy ./mychart helm install solid-vulture ./mychart --dry-run --debug --set favoriteDrink=slurm
|
使用HarborHelm仓库
https://juejin.cn/post/6844903795827146759
1 2 3 4 5 6 7 8 9
| helm plugin install https://github.com/chartmuseum/helm-push
helm repo add dubhe http://harbor.dubhe:30002/chartrepo/dubhe helm repo update
helm cm-push ./gogs.tgz dubhe --username admin --password yourpass
|
简易脚手架
Chart.yaml
1 2 3 4 5 6
| apiVersion: v2 name: mysql description: Dubhe MySQL Helm Chart for Kubernetes type: application version: 1.0.0 appVersion: "5.7.42-debian"
|
values.yaml
1 2 3 4 5 6 7
| mysql: repository: mysql tag: 5.7.42-debian imagePullPolicy: Always storageClassName: longhorn-retain storageSize: 20Gi nodePort: 30353
|
templates/deployment.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| apiVersion: apps/v1 kind: Deployment metadata: name: mysql labels: app: mysql spec: selector: matchLabels: app: mysql strategy: type: Recreate template: metadata: labels: app: mysql spec: containers: - name: mysql image: "{{ .Values.mysql.repository }}:{{ .Values.mysql.tag }}" imagePullPolicy: {{ .Values.mysql.imagePullPolicy }} env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: dubhe-secret key: mysql-password ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql - name: mysql-config mountPath: /etc/mysql/mysql.conf.d/mysqld.cnf subPath: mysqld.cnf volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: mysql - name: mysql-config configMap: name: mysql-configmap items: - key: mysql-conf path: mysqld.cnf
|
templates/configmap.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| apiVersion: v1 kind: ConfigMap metadata: name: mysql-configmap data: mysql-conf: | [mysqld] server_id = 1 log-bin = mysql-bin pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql symbolic-links=0 lower_case_table_names=1 sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8 group_concat_max_len=102400 max_connections=2000 max_allowed_packet=524288000 default-time-zone='+08:00' ignore-db-dir=lost+found
|
templates/pvc.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13
| apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql spec: accessModes: - ReadWriteOnce {{- if not ( empty .Values.mysql.storageClassName ) }} storageClassName: {{ .Values.mysql.storageClassName }} {{- end }} resources: requests: storage: {{ .Values.mysql.storageSize }}
|
templates/service.yaml
1 2 3 4 5 6 7 8 9 10 11
| apiVersion: v1 kind: Service metadata: name: mysql spec: selector: app: mysql ports: - protocol: TCP port: 3306 clusterIP: None
|
templates/service-exposed.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| apiVersion: v1 kind: Service metadata: name: mysql-exposed spec: selector: app: mysql ports: - protocol: TCP port: 3306 targetPort: 3306 {{- if not ( empty .Values.mysql.nodePort ) }} nodePort: {{ .Values.mysql.nodePort }} {{- end }} type: NodePort
|