Skip to content

Commit db902fc

Browse files
authored
Added negsoft-operator (#2)
Took 1 hour 51 minutes
1 parent aadadc1 commit db902fc

File tree

12 files changed

+510
-0
lines changed

12 files changed

+510
-0
lines changed

charts/negsoft-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/negsoft-operator/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: negsoft-operator
3+
description: A Helm chart for 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: 0.1.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: "1.0.0"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "negsoft-operator.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "negsoft-operator.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "negsoft-operator.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "negsoft-operator.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
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 "negsoft-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 "negsoft-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 "negsoft-operator.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "negsoft-operator.labels" -}}
37+
helm.sh/chart: {{ include "negsoft-operator.chart" . }}
38+
{{ include "negsoft-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 "negsoft-operator.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "negsoft-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 "negsoft-operator.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "negsoft-operator.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
{{- include "negsoft-operator.labels" . | nindent 4 }}
7+
name: {{ include "negsoft-operator.fullname" . }}-update-cronjobs
8+
rules:
9+
- apiGroups:
10+
- batch
11+
resources:
12+
- cronjobs
13+
verbs:
14+
- list
15+
- create
16+
- update
17+
- delete
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: ClusterRole
21+
metadata:
22+
labels:
23+
{{- include "negsoft-operator.labels" . | nindent 4 }}
24+
name: {{ include "negsoft-operator.fullname" . }}-read-subscriptions
25+
rules:
26+
- apiGroups:
27+
- enthus.de
28+
resources:
29+
- negsoftsubscriptions
30+
verbs:
31+
- list
32+
- watch
33+
{{- end -}}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
labels:
6+
{{- include "negsoft-operator.labels" . | nindent 4 }}
7+
name: {{ include "negsoft-operator.fullname" . }}-update-cronjobs
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ include "negsoft-operator.fullname" . }}-update-cronjobs
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ include "negsoft-operator.serviceAccountName" . }}
15+
namespace: {{ .Release.Namespace }}
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
labels:
21+
{{- include "negsoft-operator.labels" . | nindent 4 }}
22+
name: {{ include "negsoft-operator.fullname" . }}-read-subscriptions
23+
roleRef:
24+
apiGroup: rbac.authorization.k8s.io
25+
kind: ClusterRole
26+
name: {{ include "negsoft-operator.fullname" . }}-read-subscriptions
27+
subjects:
28+
- kind: ServiceAccount
29+
name: {{ include "negsoft-operator.serviceAccountName" . }}
30+
namespace: {{ .Release.Namespace }}
31+
{{- end -}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "negsoft-operator.fullname" . }}
5+
data:
6+
template_cronjob.yaml: |-
7+
{{- include "negsoft-operator.cronjob_template" . | nindent 4 }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{- define "negsoft-operator.cronjob_template" -}}
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: {{ include "negsoft-operator.fullname" . }}
6+
labels:
7+
{{- include "negsoft-operator.labels" . | nindent 4 }}
8+
spec:
9+
schedule: ""
10+
timeZone: "Europe/Berlin"
11+
concurrencyPolicy: "Forbid"
12+
jobTemplate:
13+
spec:
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 12 }}
19+
{{- end }}
20+
labels:
21+
{{- include "negsoft-operator.labels" . | nindent 8 }}
22+
{{- with .Values.podLabels }}
23+
{{- toYaml . | nindent 12 }}
24+
{{- end }}
25+
spec:
26+
{{- with .Values.imagePullSecrets }}
27+
imagePullSecrets:
28+
{{- toYaml . | nindent 12 }}
29+
{{- end }}
30+
securityContext:
31+
{{- toYaml .Values.podSecurityContext | nindent 12 }}
32+
containers:
33+
- name: cronjob
34+
securityContext:
35+
{{- toYaml .Values.securityContext | nindent 16 }}
36+
image: "" # is overridden by operator
37+
imagePullPolicy: {{ .Values.image.pullPolicy }}
38+
env:
39+
- name: GOOGLE_APPLICATION_CREDENTIALS
40+
value: /var/run/secret/cloud.google.com/service-account.json
41+
volumeMounts:
42+
- name: config
43+
mountPath: /etc/nx
44+
readOnly: true
45+
- name: gcp-service-account
46+
mountPath: /var/run/secret/cloud.google.com
47+
readOnly: true
48+
- name: files
49+
mountPath: /mnt/files
50+
volumes:
51+
- name: config
52+
configMap:
53+
name: "" # is overridden by operator
54+
- name: gcp-service-account
55+
secret:
56+
secretName: "" # is overridden by operator
57+
- name: files
58+
emptyDir: {} # is overridden by operator
59+
restartPolicy: OnFailure
60+
{{- end }}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "negsoft-operator.fullname" . }}
5+
labels:
6+
{{- include "negsoft-operator.labels" . | nindent 4 }}
7+
spec:
8+
strategy:
9+
type: Recreate
10+
{{- if not .Values.autoscaling.enabled }}
11+
replicas: {{ .Values.replicaCount }}
12+
{{- end }}
13+
selector:
14+
matchLabels:
15+
{{- include "negsoft-operator.selectorLabels" . | nindent 6 }}
16+
template:
17+
metadata:
18+
annotations:
19+
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
20+
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
21+
{{- with .Values.podAnnotations }}
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
labels:
25+
{{- include "negsoft-operator.labels" . | nindent 8 }}
26+
{{- with .Values.podLabels }}
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
spec:
30+
{{- with .Values.imagePullSecrets }}
31+
imagePullSecrets:
32+
{{- toYaml . | nindent 8 }}
33+
{{- end }}
34+
serviceAccountName: {{ include "negsoft-operator.serviceAccountName" . }}
35+
securityContext:
36+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
37+
containers:
38+
- name: {{ .Chart.Name }}
39+
securityContext:
40+
{{- toYaml .Values.securityContext | nindent 12 }}
41+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
42+
imagePullPolicy: {{ .Values.image.pullPolicy }}
43+
resources:
44+
{{- toYaml .Values.resources | nindent 12 }}
45+
env:
46+
- name: MSSQL_HOSTNAME
47+
valueFrom:
48+
secretKeyRef:
49+
name: {{ include "negsoft-operator.fullname" . }}-secret
50+
key: mssqlHostname
51+
- name: MSSQL_PORT
52+
valueFrom:
53+
secretKeyRef:
54+
name: {{ include "negsoft-operator.fullname" . }}-secret
55+
key: mssqlPort
56+
- name: MSSQL_USERNAME
57+
valueFrom:
58+
secretKeyRef:
59+
name: {{ include "negsoft-operator.fullname" . }}-secret
60+
key: mssqlUsername
61+
- name: MSSQL_PASSWORD
62+
valueFrom:
63+
secretKeyRef:
64+
name: {{ include "negsoft-operator.fullname" . }}-secret
65+
key: mssqlPassword
66+
- name: REDIS_ADDRESSES
67+
valueFrom:
68+
secretKeyRef:
69+
name: {{ include "negsoft-operator.fullname" . }}-secret
70+
key: redisAddresses
71+
- name: REDIS_MASTER_SET
72+
valueFrom:
73+
secretKeyRef:
74+
name: {{ include "negsoft-operator.fullname" . }}-secret
75+
key: redisMasterSet
76+
- name: REDIS_DATABASE
77+
valueFrom:
78+
secretKeyRef:
79+
name: {{ include "negsoft-operator.fullname" . }}-secret
80+
key: redisDatabase
81+
- name: CRONJOB_PREFIX
82+
value: {{ .Values.cronjobPrefix }}
83+
volumeMounts:
84+
- name: config
85+
mountPath: /config
86+
readOnly: true
87+
{{- with .Values.volumeMounts }}
88+
{{- toYaml . | nindent 12 }}
89+
{{- end }}
90+
volumes:
91+
- name: config
92+
configMap:
93+
name: {{ include "negsoft-operator.fullname" . }}
94+
{{- with .Values.volumes }}
95+
{{- toYaml . | nindent 8 }}
96+
{{- end }}
97+
{{- with .Values.nodeSelector }}
98+
nodeSelector:
99+
{{- toYaml . | nindent 8 }}
100+
{{- end }}
101+
{{- with .Values.affinity }}
102+
affinity:
103+
{{- toYaml . | nindent 8 }}
104+
{{- end }}
105+
{{- with .Values.tolerations }}
106+
tolerations:
107+
{{- toYaml . | nindent 8 }}
108+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "negsoft-operator.fullname" . }}-secret
5+
labels:
6+
{{- include "negsoft-operator.labels" . | nindent 4 }}
7+
type: Opaque
8+
data:
9+
mssqlHostname: {{ .Values.secret.mssqlHostname | b64enc | quote }}
10+
mssqlPort: {{ .Values.secret.mssqlPort | b64enc | quote }}
11+
mssqlUsername: {{ .Values.secret.mssqlUsername | b64enc | quote }}
12+
mssqlPassword: {{ .Values.secret.mssqlPassword | b64enc | quote }}
13+
redisAddresses: {{ .Values.secret.redisAddresses | b64enc | quote }}
14+
redisMasterSet: {{ .Values.secret.redisMasterSet | b64enc | quote }}
15+
redisDatabase: {{ .Values.secret.redisDatabase | b64enc | quote }}

0 commit comments

Comments
 (0)