Skip to content

Commit 7ad9a91

Browse files
committed
feat: remove Helm 2 support and upgrade to Helm 3.19.0
Changes: - Remove Helm 2 binary installation and initialization from Dockerfile - Upgrade Helm 3 from v3.13.3 to v3.19.0 - Upgrade Alpine base image from 3.22.0 to 3.22.2 - Create symlink from 'helm' to 'helm3' for backward compatibility - Update helm-release-plugin to latest version (438a761) - Remove all Helm 2 compatibility code from index.js: - Simplify deleteCmd() to only support Helm 3 syntax - Remove conditional checks for helm === 'helm3' - Always set Helm 3 environment variables (XDG_*) - Modernize Kubernetes API usage: - Update Ingress from deprecated extensions/v1beta1 to networking.k8s.io/v1 - Add pathType: Prefix and update backend format for Ingress resources - Update test suite for Helm 3: - Remove Helm 2 version test from CI workflow - Update helm template command to use Helm 3 syntax (positional args) - Regenerate test expectations with Helm 3 output format - Update documentation: - Remove Helm 2 version references - Update helm parameter description to reflect Helm 3-only support - Update TTL parameter docs (remove 'only works with helm3' note) - Update version to v3.19.0 - Bump Docker image tag from v3 to v4 in production workflow
1 parent 53c0d76 commit 7ad9a91

File tree

9 files changed

+74
-106
lines changed

9 files changed

+74
-106
lines changed

.github/workflows/publish-docker-prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
- name: Build
3131
run: |-
3232
docker build \
33-
--tag "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:${{ github.sha }}" --tag "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:v3" .
33+
--tag "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:${{ github.sha }}" --tag "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:v4" .
3434
3535
# Push the Docker image to Google Container Registry
3636
- name: Publish
3737
run: |-
3838
docker push "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:${{ github.sha }}"
39-
docker push "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:v3"
39+
docker push "europe-docker.pkg.dev/unicorn-985/public-images/helm-action:v4"

.github/workflows/test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,4 @@ jobs:
1919
run: 'docker run --rm -i -v $PWD:/workspace --workdir=/workspace --entrypoint=/workspace/tests/charts/test.sh helm'
2020

2121
- name: 'Test helm version'
22-
run: 'docker run --rm -i --entrypoint=helm helm version -c'
23-
24-
- name: 'Test helm3 version'
25-
run: 'docker run --rm -i --entrypoint=helm3 helm version'
22+
run: 'docker run --rm -i --entrypoint=helm helm version'

Dockerfile

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
FROM alpine:3.22.0
1+
FROM alpine:3.22.2
22

33
ENV BASE_URL="https://get.helm.sh"
44

5-
ENV HELM_2_FILE="helm-v2.15.2-linux-amd64.tar.gz"
6-
ENV HELM_3_FILE="helm-v3.13.3-linux-amd64.tar.gz"
5+
ENV HELM_3_FILE="helm-v3.19.0-linux-amd64.tar.gz"
76

8-
# coreutils is needed helm3 ttl plugin
9-
# git is needed to install a helm3 plugin
7+
# coreutils is needed for helm ttl plugin
8+
# git is needed to install helm plugins
109
# python3 needed by gcloud
1110
RUN apk add --no-cache ca-certificates \
1211
--repository http://dl-3.alpinelinux.org/alpine/edge/community/ \
1312
jq curl bash nodejs python3 git coreutils && \
14-
# Install helm version 2:
15-
curl -L ${BASE_URL}/${HELM_2_FILE} |tar xvz && \
13+
# Install Helm 3
14+
curl -L ${BASE_URL}/${HELM_3_FILE} |tar xvz && \
1615
mv linux-amd64/helm /usr/bin/helm && \
1716
chmod +x /usr/bin/helm && \
1817
rm -rf linux-amd64 && \
19-
# Install helm version 3:
20-
curl -L ${BASE_URL}/${HELM_3_FILE} |tar xvz && \
21-
mv linux-amd64/helm /usr/bin/helm3 && \
22-
chmod +x /usr/bin/helm3 && \
23-
rm -rf linux-amd64 && \
24-
# Init version 2 helm:
25-
helm init --client-only --stable-repo-url https://charts.helm.sh/stable && \
26-
# Install helm3 ttl plugin for temporary pr deploys \
27-
helm3 plugin install https://github.com/gynzy/helm-release-plugin --version 06e297a76878eec0a54c45e1877dc981b665b621
18+
# Install helm ttl plugin for temporary pr deploys
19+
helm plugin install https://github.com/gynzy/helm-release-plugin --version 438a761e7ec825ead9d181e81ade9a2650b7d5c4
2820

