Skip to content

Commit 53202e1

Browse files
committed
Changelog:
- Update image version and index - Update readme with instructions to use helm repository - Update notes and readme with port-forward instructions - Switch to Helm v2 - Substitute WIREMOCK_OPTION by args - Cleanup _helpers.tpl - Support additional pod annotations - Update configmaps - Update service - Fix ingress - Add imagePullSecrets support - Add service account support - Add pod and container security context support - Add horizontal pod autoscaler support - Update CI and CD pipelines Fix #21 Fix #22 Fix #25 Fix #27 Fix #28 Fix #34 Fix #40 Close #29 Close #31 Close #33 Close #39
1 parent fdac540 commit 53202e1

18 files changed

+354
-140
lines changed

Diff for: .github/workflows/cd.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
with:
1515
fetch-depth: 0
1616

@@ -20,11 +20,11 @@ jobs:
2020
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
2121
2222
- name: Install Helm
23-
uses: azure/setup-helm@v1
24-
with:
25-
version: v3.8.1
23+
uses: azure/setup-helm@v4
24+
env:
25+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2626

2727
- name: Run chart-releaser
28-
uses: helm/chart-releaser-action@v1.4.0
28+
uses: helm/chart-releaser-action@v1.6.0
2929
env:
3030
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Diff for: .github/workflows/ci.yaml

+13-10
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,39 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
2323
with:
2424
fetch-depth: 0
2525

2626
- name: Set up Helm
27-
uses: azure/setup-helm@v1
27+
uses: azure/setup-helm@v3
2828
with:
29-
version: v3.8.1
29+
version: v3.14.0
3030

31-
- uses: actions/setup-python@v2
31+
- uses: actions/setup-python@v4
3232
with:
33-
python-version: 3.7
33+
python-version: '3.12'
34+
check-latest: true
3435

3536
- name: Set up chart-testing
36-
uses: helm/chart-testing-action@v2.2.1
37+
uses: helm/chart-testing-action@v2.6.1
3738

3839
- name: Run chart-testing (list-changed)
3940
id: list-changed
4041
run: |
4142
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
4243
if [[ -n "$changed" ]]; then
43-
echo "::set-output name=changed::true"
44+
echo "changed=true" >> "$GITHUB_OUTPUT"
4445
fi
4546
4647
- name: Run chart-testing (lint)
47-
run: ct lint
48+
if: steps.list-changed.outputs.changed == 'true'
49+
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
4850

4951
- name: Create kind cluster
50-
uses: helm/kind-action@v1.2.0
5152
if: steps.list-changed.outputs.changed == 'true'
53+
uses: helm/kind-action@v1.8.0
5254

5355
- name: Run chart-testing (install)
54-
run: ct install
56+
if: steps.list-changed.outputs.changed == 'true'
57+
run: ct install --target-branch ${{ github.event.repository.default_branch }}

Diff for: README.md

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ and the chart remains partially compatible with it.
1818

1919
## Install WireMock
2020

21+
Once Helm is installed, you can either add this repository with `helm repo add`:
22+
23+
```bash
24+
helm repo add wiremock https://wiremock.github.io/helm-charts
25+
```
26+
27+
You can then run `helm upgrade --install <release name> wiremock/wiremock` to install it through the repository.
28+
29+
Alternatively, you can clone the helm repo and then install it with a local reference:
30+
2131
```bash
2232
helm upgrade --install <release_name> ./charts/<chart_name>
2333
```

Diff for: charts/wiremock/.helmignore

+2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
*.swp
1515
*.bak
1616
*.tmp
17+
*.orig
1718
*~
1819
# Various IDEs
1920
.project
2021
.idea/
2122
*.tmproj
23+
.vscode/

Diff for: charts/wiremock/Chart.yaml

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
apiVersion: v1
2-
appVersion: "3.0.0.1"
3-
description: A Helm chart for WireMock deployment on Kubernetes
1+
apiVersion: v2
42
name: wiremock
5-
version: 0.2.0
3+
description: A Helm chart for WireMock deployment on Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 1.0.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "3.8.0"
25+
626
maintainers:
727
- name: "gitkent"
828
url: "https://github.com/gitkent"

Diff for: charts/wiremock/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ Setup port forwarding
2525
```bash
2626
$ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wiremock.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
2727

28-
$ kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort}}
28+
$ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
29+
30+
$ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
2931
```
3032

3133
## Verify Wiremock deployment
3234

