-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90f569d
commit 8d2bf9f
Showing
13 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 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 | ||
|
||
# Example k8s files | ||
secrets/ | ||
|
||
# CI released files | ||
ci/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v2 | ||
name: default-backend | ||
description: A Helm chart for Kubernetes | ||
home: https://github.com/wyrihaximusnet/docker-default-backend | ||
icon: https://helm.wyrihaximus.net/images/charts/default-backend.png | ||
type: application | ||
version: 0.1.0 | ||
appVersion: random | ||
maintainers: | ||
- name: WyriHaximus | ||
email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Default Backend | ||
|
||
Opinionated helm chart for [`wyrihaximusnet/default-backend`](https://github.com/wyrihaximusnet/docker-default-backend). | ||
|
||
## Provided tags | ||
|
||
* `random` - Each time when the images are build a random image is selected and build, plus every hour an image is retagged as `random` and pushed. | ||
* `images/*` - For each directory inside [`images/`](https://github.com/WyriHaximusNet/docker-default-backend/tree/master/images). | ||
|
||
## Configuration | ||
|
||
This chart has very little configuration, it runs without any. But it is reccomended to set the number of replica's | ||
(until autoscaling support has been added), and optionally configure ingress hosts. Listed below is my personal | ||
configuration. Both [`k8s.wyrihaximus.net`](https://k8s.wyrihaximus.net/) and | ||
[`default-backend.k8s.wyrihaximus.net`](https://default-backend.k8s.wyrihaximus.net/) are active, refresh the pages a | ||
few times. | ||
```yaml | ||
replicas: 3 | ||
|
||
ingress: | ||
hosts: | ||
- k8s.wyrihaximus.net | ||
- default-backend.k8s.wyrihaximus.net | ||
``` | ||
## Opinionated decisions | ||
* Ports are hardcoded to `6969` for the service, and `9696` for the metrics. | ||
* TLS is assumed to be required, and is set up based on supplied hosts in `ingress.hosts`. | ||
* It's assumed that this helm chart will be run in it's own namespace, so the naming for all resources is kept as simple as possible. | ||
* Prometheus export annotations are added for metric scraping. | ||
* The default tag is random to randomly cycle through the different `404` pages. | ||
* Comes with a pod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
replicas: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "default-backend.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 "default-backend.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 -}} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "default-backend.labels" -}} | ||
helm.sh/chart: {{ include "default-backend.chart" . }} | ||
{{ include "default-backend.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "default-backend.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "default-backend.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end -}} | ||
|
||
{{- define "default-backend.nameRevision" -}} | ||
{{ template "default-backend.name" . }}___{{ .Release.Revision }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "default-backend.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "default-backend.fullname" . }} | ||
labels: | ||
app: {{ template "default-backend.name" . }} | ||
appRevision: {{ template "default-backend.nameRevision" . }} | ||
chart: {{ template "default-backend.chart" . }} | ||
release: {{ .Release.Name }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
heritage: {{ .Release.Service }} | ||
app.kubernetes.io/component: controller | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: {{ template "default-backend.name" . }} | ||
release: {{ .Release.Name }} | ||
replicas: {{ .Values.replicas }} | ||
template: | ||
metadata: | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: "9696" | ||
labels: | ||
app: {{ template "default-backend.name" . }} | ||
appRevision: {{ template "default-backend.nameRevision" . }} | ||
release: {{ .Release.Name }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
spec: | ||
containers: | ||
- name: default-backend | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- name: default-backend | ||
containerPort: 6969 | ||
protocol: TCP | ||
- name: metrics | ||
containerPort: 9696 | ||
protocol: TCP | ||
livenessProbe: | ||
failureThreshold: 6 | ||
httpGet: | ||
path: / | ||
port: metrics | ||
readinessProbe: | ||
failureThreshold: 6 | ||
httpGet: | ||
path: / | ||
port: metrics | ||
startupProbe: | ||
httpGet: | ||
path: / | ||
port: metrics | ||
failureThreshold: 90 | ||
periodSeconds: 1 | ||
resources: | ||
{{ toYaml .Values.resources | indent 12 }} | ||
affinity: | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: appRevision | ||
operator: In | ||
values: | ||
- {{ template "default-backend.nameRevision" . }} | ||
topologyKey: "kubernetes.io/hostname" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{{- if not (empty .Values.ingress.hosts) -}} | ||
{{- $chartName := .Chart.Name -}} | ||
{{- $fullName := include "default-backend.fullname" . -}} | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: {{ $fullName }} | ||
labels: | ||
app: {{ template "default-backend.name" . }} | ||
chart: {{ template "default-backend.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
{{- with .Values.ingress.annotations }} | ||
annotations: | ||
{{ toYaml . | indent 4 }} | ||
{{- end }} | ||
spec: | ||
tls: | ||
{{- range .Values.ingress.hosts }} | ||
- hosts: | ||
- {{ . }} | ||
secretName: tls-{{ . | replace "." "-" }} | ||
{{- end }} | ||
rules: | ||
{{- range .Values.ingress.hosts }} | ||
- host: {{ . }} | ||
http: | ||
paths: | ||
- path: / | ||
backend: | ||
serviceName: {{ $fullName }} | ||
servicePort: default-backend | ||
{{- end }} | ||
{{ end }} |
12 changes: 12 additions & 0 deletions
12
charts/default-backend/templates/pod-disruption-budget.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- if gt (.Values.replicas | int) 1 -}} | ||
apiVersion: policy/v1beta1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ template "default-backend.fullname" . }} | ||
spec: | ||
maxUnavailable: 1 | ||
selector: | ||
matchLabels: | ||
app: {{ include "default-backend.fullname" . }} | ||
release: {{ include "default-backend.fullname" . }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ template "default-backend.fullname" . }} | ||
labels: | ||
app: {{ template "default-backend.name" . }} | ||
appRevision: {{ template "default-backend.nameRevision" . }} | ||
chart: {{ template "default-backend.chart" . }} | ||
release: {{ .Release.Name }} | ||
releaseRevision: {{ .Release.Revision | quote }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 6969 | ||
targetPort: default-backend | ||
protocol: TCP | ||
name: default-backend | ||
- port: 9696 | ||
targetPort: metrics | ||
protocol: TCP | ||
name: metrics | ||
selector: | ||
app: {{ template "default-backend.name" . }} | ||
release: {{ .Release.Name }} |
13 changes: 13 additions & 0 deletions
13
charts/default-backend/templates/tests/test-default-backend-connection.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ include "default-backend.fullname" . }}-test-default-backend-connection" | ||
annotations: | ||
"helm.sh/hook": test-success | ||
spec: | ||
containers: | ||
- name: wget | ||
image: alpine | ||
command: ['nc'] | ||
args: ['-zv','{{ include "default-backend.fullname" . }}:6969'] | ||
restartPolicy: Never |
13 changes: 13 additions & 0 deletions
13
charts/default-backend/templates/tests/test-metrics-connection.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ include "default-backend.fullname" . }}-test-metrics-connection" | ||
annotations: | ||
"helm.sh/hook": test-success | ||
spec: | ||
containers: | ||
- name: wget | ||
image: busybox | ||
command: ['wget'] | ||
args: ['{{ include "default-backend.fullname" . }}:9696'] | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
image: | ||
repository: wyrihaximusnet/default-backend | ||
tag: random | ||
pullPolicy: Always | ||
|
||
ingress: | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
kubernetes.io/tls-acme: "true" | ||
hosts: [] | ||
|
||
replicas: 2 | ||
|
||
resources: | ||
limits: | ||
cpu: 75m | ||
memory: 64Mi | ||
requests: | ||
cpu: 75m | ||
memory: 64Mi |