2921
# Install google gcloud sdk
3022
RUN curl -sSL https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash | PREFIX=/opt/ bash && \
@@ -35,8 +27,8 @@ RUN curl -sSL https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cl
3527
ln -s /opt/google-cloud-sdk/bin/gcloud /usr/lib/google-cloud-sdk/bin/gcloud && \
3628
ln -s /opt/google-cloud-sdk/bin/kubectl /usr/lib/google-cloud-sdk/bin/kubectl
3729

38-
ENV PYTHONPATH "/usr/lib/python3.8/site-packages/"
39-
ENV PATH $PATH:/opt/google-cloud-sdk/bin
30+
ENV PYTHONPATH="/usr/lib/python3.8/site-packages/"
31+
ENV PATH=$PATH:/opt/google-cloud-sdk/bin
4032

4133
COPY . /usr/src/
4234
ENTRYPOINT ["node", "/usr/src/index.js"]

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Gynzy `additions
22
Fork from https://github.com/deliverybot/helm
33

4-
Uses "our" helm version of helm 2.15.2
5-
64
Releasing: The `v1` tag gets updated on **master merge**!
75

86

@@ -46,21 +44,20 @@ payload if the action was triggered by a deployment.
4644
JSON encoded array or a string.
4745
- `secrets`: Secret variables to include in value file interpolation. Expects a
4846
JSON encoded map.
49-
- `helm`: Helm binary to execute, one of: [`helm`, `helm3`].
47+
- `helm`: Helm binary to execute (defaults to `helm`, which uses Helm 3).
5048
- `version`: Version of the app, usually commit sha works here.
5149
- `timeout`: specify a timeout for helm deployment
5250
- `repository`: specify the URL for a helm repo to come from
5351
- `atomic`: If true, upgrade process rolls back changes made in case of failed upgrade. Defaults to true.
54-
- `ttl`: Optional ttl which can be set until the deployment will be deleted. For example `7 days`. Only works with helm3 and `release` *must* contain the string `-pr-`
52+
- `ttl`: Optional ttl which can be set until the deployment will be deleted. For example `7 days`. The `release` *must* contain the string `-pr-`
5553

5654
Additional parameters: If the action is being triggered by a deployment event
5755
and the `task` parameter in the deployment event is set to `"remove"` then this
5856
action will execute a `helm delete $service`
5957

6058
#### Versions
6159

62-
- `helm`: v2.16.1
63-
- `helm3`: v3.0.0
60+
- `helm`: v3.19.0 (Helm 3)
6461

6562
### Environment
6663

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ inputs:
2828
description: If true, upgrade process rolls back changes made in case of failed upgrade. Defaults to true.
2929
required: false
3030
helm:
31-
description: Helm binary to execute, one of [helm, helm3].
31+
description: Helm binary to execute (defaults to helm, which uses Helm 3).
3232
required: false
3333
token:
3434
description: Github repository token. If included and the event is a deployment

charts/app/templates/ingress.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- if .Values.ingress.enabled -}}
22
{{- $fullName := include "app.fullname" . -}}
3-
apiVersion: extensions/v1beta1
3+
apiVersion: networking.k8s.io/v1
44
kind: Ingress
55
metadata:
66
name: {{ $fullName }}
@@ -29,9 +29,12 @@ spec:
2929
paths:
3030
{{- range .paths }}
3131
- path: {{ . }}
32+
pathType: Prefix
3233
backend:
33-
serviceName: {{ $fullName }}
34-
servicePort: http
34+
service:
35+
name: {{ $fullName }}
36+
port:
37+
name: http
3538
{{- end }}
3639
{{- end }}
3740
{{- end }}

index.js

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,13 @@ function renderFiles(files, data) {
135135
}
136136

137137
/**
138-
* Makes a delete command for compatibility between helm 2 and 3.
138+
* Makes a delete command for helm.
139139
*
140-
* @param {string} helm
141140
* @param {string} namespace
142141
* @param {string} release
143142
*/
144-
function deleteCmd(helm, namespace, release) {
145-
if (helm === "helm3") {
146-
return ["delete", "-n", namespace, release];
147-
}
148-
return ["delete", "--purge", release];
143+
function deleteCmd(namespace, release) {
144+
return ["delete", "-n", namespace, release];
149145
}
150146

151147
async function setupClusterAuthentication(project, location, name, sa_json) {
@@ -248,7 +244,7 @@ async function run() {
248244
core.debug(`param: fetchDepencencies = "${fetchDependencies}"`);
249245

250246
// Assert that if ttl is set that release contains '-pr-'
251-
if (helm === "helm3" && ttl !== "false") {
247+
if (ttl !== "false") {
252248
if (!release.includes("-pr-")) {
253249
core.error(
254250
"ttl is set but release name does not contain '-pr-'. Aborting!"
@@ -275,17 +271,13 @@ async function run() {
275271
];
276272

277273
// Per https://helm.sh/docs/faq/#xdg-base-directory-support
278-
if (helm === "helm3") {
279-
process.env.XDG_DATA_HOME = "/root/.helm/";
280-
process.env.XDG_CACHE_HOME = "/root/.helm/";
281-
process.env.XDG_CONFIG_HOME = "/root/.helm/";
282-
process.env.HELM_PLUGINS = "/root/.local/share/helm/plugins";
283-
process.env.HELM_DATA_HOME = "/root/.local/share/helm";
284-
process.env.HELM_CACHE_HOME = "/root/.cache/helm";
285-
process.env.HELM_CONFIG_HOME = "/root/.config/helm";
286-
} else {
287-
process.env.HELM_HOME = "/root/.helm/";
288-
}
274+
process.env.XDG_DATA_HOME = "/root/.helm/";
275+
process.env.XDG_CACHE_HOME = "/root/.helm/";
276+
process.env.XDG_CONFIG_HOME = "/root/.helm/";
277+
process.env.HELM_PLUGINS = "/root/.local/share/helm/plugins";
278+
process.env.HELM_DATA_HOME = "/root/.local/share/helm";
279+
process.env.HELM_CACHE_HOME = "/root/.cache/helm";
280+
process.env.HELM_CONFIG_HOME = "/root/.config/helm";
289281

290282
if (dryRun) args.push("--dry-run");
291283
if (appName) args.push(`--set=app.name=${appName}`);
@@ -333,31 +325,29 @@ async function run() {
333325
// Remove the canary deployment before continuing.
334326
if (removeCanary) {
335327
core.debug(`removing canary ${appName}-canary`);
336-
await exec.exec(helm, deleteCmd(helm, namespace, `${appName}-canary`), {
328+
await exec.exec(helm, deleteCmd(namespace, `${appName}-canary`), {
337329
ignoreReturnCode: true,
338330
});
339331
}
340332

341333
// Actually execute the deployment here.
342334
if (task === "remove") {
343-
if (helm === "helm3") {
344-
// delete ttl cronjob in case it was set (it is not required).
345-
await exec.exec(
346-
helm,
347-
[`--namespace=${namespace}`, "release", "ttl", release, `--unset`],
348-
{ env: process.env, ignoreReturnCode: true }
349-
);
350-
}
335+
// delete ttl cronjob in case it was set (it is not required).
336+
await exec.exec(
337+
helm,
338+
[`--namespace=${namespace}`, "release", "ttl", release, `--unset`],
339+
{ env: process.env, ignoreReturnCode: true }
340+
);
351341

352-
await exec.exec(helm, deleteCmd(helm, namespace, release), {
342+
await exec.exec(helm, deleteCmd(namespace, release), {
353343
ignoreReturnCode: true,
354344
});
355345
} else {
356346
await exec.exec(helm, args);
357347
}
358348

359349
// Set ttl if set
360-
if (helm === "helm3" && ttl !== "false") {
350+
if (ttl !== "false") {
361351
core.info("Setting ttl: " + ttl);
362352
await exec.exec(
363353
helm,

tests/charts/rails-example/expected.yml

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ metadata:
99
app.kubernetes.io/name: example-rails
1010
app.kubernetes.io/instance: rails-example
1111
app.kubernetes.io/version: "v1"
12-
app.kubernetes.io/managed-by: Tiller
12+
app.kubernetes.io/managed-by: Helm
1313
helm.sh/chart: app-0.0.2
1414
type: Opaque
1515
data:
1616
DATABASE_URL: "cG9zdGdyZXM6Ly8xMjNAdGVzdC5jb20="
17-
1817
---
1918
# Source: app/templates/service.yaml
2019
apiVersion: v1
@@ -26,7 +25,7 @@ metadata:
2625
app.kubernetes.io/name: example-rails
2726
app.kubernetes.io/instance: rails-example
2827
app.kubernetes.io/version: "v1"
29-
app.kubernetes.io/managed-by: Tiller
28+
app.kubernetes.io/managed-by: Helm
3029
helm.sh/chart: app-0.0.2
3130
spec:
3231
type: ClusterIP
@@ -37,7 +36,6 @@ spec:
3736
name: http
3837
selector:
3938
app.kubernetes.io/name: example-rails
40-
4139
---
4240
# Source: app/templates/deployment.yaml
4341
apiVersion: apps/v1
@@ -51,7 +49,7 @@ metadata:
5149
app.kubernetes.io/name: example-rails
5250
app.kubernetes.io/instance: rails-example
5351
app.kubernetes.io/version: "v1"
54-
app.kubernetes.io/managed-by: Tiller
52+
app.kubernetes.io/managed-by: Helm
5553
helm.sh/chart: app-0.0.2
5654
spec:
5755
replicas: 1
@@ -76,7 +74,6 @@ spec:
7674
env:
7775
- name: RAILS_ENV
7876
value: production
79-
8077
ports:
8178
- name: http
8279
containerPort: 80
@@ -86,17 +83,12 @@ spec:
8683
httpGet:
8784
path: /
8885
port: http
89-
9086
livenessProbe:
9187
httpGet:
9288
path: /
9389
port: http
94-
95-
9690
---
9791
# Source: app/templates/workers.yaml
98-
99-
---
10092
apiVersion: apps/v1
10193
kind: Deployment
10294
metadata:
@@ -109,7 +101,7 @@ metadata:
109101
app.kubernetes.io/name: example-rails
110102
app.kubernetes.io/instance: rails-example
111103
app.kubernetes.io/version: "v1"
112-
app.kubernetes.io/managed-by: Tiller
104+
app.kubernetes.io/managed-by: Helm
113105
helm.sh/chart: app-0.0.2
114106
spec:
115107
replicas: 1
@@ -138,7 +130,6 @@ spec:
138130
env:
139131
- name: RAILS_ENV
140132
value: production
141-
142133
ports:
143134
- name: http
144135
containerPort: 80
@@ -148,13 +139,35 @@ spec:
148139
httpGet:
149140
path: /
150141
port: http
151-
152142
livenessProbe:
153143
httpGet:
154144
path: /
155145
port: http
156-
157-
146+
---
147+
# Source: app/templates/ingress.yaml
148+
apiVersion: networking.k8s.io/v1
149+
kind: Ingress
150+
metadata:
151+
name: rails-example
152+
namespace: default
153+
labels:
154+
app.kubernetes.io/name: example-rails
155+
app.kubernetes.io/instance: rails-example
156+
app.kubernetes.io/version: "v1"
157+
app.kubernetes.io/managed-by: Helm
158+
helm.sh/chart: app-0.0.2
159+
spec:
160+
rules:
161+
- host: "example.com"
162+
http:
163+
paths:
164+
- path: /
165+
pathType: Prefix
166+
backend:
167+
service:
168+
name: rails-example
169+
port:
170+
name: http
158171
---
159172
# Source: app/templates/migration.yaml
160173
apiVersion: batch/v1
@@ -166,7 +179,7 @@ metadata:
166179
app.kubernetes.io/name: example-rails
167180
app.kubernetes.io/instance: rails-example
168181
app.kubernetes.io/version: "v1"
169-
app.kubernetes.io/managed-by: Tiller
182+
app.kubernetes.io/managed-by: Helm
170183
helm.sh/chart: app-0.0.2
171184
annotations:
172185
"helm.sh/hook": pre-upgrade
@@ -194,27 +207,3 @@ spec:
194207
env:
195208
- name: RAILS_ENV
196209
value: production
197-
198-
---
199-
# Source: app/templates/ingress.yaml
200-
apiVersion: extensions/v1beta1
201-
kind: Ingress
202-
metadata:
203-
name: rails-example
204-
namespace: default
205-
labels:
206-
app.kubernetes.io/name: example-rails
207-
app.kubernetes.io/instance: rails-example
208-
app.kubernetes.io/version: "v1"
209-
app.kubernetes.io/managed-by: Tiller
210-
helm.sh/chart: app-0.0.2
211-
spec:
212-
rules:
213-
- host: "example.com"
214-
http:
215-
paths:
216-
- path: /
217-
backend:
218-
serviceName: rails-example
219-
servicePort: http
220-

0 commit comments

Comments
 (0)