Skip to content

Commit

Permalink
Create a helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardCooke committed Sep 4, 2024
1 parent 882dcfd commit 72ee80f
Show file tree
Hide file tree
Showing 27 changed files with 1,481 additions and 3 deletions.
23 changes: 23 additions & 0 deletions charts/multicluster-ingress/.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 charts/multicluster-ingress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: multiclusteringress
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"
Empty file.
63 changes: 63 additions & 0 deletions charts/multicluster-ingress/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

{{/*
Expand the name of the chart.
*/}}
{{- define "multiclusterIngress.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 "multiclusterIngress.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 "multiclusterIngress.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "multiclusterIngress.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "multiclusterIngress.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions charts/multicluster-ingress/templates/api-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.apiServer.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "{{ include "multiclusterIngress.name" . | trunc 40 }}-api-server"
labels:
{{- include "multiclusterIngress.labels" . | nindent 4 }}
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.apiServer.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.apiServer.ingress.className }}
{{- if .Values.apiServer.ingress.tls }}
tls:
{{- range .Values.apiServer.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.apiServer.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: "{{ include "multiclusterIngress.name" $ | trunc 40 }}-api-server"
port:
number: {{ $.Values.apiServer.service.port }}
{{- end }}
{{- end }}
{{- end }}
106 changes: 106 additions & 0 deletions charts/multicluster-ingress/templates/api-server-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{{- if .Values.apiServer.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ include "multiclusterIngress.name" . | trunc 40 }}-api-server"
labels:
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "multiclusterIngress.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.apiServer.replicas }}
selector:
matchLabels:
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- include "multiclusterIngress.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "multiclusterIngress.labels" . | nindent 8 }}
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: "{{ .Values.apiServer.serviceAccount.name }}"
automountServiceAccountToken: true
securityContext:
{{- toYaml .Values.apiServer.podSecurityContext | nindent 8 }}
containers:
- name: api-server
args:
- --front-end
envFrom:
- configMapRef:
name: mcingress
- secretRef:
name: mcingress
securityContext:
{{- toYaml .Values.apiServer.securityContext | nindent 10 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 8080
protocol: TCP
name: http
livenessProbe:
httpGet:
path: /Healthz/Liveness
port: http
initialDelaySeconds: 30
timeoutSeconds: 1
readinessProbe:
httpGet:
path: /Healthz/Ready
port: http
initialDelaySeconds: 15
timeoutSeconds: 1
resources:
{{- toYaml .Values.apiServer.resources | nindent 10 }}
volumeMounts:
- mountPath: /app/appsettings.json
subPath: appsettings.json
name: appconfig
{{ with .Values.apiServer.volumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: appconfig
configMap:
name: mcingress-appsettings
items:
- key: appsettings
path: appsettings.json
{{ with .Values.apiServer.volumes }}
{{- toYaml . | nindent 6 }}
{{- end }}

{{- with .Values.apiServer.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 6 }}
{{- end }}

{{- with .Values.apiServer.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}

{{- with .Values.apiServer.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

{{- end }}
13 changes: 13 additions & 0 deletions charts/multicluster-ingress/templates/api-server-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if and .Values.apiServer.enabled .Values.rbac.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: api-server
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: api-server
subjects:
- kind: ServiceAccount
name: {{ .Values.apiServer.serviceAccount.name }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/multicluster-ingress/templates/api-server-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if and .Values.apiServer.enabled .Values.rbac.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: api-server
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- apiGroups:
- multicluster.veccsolutions.io
verbs:
- '*'
resources:
- clustercaches
- hostnamecaches
- resourcecaches
{{- end }}
20 changes: 20 additions & 0 deletions charts/multicluster-ingress/templates/api-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ include "multiclusterIngress.name" . | trunc 40 }}-api-server"
labels:
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.apiServer.service.type }}
ports:
- port: {{ .Values.apiServer.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "multiclusterIngress.selectorLabels" . | nindent 4 }}
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/multicluster-ingress/templates/api-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: "{{ .Values.apiServer.serviceAccount.name }}"
labels:
{{- include "multiclusterIngress.labels" . | nindent 4 }}
{{- with .Values.apiServer.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.apiServer.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: false
Loading

0 comments on commit 72ee80f

Please sign in to comment.