diff options
| author | Max Resnick <max@ofmax.li> | 2019-09-22 09:23:20 -0700 |
|---|---|---|
| committer | Max Resnick <max@ofmax.li> | 2019-09-22 09:23:20 -0700 |
| commit | 479a617193774e2fe88279caa34ae3ff56a35fba (patch) | |
| tree | 6e42c80583e877bb58fda360bc1e17d626c1ba82 /grumpy/static-files/templates | |
| parent | 11d2384be92b00b830f4a0e4fdc9a8bf86b76d31 (diff) | |
| download | grumpy-charts-479a617193774e2fe88279caa34ae3ff56a35fba.tar.gz | |
add static files
Diffstat (limited to 'grumpy/static-files/templates')
| -rw-r--r-- | grumpy/static-files/templates/NOTES.txt | 21 | ||||
| -rw-r--r-- | grumpy/static-files/templates/_helpers.tpl | 56 | ||||
| -rw-r--r-- | grumpy/static-files/templates/deployment.yaml | 53 | ||||
| -rw-r--r-- | grumpy/static-files/templates/ingress.yaml | 37 | ||||
| -rw-r--r-- | grumpy/static-files/templates/service.yaml | 16 | ||||
| -rw-r--r-- | grumpy/static-files/templates/serviceaccount.yaml | 8 | ||||
| -rw-r--r-- | grumpy/static-files/templates/tests/test-connection.yaml | 15 |
7 files changed, 206 insertions, 0 deletions
diff --git a/grumpy/static-files/templates/NOTES.txt b/grumpy/static-files/templates/NOTES.txt new file mode 100644 index 0000000..ee24298 --- /dev/null +++ b/grumpy/static-files/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "static-files.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "static-files.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "static-files.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "static-files.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/grumpy/static-files/templates/_helpers.tpl b/grumpy/static-files/templates/_helpers.tpl new file mode 100644 index 0000000..dc26cf9 --- /dev/null +++ b/grumpy/static-files/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "static-files.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 "static-files.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 "static-files.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "static-files.labels" -}} +app.kubernetes.io/name: {{ include "static-files.name" . }} +helm.sh/chart: {{ include "static-files.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "static-files.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "static-files.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/grumpy/static-files/templates/deployment.yaml b/grumpy/static-files/templates/deployment.yaml new file mode 100644 index 0000000..da9d3c8 --- /dev/null +++ b/grumpy/static-files/templates/deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "static-files.fullname" . }} + labels: +{{ include "static-files.labels" . | indent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "static-files.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "static-files.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ template "static-files.serviceAccountName" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/grumpy/static-files/templates/ingress.yaml b/grumpy/static-files/templates/ingress.yaml new file mode 100644 index 0000000..cd442fa --- /dev/null +++ b/grumpy/static-files/templates/ingress.yaml @@ -0,0 +1,37 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "static-files.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: +{{ include "static-files.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/grumpy/static-files/templates/service.yaml b/grumpy/static-files/templates/service.yaml new file mode 100644 index 0000000..f83fa84 --- /dev/null +++ b/grumpy/static-files/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "static-files.fullname" . }} + labels: +{{ include "static-files.labels" . | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "static-files.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/grumpy/static-files/templates/serviceaccount.yaml b/grumpy/static-files/templates/serviceaccount.yaml new file mode 100644 index 0000000..da69bc1 --- /dev/null +++ b/grumpy/static-files/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "static-files.serviceAccountName" . }} + labels: +{{ include "static-files.labels" . | indent 4 }} +{{- end -}} diff --git a/grumpy/static-files/templates/tests/test-connection.yaml b/grumpy/static-files/templates/tests/test-connection.yaml new file mode 100644 index 0000000..b6b36f5 --- /dev/null +++ b/grumpy/static-files/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "static-files.fullname" . }}-test-connection" + labels: +{{ include "static-files.labels" . | indent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "static-files.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never |