Skip to content

Commit 55edbcd

Browse files
authored
🧹 store helm chart in repository (#113)
Signed-off-by: Harsha <harshaisgud@gmail.com>
1 parent d58bf4a commit 55edbcd

14 files changed

Lines changed: 603 additions & 32 deletions

.github/workflows/helm-release.yaml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ on:
55
# Publish semver tags as releases.
66
tags: ["v*.*.*"]
77

8-
env:
9-
RELEASE: ${{ github.ref_name }}
10-
CHART_NAME: mondoo-operator
11-
128
jobs:
139
release:
1410
runs-on: ubuntu-latest
@@ -22,40 +18,13 @@ jobs:
2218
run: |
2319
git config user.name "$GITHUB_ACTOR"
2420
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
25-
26-
- name: Import environment variables from file
27-
run: cat ".github/env" >> $GITHUB_ENV
28-
29-
- name: Install Go
30-
uses: actions/setup-go@v2
31-
with:
32-
go-version: "${{ env.golang-version }}"
33-
21+
3422
- name: Install Helm
3523
uses: azure/setup-helm@v1
3624
with:
3725
version: v3.7.1
38-
39-
- name: Create Helm Chart
40-
run: make helm
41-
42-
- name: Set Chart and App Version to current release version
43-
uses: mikefarah/yq@master
44-
with:
45-
cmd: |
46-
yq -i '
47-
.version = strenv(RELEASE) |
48-
.appVersion = strenv(RELEASE)
49-
' mondoo-operator/Chart.yaml
50-
51-
- name: Set Image tag to latest in values.yaml
52-
uses: mikefarah/yq@master
53-
with:
54-
cmd: yq -i '.controllerManager.manager.image.tag = "latest"' mondoo-operator/values.yaml
5526

5627
- name: Run chart-releaser
5728
uses: helm/chart-releaser-action@v1.3.0
58-
with:
59-
charts_dir: .
6029
env:
6130
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

charts/mondoo-operator/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/mondoo-operator/Chart.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v2
2+
name: mondoo-operator
3+
description: A Helm chart for Kubernetes
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
# This is the chart version. This version number should be incremented each time you make changes
14+
# to the chart and its templates, including the app version.
15+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16+
version: 0.1.0
17+
# This is the version number of the application being deployed. This version number should be
18+
# incremented each time you make changes to the application. Versions are not expected to
19+
# follow Semantic Versioning. They should reflect the version the application is using.
20+
# It is recommended to use it with quotes.
21+
appVersion: "0.1.0"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "mondoo-operator.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "mondoo-operator.fullname" -}}
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 }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "mondoo-operator.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "mondoo-operator.labels" -}}
37+
helm.sh/chart: {{ include "mondoo-operator.chart" . }}
38+
{{ include "mondoo-operator.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 "mondoo-operator.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "mondoo-operator.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 "mondoo-operator.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "mondoo-operator.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ include "mondoo-operator.fullname" . }}-controller-manager
5+
labels:
6+
{{- include "mondoo-operator.labels" . | nindent 4 }}
7+
---
8+
apiVersion: v1
9+
kind: ServiceAccount
10+
metadata:
11+
name: {{ include "mondoo-operator.fullname" . }}-workload
12+
labels:
13+
{{- include "mondoo-operator.labels" . | nindent 4 }}
14+
---
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
name: {{ include "mondoo-operator.fullname" . }}-controller-manager
19+
labels:
20+
control-plane: controller-manager
21+
{{- include "mondoo-operator.labels" . | nindent 4 }}
22+
spec:
23+
replicas: {{ .Values.controllerManager.replicas }}
24+
selector:
25+
matchLabels:
26+
control-plane: controller-manager
27+
{{- include "mondoo-operator.selectorLabels" . | nindent 6 }}
28+
template:
29+
metadata:
30+
labels:
31+
control-plane: controller-manager
32+
{{- include "mondoo-operator.selectorLabels" . | nindent 8 }}
33+
spec:
34+
containers:
35+
- args:
36+
- --secure-listen-address=0.0.0.0:8443
37+
- --upstream=http://127.0.0.1:8080/
38+
- --logtostderr=true
39+
- --v=10
40+
image: {{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{ .Values.controllerManager.kubeRbacProxy.image.tag
41+
| default .Chart.AppVersion }}
42+
name: kube-rbac-proxy
43+
ports:
44+
- containerPort: 8443
45+
name: https
46+
protocol: TCP
47+
resources: {}
48+
- args:
49+
- --health-probe-bind-address=:8081
50+
- --metrics-bind-address=127.0.0.1:8080
51+
- --leader-elect
52+
command:
53+
- /manager
54+
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
55+
| default .Chart.AppVersion }}
56+
imagePullPolicy: IfNotPresent
57+
livenessProbe:
58+
httpGet:
59+
path: /healthz
60+
port: 8081
61+
initialDelaySeconds: 15
62+
periodSeconds: 20
63+
name: manager
64+
readinessProbe:
65+
httpGet:
66+
path: /readyz
67+
port: 8081
68+
initialDelaySeconds: 5
69+
periodSeconds: 10
70+
resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10
71+
}}
72+
securityContext:
73+
allowPrivilegeEscalation: false
74+
securityContext:
75+
runAsNonRoot: true
76+
serviceAccountName: {{ include "mondoo-operator.fullname" . }}-controller-manager
77+
terminationGracePeriodSeconds: 10
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: {{ include "mondoo-operator.fullname" . }}-leader-election-role
5+
labels:
6+
{{- include "mondoo-operator.labels" . | nindent 4 }}
7+
rules:
8+
- apiGroups:
9+
- ""
10+
resources:
11+
- configmaps
12+
verbs:
13+
- get
14+
- list
15+
- watch
16+
- create
17+
- update
18+
- patch
19+
- delete
20+
- apiGroups:
21+
- coordination.k8s.io
22+
resources:
23+
- leases
24+
verbs:
25+
- get
26+
- list
27+
- watch
28+
- create
29+
- update
30+
- patch
31+
- delete
32+
- apiGroups:
33+
- ""
34+
resources:
35+
- events
36+
verbs:
37+
- create
38+
- patch
39+
---
40+
apiVersion: rbac.authorization.k8s.io/v1
41+
kind: RoleBinding
42+
metadata:
43+
name: {{ include "mondoo-operator.fullname" . }}-leader-election-rolebinding
44+
labels:
45+
{{- include "mondoo-operator.labels" . | nindent 4 }}
46+
roleRef:
47+
apiGroup: rbac.authorization.k8s.io
48+
kind: Role
49+
name: '{{ include "mondoo-operator.fullname" . }}-leader-election-role'
50+
subjects:
51+
- kind: ServiceAccount
52+
name: '{{ include "mondoo-operator.fullname" . }}-controller-manager'
53+
namespace: '{{ .Release.Namespace }}'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "mondoo-operator.fullname" . }}-manager-config
5+
labels:
6+
{{- include "mondoo-operator.labels" . | nindent 4 }}
7+
data:
8+
controller_manager_config.yaml: |
9+
apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
10+
health:
11+
healthProbeBindAddress: {{ .Values.managerConfig.controllerManagerConfigYaml.health.healthProbeBindAddress
12+
| quote }}
13+
kind: ControllerManagerConfig
14+
leaderElection:
15+
leaderElect: {{ .Values.managerConfig.controllerManagerConfigYaml.leaderElection.leaderElect
16+
}}
17+
resourceName: {{ .Values.managerConfig.controllerManagerConfigYaml.leaderElection.resourceName
18+
| quote }}
19+
metrics:
20+
bindAddress: {{ .Values.managerConfig.controllerManagerConfigYaml.metrics.bindAddress
21+
| quote }}
22+
webhook:
23+
port: {{ .Values.managerConfig.controllerManagerConfigYaml.webhook.port }}

0 commit comments

Comments
 (0)