Skip to content

Commit

Permalink
Merge pull request #67 from dfds/chore/create-helm-chart
Browse files Browse the repository at this point in the history
Added Helm chart
  • Loading branch information
SEQUOIIA authored Nov 13, 2023
2 parents a62115a + 0324d47 commit 1152897
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 0 deletions.
23 changes: 23 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: k8s-janitor
description: A Helm chart for k8s-janitor

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
66 changes: 66 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "k8s-janitor.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 "k8s-janitor.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" $name .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

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

{{/*
Common labels
*/}}
{{- define "k8s-janitor.labels" -}}
{{ include "k8s-janitor.selectorLabels" . }}
{{- if eq .Values.managedByHelm true }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "k8s-janitor.chart" . }}
{{- end }}
{{- end }}

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


{{/*
Create the name of the service account to use
*/}}
{{- define "k8s-janitor.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "k8s-janitor.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions chart/templates/_val.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

{{- define "k8s-janitor.serviceaccount.awsRoleArn" -}}
{{- if .Values.serviceAccount.awsRoleArn }}
{{- .Values.serviceAccount.awsRoleArn }}
{{- else }}
{{- "arn:aws:iam::${aws_account_id}:role/k8s-janitor" }}
{{- end }}
{{- end }}
78 changes: 78 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "k8s-janitor.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "k8s-janitor.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "k8s-janitor.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "k8s-janitor.selectorLabels" . | nindent 8 }}
spec:
priorityClassName: selfservice
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "k8s-janitor.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: app
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.app.environment }}
env:
{{- toYaml . | nindent 12}}
{{- end }}
ports:
- name: web
protocol: TCP
containerPort: {{ .Values.service.port }}
- name: metrics
protocol: TCP
containerPort: {{ .Values.service.metricsPort }}
livenessProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
httpGet:
port: web
path: /healthz
readinessProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
httpGet:
port: web
path: /healthz
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
23 changes: 23 additions & 0 deletions chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "k8s-janitor.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- if .Values.service.scrapeMetrics }}
scrape-service-metrics: "true"
{{- end }}
{{- include "k8s-janitor.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: web
protocol: TCP
name: external
- port: {{ .Values.service.metricsPort }}
targetPort: metrics
protocol: TCP
name: metrics
selector:
{{- include "k8s-janitor.selectorLabels" . | nindent 4 }}
14 changes: 14 additions & 0 deletions chart/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "k8s-janitor.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "k8s-janitor.labels" . | nindent 4 }}
annotations:
eks.amazonaws.com/role-arn: {{ include "k8s-janitor.serviceaccount.awsRoleArn" . }}
{{- with .Values.serviceAccount.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
123 changes: 123 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Default values for k8s-janitor.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
managedByHelm: true
environment: "develop"

image:
repository: 579478677147.dkr.ecr.eu-central-1.amazonaws.com/ded/k8s-janitor
pullPolicy: Always
tag: "latest"

app:
config:
kafkaSecretRef: k8s-janitor-kafka-credentials

environment:
- name: AWS_S3_BUCKET_REGION
value: $(AWS_S3_BUCKET_REGION)
- name: AWS_S3_BUCKET_NAME_CONFIG_MAP
value: $(AWS_S3_BUCKET_NAME_CONFIG_MAP)
- name: CONFIG_MAP_FILE_NAME
value: $(CONFIG_MAP_FILE_NAME)
- name: KUBERNETES_SERVICE_KAFKA_BOOTSTRAP_SERVERS
value: $(KUBERNETES_SERVICE_KAFKA_BOOTSTRAP_SERVERS)
- name: KUBERNETES_SERVICE_KAFKA_BROKER_VERSION_FALLBACK
value: "0.10.0.0"
- name: KUBERNETES_SERVICE_KAFKA_API_VERSION_FALLBACK_MS
value: "0"
- name: KUBERNETES_SERVICE_KAFKA_SASL_USERNAME
valueFrom:
secretKeyRef:
name: k8s-janitor-kafka-credentials
key: username
- name: KUBERNETES_SERVICE_KAFKA_SASL_PASSWORD
valueFrom:
secretKeyRef:
name: k8s-janitor-kafka-credentials
key: password
- name: KUBERNETES_SERVICE_KAFKA_GROUP_ID
value: "$(KUBERNETES_SERVICE_KAFKA_GROUP_ID)"
- name: KUBERNETES_SERVICE_KAFKA_ENABLE_AUTO_COMMIT
value: "false"
- name: KUBERNETES_SERVICE_KAFKA_SASL_MECHANISMS
value: "PLAIN"
- name: KUBERNETES_SERVICE_KAFKA_SECURITY_PROTOCOL
value: "SASL_SSL"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
awsRoleArn: ""
# Annotations to add to the service account
annotations:
eks.amazonaws.com/sts-regional-endpoints: "true"
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 80
metricsPort: 8080
scrapeMetrics: true

ingress:
enabled: true
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
match: Host(`localhost`)
matches:
- name: k8s-janitor
match: Host(`build.dfds.cloud`) && PathPrefix(`/api`)
prefix: "/api"
- name: k8s-janitor-pub
match: Host(`api.hellman.oxygen.dfds.cloud`) && PathPrefix(`/ssu/api`)
prefix: "/ssu/api"
middlewares: []
services: []
routes: []
# - kind: Rule
# match: Host(`build.dfds.cloud`)
# priority: 90
# middlewares: []
# services:
# - kind: Service
# name: k8s-janitor
# namespace: selfservice
# port: external

resources:
requests:
memory: "200Mi"
cpu: "100m"
limits:
memory: "400Mi"
cpu: "200m"


nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit 1152897

Please sign in to comment.