Skip to content

Commit

Permalink
[ugc-demo] add chart
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-weyer authored Mar 19, 2024
1 parent 41c8650 commit a0b9e0c
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 0 deletions.
12 changes: 12 additions & 0 deletions charts/sophora-ugc-demo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
name: sophora-ugc-demo
description: A Helm chart for the UGC demo
type: application

version: 0.1.0

appVersion: 'latest'

maintainers:
- name: Team Koala
email: [email protected]
62 changes: 62 additions & 0 deletions charts/sophora-ugc-demo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ugc-demo.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ugc-demo.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ugc-demo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ugc-demo.labels" -}}
helm.sh/chart: {{ include "ugc-demo.chart" . }}
{{ include "ugc-demo.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ugc-demo.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ugc-demo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ugc-demo.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ugc-demo.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
94 changes: 94 additions & 0 deletions charts/sophora-ugc-demo/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ugc-demo.fullname" . }}
labels:
{{- include "ugc-demo.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "ugc-demo.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/sophora-properties-configmap.yaml") . | sha256sum }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ugc-demo.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: config-generator
image: alpine:3.19
imagePullPolicy: IfNotPresent
env:
- name: SOPHORA_DELIVERY_CLIENT_USERNAME
valueFrom:
secretKeyRef:
key: {{ .Values.sophora.authentication.secret.usernameKey }}
name: {{ .Values.sophora.authentication.secret.name }}
optional: false
- name: SOPHORA_DELIVERY_CLIENT_PASSWORD
valueFrom:
secretKeyRef:
key: {{ .Values.sophora.authentication.secret.passwordKey }}
name: {{ .Values.sophora.authentication.secret.name }}
optional: false
command: [ "/bin/sh" ]
args:
- "-c"
- |
apk update && apk add gettext
mkdir /usr/local/ugc-demo/conf/
echo "Created conf directory"
envsubst < /usr/local/ugc-demo-template/sophora.properties > /usr/local/ugc-demo/conf/sophora.properties
echo "Generated /usr/local/ugc-demo/conf/sophora.properties from ENV and template"
cp /usr/local/ugc-demo-template/submitter.properties /usr/local/ugc-demo/conf/submitter.properties
echo "Generated /usr/local/ugc-demo/conf/submitter.properties from template"
volumeMounts:
- name: submitter-properties-template
mountPath: /usr/local/ugc-demo-template/submitter.properties
subPath: submitter.properties
- name: sophora-properties-template
mountPath: /usr/local/ugc-demo-template/sophora.properties
subPath: sophora.properties
- name: ugc-demo-config
mountPath: /usr/local/ugc-demo/
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: ugc-demo-config
mountPath: /usr/local/ugc-demo/
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: ugc-demo-config
emptyDir: {}
- name: submitter-properties-template
configMap:
name: {{ include "ugc-demo.fullname" . }}-submitter-properties
- name: sophora-properties-template
configMap:
name: {{ include "ugc-demo.fullname" . }}-sophora-properties
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
38 changes: 38 additions & 0 deletions charts/sophora-ugc-demo/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "ugc-demo.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ required "A hostname for the ingress must be provided in .Values.ugc-demo.ingress.host" .host }}
http:
paths:
- path: /
pathType: {{ default "ImplementationSpecific" .pathType }}
backend:
service:
name: {{ $fullName }}
port:
number: 8080
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/sophora-ugc-demo/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Service
apiVersion: v1
metadata:
name: {{ include "ugc-demo.fullname" . }}
labels:
{{- include "ugc-demo.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector: {{- include "ugc-demo.selectorLabels" . | nindent 4 }}
type: {{ .Values.service.type }}
ports:
- protocol: TCP
targetPort: 8080
port: {{ .Values.service.port }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "ugc-demo.fullname" . }}-sophora-properties
labels:
{{- include "ugc-demo.labels" . | nindent 4 }}
data:
sophora.properties: |-
{{ toString (required "A valid sophora.properties configuration needs to be provided." .Values.ugc.demo.sophoraproperties) | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "ugc-demo.fullname" . }}-submitter-properties
labels:
{{- include "ugc-demo.labels" . | nindent 4 }}
data:
submitter.properties: |-
{{- toString (required "A valid submitter.properties configuration needs to be provided." .Values.ugc.demo.submitterproperties) | nindent 4 }}
59 changes: 59 additions & 0 deletions charts/sophora-ugc-demo/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
nameOverride: ""
fullnameOverride: ""

replicaCount: 1

image:
repository: docker.subshell.com/ugc/ugc-demo
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

ingress:
enabled: false
ingressClassName: nginx
tls:
hosts:
annotations: {}

service:
type: ClusterIP
port: 8080
annotations: {}

ugc:
demo:
submitterproperties:

sophoraproperties:

sophora:
authentication:
secret:
name: secret-name
usernameKey: username
passwordKey: password

# Additional environment variables can be defined here
env:

resources:
requests:
cpu: "200m"
memory: "2.5G"
limits:
memory: "2.5G"


nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit a0b9e0c

Please sign in to comment.