Commit e2060a7e authored by Geoff Simmons's avatar Geoff Simmons

Package the "hello world" example as a helm chart. Passes verify.sh.

parent 204d5a20
# 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
apiVersion: v2
name: viking-ingress
version: 0.1.0
description: Ingress and backend Services/Deployments using Viking Ingress
engine: gotpl
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "viking-ingress.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "viking-ingress.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | 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).
*/}}
{{- define "viking-ingress.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 "viking-ingress.labels" -}}
helm.sh/chart: {{ include "viking-ingress.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{ range $name, $app := .Values.apps }}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: {{ $name }}
app.kubernetes.io/component: ingressBackend
helm.sh/chart: {{ printf "%s-%s" $.Chart.Name $.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- if $.Chart.AppVersion }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/instance: {{ $.Release.Name }}
name: {{ $name }}
spec:
replicas: {{ default "1" $app.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ $name }}
app.kubernetes.io/instance: {{ $.Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ $name }}
app.kubernetes.io/component: ingressBackend
helm.sh/chart: {{ printf "%s-%s" $.Chart.Name $.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- if $.Chart.AppVersion }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
containers:
- name: {{ $name }}
image: {{ $app.image }}
ports:
- containerPort: {{ default "80" $app.containerPort }}
---
{{ end }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ include "viking-ingress.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "viking-ingress.name" . }}
app.kubernetes.io/component: ingress
{{- include "viking-ingress.labels" . | nindent 4 }}
annotations:
kubernetes.io/ingress.class: {{ .Values.ingress.class }}
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
rules:
{{- range $rule := .Values.ingress.rules }}
- host: {{ $rule.host }}
http:
paths:
{{- range $path := $rule.paths }}
- path: {{ $path.path }}
backend:
serviceName: {{ $path.app }}-svc
servicePort: {{ default "80" $path.servicePort }}
{{- end }}
{{- end }}
{{ range $name, $app := .Values.apps }}
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: {{ $name }}-svc
app.kubernetes.io/component: ingressBackend
helm.sh/chart: {{ printf "%s-%s" $.Chart.Name $.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- if $.Chart.AppVersion }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/instance: {{ $.Release.Name }}
name: {{ $name }}-svc
spec:
ports:
- port: {{ default "80" $app.servicePort }}
targetPort: {{ default "80" $app.targetPort }}
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ $name }}
app.kubernetes.io/component: ingressBackend
app.kubernetes.io/instance: {{ $.Release.Name }}
---
{{ end }}
# Map of Ingress backend apps, keys are app names.
apps:
example:
image: uplex/http-echo
# replicas: 1
## containerPort for the pod template ports spec
## servicePort for Service spec.ports.port
## targetPort for Service spec.ports.targetPort
# containerPort: 80
# servicePort: 80
# targetPort: 80
ingress:
# Must match the Ingress class observed by the controller.
class: "varnish"
# Ingress rules
rules:
- host: example.com
paths:
- path: /
app: example
# servicePort: 80
\ No newline at end of file
#! /bin/bash -ex
helm install viking-ingress ./charts --values values.yaml
#! /bin/bash -ex
MYDIR=$(dirname ${BASH_SOURCE[0]})
source ${MYDIR}/../../test/utils.sh
helm uninstall viking-ingress
echo "Waiting until varnish-ingress Pods are not configured for Ingress"
wait_until_not_configured app=varnish-ingress
apps:
coffee:
image: nginxdemos/hello:plain-text
replicas: 2
tea:
image: nginxdemos/hello:plain-text
replicas: 3
ingress:
rules:
- host: cafe.example.com
paths:
- path: /tea
app: tea
- path: /coffee
app: coffee
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment