Skip to content

Commit 50ee2a4

Browse files
authored
Add Helm chart publishing workflow (#281)
* Adopt charts values to helm-charts repo * Add publish helm workflow * Use afritzler helm releaser * Use bitdeps helm releaser * Add setting version of charts to tag * Rename charts to metal-operator * Run publish charts on releases and push events * Remove kube-rbac * Move crds folder and use afritzler's action * Trigger chart pushing * Rename publish-helm to publish-chart * Use bitdeps action for publish charts
1 parent 5b8e25f commit 50ee2a4

File tree

3 files changed

+77
-19
lines changed

3 files changed

+77
-19
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Publish Helm Chart
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
release:
8+
types:
9+
- published
10+
push:
11+
branches:
12+
- main
13+
tags:
14+
- v*.*.*
15+
pull_request:
16+
branches:
17+
- main
18+
paths-ignore:
19+
- 'docs/**'
20+
- '**/*.md'
21+
types: [labeled, unlabeled, opened, synchronize, reopened]
22+
23+
jobs:
24+
publish-charts:
25+
runs-on: ubuntu-latest
26+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ok-to-chart')
27+
steps:
28+
- name: Check out repository
29+
uses: actions/checkout@v4
30+
- name: Set up Helm
31+
uses: azure/setup-helm@v4.3.0
32+
with:
33+
version: v3.16.2
34+
- name: Configure Git
35+
run: |
36+
git config user.name "$GITHUB_ACTOR"
37+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
38+
- name: Set charts version
39+
if: github.event_name == 'push'
40+
run: |
41+
sed -i "s/version: .*/version: ${GITHUB_REF_NAME#v}/" dist/chart/Chart.yaml
42+
- name: Move crds folder out of templates
43+
run: mv dist/chart/templates/crd dist/chart/crds
44+
- name: Run chart-releaser
45+
uses: bitdeps/helm-oci-charts-releaser@v0.1.4
46+
with:
47+
charts_dir: dist/chart
48+
oci_registry: ghcr.io/${{ github.repository_owner }}/charts
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
oci_password: ${{ secrets.GITHUB_TOKEN }}
51+
oci_username: ${{ github.actor }}
52+
skip_gh_release: true

dist/chart/templates/manager/manager.yaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
control-plane: controller-manager
99
spec:
1010
replicas: {{ .Values.controllerManager.replicas }}
11+
strategy:
12+
type: {{ .Values.controllerManager.strategy.type | quote }}
1113
selector:
1214
matchLabels:
1315
{{- include "chart.selectorLabels" . | nindent 6 }}
@@ -28,35 +30,36 @@ spec:
2830
containers:
2931
- name: manager
3032
args:
31-
{{- range .Values.controllerManager.container.args }}
33+
{{- range .Values.controllerManager.manager.args }}
3234
- {{ . }}
3335
{{- end }}
3436
command:
3537
- /manager
36-
image: {{ .Values.controllerManager.container.image.repository }}:{{ .Values.controllerManager.container.image.tag }}
37-
{{- if .Values.controllerManager.container.env }}
38+
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag }}
39+
{{- if .Values.controllerManager.manager.env }}
3840
env:
39-
{{- range $key, $value := .Values.controllerManager.container.env }}
41+
{{- range $key, $value := .Values.controllerManager.manager.env }}
4042
- name: {{ $key }}
4143
value: {{ $value }}
4244
{{- end }}
4345
{{- end }}
4446
livenessProbe:
45-
{{- toYaml .Values.controllerManager.container.livenessProbe | nindent 12 }}
47+
{{- toYaml .Values.controllerManager.manager.livenessProbe | nindent 12 }}
4648
readinessProbe:
47-
{{- toYaml .Values.controllerManager.container.readinessProbe | nindent 12 }}
49+
{{- toYaml .Values.controllerManager.manager.readinessProbe | nindent 12 }}
4850
{{- if .Values.webhook.enable }}
4951
ports:
5052
- containerPort: 9443
5153
name: webhook-server
5254
protocol: TCP
5355
{{- end }}
5456
resources:
55-
{{- toYaml .Values.controllerManager.container.resources | nindent 12 }}
57+
{{- toYaml .Values.controllerManager.manager.resources | nindent 12 }}
5658
securityContext:
57-
{{- toYaml .Values.controllerManager.container.securityContext | nindent 12 }}
58-
{{- if and .Values.certmanager.enable (or .Values.webhook.enable .Values.metrics.enable) }}
59+
{{- toYaml .Values.controllerManager.manager.securityContext | nindent 12 }}
5960
volumeMounts:
61+
- mountPath: /etc/macdb/
62+
name: macdb
6063
{{- if and .Values.webhook.enable .Values.certmanager.enable }}
6164
- name: webhook-cert
6265
mountPath: /tmp/k8s-webhook-server/serving-certs
@@ -67,14 +70,15 @@ spec:
6770
mountPath: /tmp/k8s-metrics-server/metrics-certs
6871
readOnly: true
6972
{{- end }}
70-
{{- end }}
7173
securityContext:
72-
{{- toYaml .Values.controllerManager.securityContext | nindent 8 }}
74+
{{- toYaml .Values.controllerManager.podSecurityContext | nindent 8 }}
7375
serviceAccountName: {{ .Values.controllerManager.serviceAccountName }}
7476
hostNetwork: {{ .Values.controllerManager.hostNetwork }}
7577
terminationGracePeriodSeconds: {{ .Values.controllerManager.terminationGracePeriodSeconds }}
76-
{{- if and .Values.certmanager.enable (or .Values.webhook.enable .Values.metrics.enable) }}
7778
volumes:
79+
- name: macdb
80+
secret:
81+
secretName: macdb
7882
{{- if and .Values.webhook.enable .Values.certmanager.enable }}
7983
- name: webhook-cert
8084
secret:
@@ -85,4 +89,3 @@ spec:
8589
secret:
8690
secretName: metrics-server-cert
8791
{{- end }}
88-
{{- end }}

dist/chart/values.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# [MANAGER]: Manager Deployment Configurations
22
controllerManager:
33
replicas: 1
4-
container:
4+
strategy:
5+
type: Recreate
6+
manager:
57
image:
68
repository: controller
79
tag: latest
@@ -11,11 +13,11 @@ controllerManager:
1113
- "--health-probe-bind-address=:8081"
1214
resources:
1315
limits:
14-
cpu: 500m
15-
memory: 128Mi
16+
cpu: 300m
17+
memory: 200Mi
1618
requests:
17-
cpu: 10m
18-
memory: 64Mi
19+
cpu: 300m
20+
memory: 50Mi
1921
livenessProbe:
2022
initialDelaySeconds: 15
2123
periodSeconds: 20
@@ -33,12 +35,13 @@ controllerManager:
3335
capabilities:
3436
drop:
3537
- "ALL"
36-
securityContext:
38+
podSecurityContext:
3739
runAsNonRoot: true
3840
seccompProfile:
3941
type: RuntimeDefault
4042
terminationGracePeriodSeconds: 10
4143
serviceAccountName: metal-operator-controller-manager
44+
hostNetwork: true
4245

4346
# [RBAC]: To enable RBAC (Permissions) configurations
4447
rbac:

0 commit comments

Comments
 (0)