Skip to content

Commit

Permalink
clean up chart
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Aug 24, 2024
1 parent afb1858 commit 88e72a6
Show file tree
Hide file tree
Showing 21 changed files with 380 additions and 420 deletions.
26 changes: 7 additions & 19 deletions deploy/ctrlplane/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
apiVersion: v2
name: ctrlplane
description: A Helm chart for Kubernetes

# 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.
description: Ctrlplane Helm chart for Kubernetes
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"

dependencies:
- name: webservice
version: "*.*.*"
repository: file://charts/webservice
condition: webservice.install
1 change: 1 addition & 0 deletions deploy/ctrlplane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Ctrlplane Helm Chart
23 changes: 23 additions & 0 deletions deploy/ctrlplane/charts/webservice/.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 deploy/ctrlplane/charts/webservice/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: webservice
description: A Helm chart for Kubernetes

# 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"
62 changes: 62 additions & 0 deletions deploy/ctrlplane/charts/webservice/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "webservice.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 "webservice.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 "webservice.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "webservice.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "webservice.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
67 changes: 67 additions & 0 deletions deploy/ctrlplane/charts/webservice/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{- $imageCfg := dict "global" $.Values.global.image "local" $.Values.image -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "webservice.fullname" . }}
labels:
{{- if .Values.deployment.labels -}}
{{- toYaml .Values.deployment.labels | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.deployment.annotations -}}
{{- toYaml .Values.deployment.annotations | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "ctrlplane.selectorLabels" $ | nindent 6 }}
{{- include "webservice.labels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "webservice.labels" . | nindent 8 }}
annotations:
{{- if .Values.pod.annotations -}}
{{- toYaml .Values.pod.annotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "webservice.serviceAccountName" . }}
{{- if .tolerations }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
{{- end }}
{{- include "ctrlplane.nodeSelector" . | nindent 6 }}
{{- include "ctrlplane.priorityClassName" . | nindent 6 }}
{{- include "ctrlplane.podSecurityContext" .Values.pod.securityContext | nindent 6 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- name: http
containerPort: 8080
protocol: TCP
env:
{{- include "ctrlplane.extraEnv" (dict "root" $ "local" .) | nindent 12 }}
{{- include "ctrlplane.extraEnvFrom" (dict "root" $ "local" .) | nindent 12 }}
livenessProbe:
httpGet:
path: /healthz
port: http
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 20
periodSeconds: 5
startupProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 20
periodSeconds: 5
failureThreshold: 120

resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes: {}
23 changes: 23 additions & 0 deletions deploy/ctrlplane/charts/webservice/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "webservice.fullname" . }}
labels:
{{- include "ctrlplane.commonLabels" . | nindent 4 }}
{{- include "webservice.labels" . | nindent 4 }}
{{- include "webservice.commonLabels" . | nindent 4 }}
{{- if .Values.service.labels -}}
{{- toYaml .Values.service.labels | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.service.annotations -}}
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: 8080
protocol: TCP
name: webservice
selector:
{{- include "webservice.labels" . | nindent 4 }}
32 changes: 32 additions & 0 deletions deploy/ctrlplane/charts/webservice/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
nameOverride: ""
fullnameOverride: ""

replica: 5

image:
repository: ctrlplane/webservice
tag: latest
pullPolicy: Always

extraEnv: {}
extraEnvFrom: {}

deployment:
labels: {}
annotations: {}

service:
type: ClusterIP
annotations: {}
labels: {}

tolerations: []
pod: {}

resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 4000m
memory: 4Gi
22 changes: 0 additions & 22 deletions deploy/ctrlplane/templates/NOTES.txt

This file was deleted.

20 changes: 20 additions & 0 deletions deploy/ctrlplane/templates/_env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- define "ctrlplane.extraEnvFrom" -}}
{{- $global := deepCopy (get .root.Values.global "extraEnvFrom" | default (dict)) -}}
{{- $values := deepCopy (get .root.Values "extraEnvFrom" | default (dict)) -}}
{{- $local := deepCopy (get .local "extraEnvFrom" | default (dict)) -}}
{{- $allExtraEnvFrom := mergeOverwrite $global $values $local -}}
{{- range $key, $value := $allExtraEnvFrom }}
- name: {{ $key }}
valueFrom:
{{ toYaml $value | nindent 4 }}
{{- end -}}
{{- end -}}


{{- define "ctrlplane.extraEnv" -}}
{{- $allExtraEnv := merge (default (dict) .Values.extraEnv) .Values.global.extraEnv -}}
{{- range $key, $value := $allExtraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end -}}
{{- end -}}
9 changes: 9 additions & 0 deletions deploy/ctrlplane/templates/_labels.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- define "ctrlplane.commonLabels" -}}
{{- $commonLabels := merge (pluck "labels" (default (dict) .Values.common) | first) .Values.global.common.labels}}
{{- if $commonLabels }}
{{- range $key, $value := $commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end -}}
{{- end -}}

25 changes: 25 additions & 0 deletions deploy/ctrlplane/templates/_pod.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- define "ctrlplane.priorityClassName" -}}
{{- $pcName := default .Values.global.priorityClassName .Values.priorityClassName -}}
{{- if $pcName }}
priorityClassName: {{ $pcName }}
{{- end -}}
{{- end -}}

{{- define "ctrlplane.podSecurityContext" -}}
{{- $psc := . }}
{{- if $psc }}
securityContext:
{{- if not (empty $psc.runAsUser) }}
runAsUser: {{ $psc.runAsUser }}
{{- end }}
{{- if not (empty $psc.runAsGroup) }}
runAsGroup: {{ $psc.runAsGroup }}
{{- end }}
{{- if not (empty $psc.fsGroup) }}
fsGroup: {{ $psc.fsGroup }}
{{- end }}
{{- if not (empty $psc.fsGroupChangePolicy) }}
fsGroupChangePolicy: {{ $psc.fsGroupChangePolicy }}
{{- end }}
{{- end }}
{{- end -}}
7 changes: 7 additions & 0 deletions deploy/ctrlplane/templates/_selector.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- define "ctrlplane.nodeSelector" -}}
{{- $nodeSelector := default .Values.global.nodeSelector .Values.nodeSelector -}}
{{- if $nodeSelector }}
nodeSelector:
{{- toYaml $nodeSelector | nindent 2 }}
{{- end }}
{{- end -}}
Loading

0 comments on commit 88e72a6

Please sign in to comment.