Skip to content

Commit f640769

Browse files
author
cleverhu
authored
Merge pull request #8 from cleverhu/optimize-helm-chart
optimize helm chart
2 parents 84aa0f9 + c4e882e commit f640769

File tree

8 files changed

+60
-20
lines changed

8 files changed

+60
-20
lines changed

.github/workflows/push-helm-chart.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ jobs:
1919
uses: actions/checkout@v2
2020
# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
2121
- name: Generate Chart Version
22-
run: echo CHART_VERSION=`git describe --tags --always| sed 's/^v//g'` >> $GITHUB_ENV
22+
run: |
23+
echo CHART_VERSION=`git describe --tags --always| sed 's/^v//g'` >> $GITHUB_ENV
24+
echo APP_VERSION=`git describe --tags --always` >> $GITHUB_ENV
2325
- name: Push chart to charts
2426
run: |
2527
helm plugin install https://github.com/chartmuseum/helm-push
2628
helm repo add ${{ env.APP_NAME }} ${{ secrets.REGISTRY }}
29+
sed -i 's/imageTag: ""/imageTag: '${{ env.APP_VERSION }}'/g' ./charts/values.yaml
2730
helm dep up ./charts
2831
helm package ./charts/ -d dist --version ${{ env.CHART_VERSION }}
2932
helm cm-push ./dist/${{ env.APP_NAME }}-${{ env.CHART_VERSION }}.tgz ${{ env.APP_NAME }} -a ${{ env.APP_VERSION }} -v ${{ env.CHART_VERSION }} -u ${{ secrets.REGISTRY_USER_NAME }} -p ${{ secrets.REGISTRY_PASSWORD }}

charts/.relok8s-images.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# controller
2-
- "{{ .controller.image.registry }}/{{ .controller.image.repository }}:{{ .controller.image.tag }}"
2+
- "{{ .controller.image.registry }}/{{ .controller.image.repository }}:{{ .global.controller.imageTag }}"
33

44
# cleanup
55
- "{{ .cleanup.image.registry }}/{{ .cleanup.image.repository }}:{{ .cleanup.image.tag }}"

charts/Chart.lock

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
dependencies:
2-
- name: common
3-
repository: https://charts.bitnami.com/bitnami
4-
version: 2.2.1
5-
digest: sha256:6c67cfa9945bf608209d4e2ca8f17079fca4770907c7902d984187ab5b21811e
6-
generated: "2022-12-02T16:25:03.611542+08:00"
1+
dependencies: []
2+
digest: sha256:643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726
3+
generated: "2022-12-16T11:08:15.527424+08:00"

charts/Chart.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ description: kubernetes-cronhpa-controller is a kubernetes cron horizontal pod a
44
any kind object defined in kubernetes which support scale subresource(such as Deployment
55
and StatefulSet).
66
apiVersion: v2
7-
appVersion: 1.3.0
7+
appVersion: 0.0.1
88
kubeVersion: ">=1.7.0-0"
99
keywords:
1010
- cronhpa
1111
- namespace:kube-system
1212
- releaseName:kubernetes-cronhpa-controller
1313
- category:autoscaling
1414
home: https://github.com/AliyunContainerService/kubernetes-cronhpa-controller
15-
dependencies:
16-
- name: common
17-
repository: https://charts.bitnami.com/bitnami
18-
tags:
19-
- bitnami-common
20-
version: 2.x.x
21-
version: 0.0.3
15+
dependencies: []
16+
version: 0.0.1

charts/charts/common-2.2.1.tgz

-14.5 KB
Binary file not shown.

charts/templates/_commons.tpl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Return the target Kubernetes version
5+
*/}}
6+
{{- define "common.capabilities.kubeVersion" -}}
7+
{{- if .Values.global }}
8+
{{- if .Values.global.kubeVersion }}
9+
{{- .Values.global.kubeVersion -}}
10+
{{- else }}
11+
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
12+
{{- end -}}
13+
{{- else }}
14+
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
15+
{{- end -}}
16+
{{- end -}}
17+
18+
{{/*
19+
Return the proper image name
20+
{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" $) }}
21+
*/}}
22+
{{- define "common.images.image" -}}
23+
{{- $registryName := .imageRoot.registry -}}
24+
{{- $repositoryName := .imageRoot.repository -}}
25+
{{- $tag := .imageRoot.tag | toString -}}
26+
{{- if .global }}
27+
{{- if .global.imageRegistry }}
28+
{{- $registryName = .global.imageRegistry -}}
29+
{{- end -}}
30+
{{- end -}}
31+
{{- if .tag }}
32+
{{- if .tag.imageTag }}
33+
{{- $tag = .tag.imageTag -}}
34+
{{- end -}}
35+
{{- end -}}
36+
{{- if $registryName }}
37+
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
38+
{{- else -}}
39+
{{- printf "%s:%s" $repositoryName $tag -}}
40+
{{- end -}}
41+
{{- end -}}

charts/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1212
Return the cronhpa image name
1313
*/}}
1414
{{- define "controller.image" -}}
15-
{{- include "common.images.image" (dict "imageRoot" .Values.controller.image "global" .Values.global) -}}
15+
{{- include "common.images.image" (dict "imageRoot" .Values.controller.image "global" .Values.global "tag" .Values.global.controller) -}}
1616
{{- end -}}
1717

1818
{{/*

charts/values.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ global:
66
## @param global.imageRegistry Global Docker image registry
77
##
88
imageRegistry: ""
9+
controller:
10+
## @param global.imageTag Global controller image tag
11+
##
12+
imageTag: ""
913
## Role Based Access
1014
## Ref: https://kubernetes.io/docs/admin/authorization/rbac/
1115
## @param global.rbac.create Create ClusterRole and ClusterRoleBinding
@@ -20,9 +24,9 @@ controller:
2024
## @param controller.image.pullPolicy Controller image pull policy
2125
##
2226
image:
23-
registry: ghcr.io
27+
registry: ghcr.m.daocloud.io
2428
repository: daocloud/kubernetes-cronhpa-controller
25-
tag: "v1.3.0"
29+
tag: ""
2630
pullPolicy: IfNotPresent
2731

2832
## @param controller.timezone Timezone in controller pod
@@ -49,7 +53,7 @@ cleanup:
4953
## @param cleanup.image.pullPolicy Cleanup job image pull policy
5054
##
5155
image:
52-
registry: ghcr.io
56+
registry: ghcr.m.daocloud.io
5357
repository: cloudtty/cloudshell
5458
tag: "v0.5.0"
5559
pullPolicy: IfNotPresent

0 commit comments

Comments
 (0)