33-
To verify erifying a response using Wiremock, run
35+
To verify a response using Wiremock, run
3436

3537
```bash
3638
$ curl -X POST http://127.0.0.1:8080/v1/hello

Diff for: charts/wiremock/templates/NOTES.txt

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
1. Get the application URL by running these commands:
22
{{- if .Values.ingress.enabled }}
3-
{{- range .Values.ingress.hosts }}
4-
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
57
{{- end }}
68
{{- else if contains "NodePort" .Values.service.type }}
79
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "wiremock.fullname" . }})
810
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
911
echo http://$NODE_IP:$NODE_PORT
1012
{{- else if contains "LoadBalancer" .Values.service.type }}
1113
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
12-
You can watch the status of by running 'kubectl get svc -w {{ include "wiremock.fullname" . }}'
13-
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wiremock.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "wiremock.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wiremock.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
1416
echo http://$SERVICE_IP:{{ .Values.service.port }}
1517
{{- else if contains "ClusterIP" .Values.service.type }}
1618
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wiremock.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
17-
kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort}}
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
1821
echo "Visit http://127.0.0.1:8080/__admin/mappings to use your application"
1922
run "curl -X POST http://127.0.0.1:8080/v1/hello"
20-
{{- end }}
23+
{{- end }}

Diff for: charts/wiremock/templates/_helpers.tpl

+58-16
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,74 @@
1-
{{/* vim: set filetype=mustache: */}}
21
{{/*
32
Expand the name of the chart.
43
*/}}
54
{{- define "wiremock.name" -}}
6-
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7-
{{- end -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
87

98
{{/*
109
Create a default fully qualified app name.
1110
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
1211
If release name contains chart name it will be used as a full name.
1312
*/}}
1413
{{- define "wiremock.fullname" -}}
15-
{{- if .Values.fullnameOverride -}}
16-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17-
{{- else -}}
18-
{{- $name := default .Chart.Name .Values.nameOverride -}}
19-
{{- if contains $name .Release.Name -}}
20-
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21-
{{- else -}}
22-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23-
{{- end -}}
24-
{{- end -}}
25-
{{- end -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
2625

2726
{{/*
2827
Create chart name and version as used by the chart label.
2928
*/}}
3029
{{- define "wiremock.chart" -}}
31-
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32-
{{- end -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "wiremock.labels" -}}
37+
helm.sh/chart: {{ include "wiremock.chart" . }}
38+
{{ include "wiremock.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "wiremock.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "wiremock.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "wiremock.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "wiremock.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Pod annotations
66+
*/}}
67+
{{- define "wiremock.podAnnotations" -}}
68+
checksum/configMappings: {{ include (print $.Template.BasePath "/configmap-mappings.yaml") . | sha256sum }}
69+
checksum/configResponses: {{ include (print $.Template.BasePath "/configmap-responses.yaml") . | sha256sum }}
70+
{{- if .Values.podAnnotations }}
71+
{{ .Values.podAnnotations }}
72+
{{- end }}
73+
{{- end }}
74+

Diff for: charts/wiremock/templates/configmap-mappings.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: {{ include "wiremock.fullname" . }}-mappings-configs
5-
namespace: {{ .Release.Namespace | quote }}
65
labels:
7-
app.kubernetes.io/name: {{ include "wiremock.name" . }}
8-
helm.sh/chart: {{ include "wiremock.chart" . }}
9-
app.kubernetes.io/instance: {{ .Release.Name }}
10-
app.kubernetes.io/managed-by: {{ .Release.Service }}
6+
{{- include "wiremock.labels" . | nindent 4 }}
117
data:
128
{{- $files := .Files }}
139
{{- range $key, $value := .Files }}

Diff for: charts/wiremock/templates/configmap-responses.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: {{ include "wiremock.fullname" . }}-responses-configs
5-
namespace: {{ .Release.Namespace | quote }}
65
labels:
7-
app.kubernetes.io/name: {{ include "wiremock.name" . }}
8-
helm.sh/chart: {{ include "wiremock.chart" . }}
9-
app.kubernetes.io/instance: {{ .Release.Name }}
10-
app.kubernetes.io/managed-by: {{ .Release.Service }}
6+
{{- include "wiremock.labels" . | nindent 4 }}
117
data:
128
{{- $files := .Files }}
139
{{- range $key, $value := .Files }}

0 commit comments

Comments
 (0)