Skip to content

Commit

Permalink
Redirect helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Apr 8, 2020
1 parent fb10078 commit 12d718c
Show file tree
Hide file tree
Showing 13 changed files with 602 additions and 0 deletions.
22 changes: 22 additions & 0 deletions charts/redirect/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
21 changes: 21 additions & 0 deletions charts/redirect/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: redirect
description: Redirect Delpoyment

# 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.
version: 0.0.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: random
85 changes: 85 additions & 0 deletions charts/redirect/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define ".helm.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 ".helm.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 ".helm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define ".helm.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include ".helm.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Host rule
*/}}
{{- define ".helm.hostRule" -}}
- host: {{ .Host | quote }}
http:
paths:
- path: /
backend:
serviceName: {{ .FullName }}
servicePort: {{ .SvcPort }}
{{- end -}}

{{/*
Host TLS config
*/}}
{{- define ".helm.hostTLS" -}}
- hosts:
- {{ .Host | quote }}
secretName: tls-{{ .Host | replace "." "-" }}
{{- end -}}
14 changes: 14 additions & 0 deletions charts/redirect/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include ".helm.fullname" . }}
labels:
app: {{ include ".helm.fullname" . }}
data:
config.yaml: |
defaultFallbackTarget: {{ .Values.redirect.defaultFallbackTarget }}
buildin:
wwwToNonWww: {{ if eq .Values.redirect.buildin "wwwToNonWww" -}}true{{- else -}}false{{- end }}
nonWwwToWww: {{ if eq .Values.redirect.buildin "nonWwwToWww" -}}true{{- else -}}false{{- end }}
{{ if .Values.redirect.hosts -}}hosts:
{{- toYaml .Values.redirect.hosts | nindent 6 }}{{- end }}
74 changes: 74 additions & 0 deletions charts/redirect/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include ".helm.fullname" . }}
labels:
app: {{ include ".helm.fullname" . }}
release: {{ include ".helm.fullname" . }}
{{- include ".helm.labels" . | nindent 4 }}
{{- toYaml .Values.labels | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include ".helm.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: {{ .Values.service.metricsPort | quote}}
labels:
app: {{ include ".helm.fullname" . }}
release: {{ include ".helm.fullname" . }}
{{- include ".helm.selectorLabels" . | nindent 8 }}
{{- toYaml .Values.labels | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include ".helm.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
- name: http-metrics
containerPort: {{ .Values.service.metricsPort }}
protocol: TCP
livenessProbe:
httpGet:
path: /ping
port: http-metrics
readinessProbe:
httpGet:
path: /ping
port: http-metrics
volumeMounts:
- name: {{ include ".helm.fullname" . }}-configmap-volume
mountPath: /etc/redirect/
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: {{ include ".helm.fullname" . }}-configmap-volume
configMap:
name: {{ include ".helm.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 12d718c

Please sign in to comment.