├── README.md └── flask-chart ├── .helmignore ├── Chart.yaml ├── templates ├── NOTES.txt ├── _helpers.tpl ├── deployment.yaml ├── ingress.yaml └── service.yaml └── values.yaml /README.md: -------------------------------------------------------------------------------- 1 | # flask-chart 2 | 3 | Very simple chart for a Flask application. 4 | 5 | This helm chart defines a deployment, service, and (optional) ingress for a Flask application. 6 | 7 | The Flask application is assumed to be serving on port 5000, this port can be passed into the Docker run command with an environment variable. For a sample application that would run with this chart, check out [python-miniconda](https://github.com/heroku-examples/python-miniconda). 8 | -------------------------------------------------------------------------------- /flask-chart/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /flask-chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | description: Flask chart for Kubernetes 3 | name: flask-chart 4 | version: 0.1.0 5 | -------------------------------------------------------------------------------- /flask-chart/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | The url for this application: 2 | {{- range .Values.ingress.hosts }} 3 | http://{{ . }} 4 | {{- end }} 5 | -------------------------------------------------------------------------------- /flask-chart/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "flask-chart.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | */}} 13 | {{- define "flask-chart.fullname" -}} 14 | {{- $name := default .Chart.Name .Values.nameOverride -}} 15 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 16 | {{- end -}} 17 | -------------------------------------------------------------------------------- /flask-chart/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: {{ template "flask-chart.fullname" . }} 5 | labels: 6 | app: {{ template "flask-chart.name" . }} 7 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | spec: 11 | replicas: {{ .Values.replicaCount }} 12 | template: 13 | metadata: 14 | labels: 15 | app: {{ template "flask-chart.name" . }} 16 | release: {{ .Release.Name }} 17 | spec: 18 | containers: 19 | - name: {{ .Chart.Name }} 20 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 21 | imagePullPolicy: {{ .Values.image.pullPolicy }} 22 | env: 23 | - name: PORT 24 | value: "{{ .Values.service.internalPort }}" 25 | ports: 26 | - containerPort: {{ .Values.service.internalPort }} 27 | livenessProbe: 28 | httpGet: 29 | path: / 30 | port: {{ .Values.service.internalPort }} 31 | readinessProbe: 32 | httpGet: 33 | path: / 34 | port: {{ .Values.service.internalPort }} 35 | resources: 36 | {{ toYaml .Values.resources | indent 12 }} 37 | {{- if .Values.nodeSelector }} 38 | nodeSelector: 39 | {{ toYaml .Values.nodeSelector | indent 8 }} 40 | {{- end }} 41 | -------------------------------------------------------------------------------- /flask-chart/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | {{- $serviceName := include "flask-chart.fullname" . -}} 3 | {{- $servicePort := .Values.service.externalPort -}} 4 | apiVersion: extensions/v1beta1 5 | kind: Ingress 6 | metadata: 7 | name: {{ template "flask-chart.fullname" . }} 8 | labels: 9 | app: {{ template "flask-chart.name" . }} 10 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} 11 | release: {{ .Release.Name }} 12 | heritage: {{ .Release.Service }} 13 | annotations: 14 | {{- range $key, $value := .Values.ingress.annotations }} 15 | {{ $key }}: {{ $value | quote }} 16 | {{- end }} 17 | spec: 18 | rules: 19 | {{- range $host := .Values.ingress.hosts }} 20 | - host: {{ $host }} 21 | http: 22 | paths: 23 | - path: / 24 | backend: 25 | serviceName: {{ $serviceName }} 26 | servicePort: {{ $servicePort }} 27 | {{- end -}} 28 | {{- if .Values.ingress.tls }} 29 | tls: 30 | {{ toYaml .Values.ingress.tls | indent 4 }} 31 | {{- end -}} 32 | {{- end -}} 33 | -------------------------------------------------------------------------------- /flask-chart/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ template "flask-chart.fullname" . }} 5 | labels: 6 | app: {{ template "flask-chart.name" . }} 7 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | spec: 11 | ports: 12 | - port: {{ .Values.service.externalPort }} 13 | targetPort: {{ .Values.service.internalPort }} 14 | protocol: TCP 15 | name: {{ .Values.service.name }} 16 | selector: 17 | app: {{ template "flask-chart.name" . }} 18 | release: {{ .Release.Name }} 19 | -------------------------------------------------------------------------------- /flask-chart/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for flask-chart. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | replicaCount: 1 5 | image: 6 | repository: nginx 7 | tag: stable 8 | pullPolicy: IfNotPresent 9 | service: 10 | name: nginx 11 | externalPort: 80 12 | internalPort: 5000 13 | ingress: 14 | enabled: false 15 | # Used to create an Ingress record. 16 | hosts: 17 | - chart-example.local 18 | annotations: 19 | kubernetes.io/ingress.class: nginx 20 | kubernetes.io/tls-acme: "true" 21 | tls: 22 | - secretName: chart-example-tls 23 | hosts: 24 | - chart-example.local 25 | resources: {} 26 | --------------------------------------------------------------------------------