Valley Path chart, first try

This commit is contained in:
Hendrik Leidinger 2022-01-12 19:36:42 +01:00
parent bd41dff84e
commit 07c1849b4a
28 changed files with 291 additions and 521 deletions

View file

@ -1,24 +0,0 @@
apiVersion: v1
name: django-nginx-uwsgi
icon: https://apsl.github.io/kubernetes-charts/images/django-nginx-uwsgi.png
version: 0.4.4
keywords:
- django
- nginx
- uwsgi
- crons
- rq
- celery
- celery-beat
description: >
A Chart for a simple architecture of an app deploying over K8s using nginx and uwsgi in the same pod.
So, it depends of nginx-uwsgi packages for the app, uwsgi for crons, rq or celery and redis package.
mantainers:
- name: Tomeu Canyelles
email: bcanyelles@apsl.net
- name: Pau Rul.lan
email: prullan@apsl.net
- name: Edu Herraiz
email: eherraiz@apsl.net
- name: Marc Tudurí
email: mtuduri@apsl.net

View file

@ -1 +0,0 @@
# In progress...

View file

@ -1,3 +0,0 @@
# Django
Deploy a full Django based application with Nginx and uWSGI stack.

View file

@ -1,200 +0,0 @@
questions:
# Images
- variable: global.image.uwsgi
label: uWSGI image
type: string
group: Images
- variable: global.image.nginx
label: Nginx image
type: string
group: Images
- variable: global.image.tag
label: Image tag
description: The tag for nginx & uwsgi images
type: string
default: "latest"
group: Images
# Databases
- variable: app.databaseController.enabled
label: Automatic database configuration
type: boolean
default: "true"
show_subquestion_if: "false && global.databaseController.secret.shared=false"
group: Database
subquestions:
- variable: app.configMap.databaseName
label: Database name
type: string
- variable: app.configMap.databasePort
label: Database port
type: string
default: "6543"
- variable: app.configMap.databaseUser
label: Database username
type: string
- variable: app.secrets.passwordDB
label: Database password
type: password
- variable: global.databaseController.secret.shared
label: Use common secrets
description: Use secrets generated by database controller
type: boolean
default: "true"
group: Database
- variable: global.cloudSql.host
label: CloudSQL database host
type: string
default: "10.7.0.3"
group: Database
# Main settings
- variable: app.configMap.enableSentry
label: Enable Sentry DSN
type: enum
options:
- "True"
- "False"
default: "True"
group: Main settings
show_subquestion_if: "True"
subquestions:
- variable: app.secrets.sentryDSN
label: Sentry DSN
type: string
- variable: app.configMap.compressEnabled
label: Compress enabled
type: enum
options:
- "True"
- "False"
default: "True"
group: Main settings
- variable: app.configMap.compressOffline
label: Compress offline
type: enum
options:
- "True"
- "False"
default: "True"
group: Main settings
- variable: app.configMap.allowedHosts
label: Allowed hosts
type: string
default: "*"
group: Main settings
- variable: app.configMap.enableBasicAuth
description: Use demo/demo to login
label: Use Basic auth
type: enum
options:
- "True"
- "False"
default: "False"
group: Main settings
- variable: app.configMap.enable3wRedirect
label: Enable www redirect
type: enum
options:
- "True"
- "False"
default: "False"
group: Main settings
- variable: app.configMap.enableHttpsRedirect
label: Enable https redirect
type: enum
options:
- "True"
- "False"
default: "False"
group: Main settings
# Migrations
- variable: migrations.enabled
label: Use pod for migrations
description: "Is recommended choose only one option: pods or cronjob as migration executor"
type: boolean
default: "false"
group: Migrations
- variable: cronjob.enabled
label: Use cron-job for migrations
type: boolean
default: "true"
group: Migrations
- variable: migrations.deployment.probes.readiness.timeout
label: Timeout for readiness probe request
type: int
default: 5
show_if: "migrations.enabled=true"
group: Migrations
- variable: migrations.deployment.probes.readiness.period
label: Time between readiness probe request
type: int
default: 30
show_if: "migrations.enabled=true"
group: Migrations
# Redis
- variable: redis.enabled
description: This value create a new redis pod
label: Use unhosted redis
type: boolean
default: "false"
group: Redis
- variable: app.deployment.redis.host
label: Redis host
type: string
default: "10.0.0.3"
show_if: "redis.enabled=false"
group: Redis
- variable: app.deployment.redis.port
label: Redis port
type: string
default: "6379"
group: Redis
- variable: app.deployment.redis.database
label: Redis database
type: string
default: "1"
show_if: "redis.enabled=false"
group: Redis
# Extra components
- variable: varnish.enabled
label: Use Varnish
type: boolean
default: "false"
group: Extra Components
- variable: crons.enabled
label: Use Crons
type: boolean
default: "false"
group: Extra Components
- variable: celery.enabled
label: Use Celery
type: boolean
default: "false"
group: Extra Components
- variable: rq.enabled
label: Use RQ
type: boolean
default: "false"
group: Extra Components
# Celery settings
- variable: global.celery.brokerUrl
label: Celery broker url
type: string
default: "redis://10.0.0.3:6379/1"
show_if: "celery.enabled=true"
group: Celery settings
- variable: celery-beat.enabled
label: Use Celery Beat
type: boolean
default: "false"
show_if: "celery.enabled=true"
group: Celery settings

View file

@ -1,27 +0,0 @@
dependencies:
- name: nginx-uwsgi
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.4.3
- name: uwsgi
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.4.4
- name: uwsgi
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.4.4
- name: django-celery
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.1.2
- name: django-celery
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.1.2
- name: varnish
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.1.0
- name: redis
repository: https://charts.helm.sh/stable
version: 0.8.0
- name: uwsgi
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
version: 0.4.4
digest: sha256:5178f387e3ab951e49867fa6370e1785f6bc43dbb8dcfc84503305887bf43dd2
generated: "2021-01-11T16:06:56.133014619+01:00"

View file

@ -1,45 +0,0 @@
dependencies:
- name: nginx-uwsgi
version: 0.4.3
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
alias: app
- name: uwsgi
version: 0.4.4
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
alias: crons
condition: crons.enabled
- name: uwsgi
version: 0.4.4
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
alias: rq
condition: rq.enabled
- name: django-celery
version: 0.1.2
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
alias: celery
condition: celery.enabled
- name: django-celery
version: 0.1.2
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
alias: celery-beat
condition: celery-beat.enabled
- name: varnish
version: 0.1.0
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
condition: varnish.enabled
- name: redis
version: 0.8.0
repository: https://charts.helm.sh/stable
condition: redis.enabled
- name: uwsgi
version: 0.4.4
repository: https://raw.githubusercontent.com/APSL/kubernetes-charts/master/packages
alias: migrations
condition: migrations.enabled

View file

@ -1,4 +0,0 @@
This chart "{{ template "name" . }}" details a deploy which contains three pods:
1. Application
2. Nginx container
2. Proxy to SQL instance of GCE

View file

@ -1,24 +0,0 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "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).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default release name truncated at 63 chars.
*/}}
{{- define "releasename" -}}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View file

@ -1,67 +0,0 @@
{{- if .Values.cronjob.enabled }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ .Release.Name }}-migrations
namespace: {{ .Release.Namespace }}
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 1
schedule: "{{ .Values.cronjob.schedule }}"
suspend: {{ .Values.cronjob.suspend }}
jobTemplate:
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- args:
{{- if .Values.cronjob.migrations.enabled }}
- launch-migrations
{{- else }}
- echo
- "Job done"
{{- end }}
envFrom:
- configMapRef:
name: {{ .Release.Name }}
- secretRef:
name: {{ .Release.Name }}
env:
{{- if .Values.app.deployment.pgBouncer.enabled }}
- name: DATABASE_HOST
value: {{ .Values.global.cloudSql.host }}
- name: DATABASE_PORT
value: "{{ .Values.global.configMap.databasePort }}"
{{- end }}
{{- if .Values.global.databaseController.secret.shared }}
- name: DATABASE_NAME
valueFrom:
secretKeyRef:
name: {{ .Values.global.databaseController.secret.name }}-{{ .Release.Name }}
key: database-name
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: {{ .Values.global.databaseController.secret.name }}-{{ .Release.Name }}
key: database-user
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.global.databaseController.secret.name }}-{{ .Release.Name }}
key: database-password
{{- end }}
image: {{ .Values.global.image.uwsgi }}:{{ .Values.global.image.tag }}
imagePullPolicy: Always
name: {{ .Release.Name }}-migrations
resources:
limits:
cpu: 250m
memory: 512Mi
requests:
cpu: 25m
memory: 100Mi
{{- end }}

View file

@ -1,123 +0,0 @@
# Default values for django app
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
.commons: &commons
secrets:
enabled: false
service:
enabled: false
configMap:
enabled: false
strategy:
type: Recreate
probes:
liveness:
enabled: false
readiness:
enabled: false
global:
image:
uwsgi: ""
nginx: ""
tag: ""
dataSecrets:
dataConfigMap:
cloudSql:
host: ""
secrets:
passwordDB: ""
sentryDSN: ""
configMap:
databaseHost: "127.0.0.1"
databasePort: "5432"
databaseController:
secret:
shared: false
cronjob:
enabled: true
suspend: true
schedule: "0 6 * * 1-5"
migrations:
enabled: true
app:
deployment:
pgBouncer:
enabled: true
crons:
enabled: true
crons:
enabled: true
<<: *commons
deployment:
probes:
liveness:
enabled: false
readiness:
enabled: true
migrations:
enabled: false
migrations:
enabled: true
<<: *commons
deployment:
probes:
liveness:
enabled: false
readiness:
enabled: true
celery:
enabled: false
<<: *commons
celery-beat:
enabled: false
<<: *commons
deployment:
args:
- run-celery-beat
probes:
liveness:
args: launch-celery-beat-liveness-probe
metrics:
enabled: false
rq:
enabled: false
djangoRQ:
enabled: true
<<: *commons
redis:
enabled: false
image: redis:3.0.7
usePassword: false
persistence:
enabled: false
resources:
limits:
cpu: 50m
memory: 256Mi
requests:
cpu: 50m
memory: 128Mi
# BackendHost takes release name as a prefix: {{ RELEASE_NAME-backendHost }}
varnish:
enabled: true
backendHost: ""

View file

@ -1,3 +0,0 @@
categories:
- generic
icon_url: "https://raw.githubusercontent.com/APSL/kubernetes-charts/master/images/django-nginx-uwsgi.png"

View file

@ -14,8 +14,10 @@
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View file

@ -0,0 +1,24 @@
apiVersion: v2
name: vp-web
description: Valley-Path Software Company website
# 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.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.0.0"

View file

@ -0,0 +1,3 @@
# Valley Path Web
Valley Path Software Company Website

View file

@ -0,0 +1,11 @@
groups:
- name: "Network"
description: "Specify Network settings"
questions:
- variable: service.port
label: "External Port"
description: "Port for exposing the service"
group: "Network"
schema:
type: int
required: true

View file

@ -0,0 +1,22 @@
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 }}{{ .path }}
{{- 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 "vp-web.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 "vp-web.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "vp-web.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
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 "vp-web.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}

View file

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "vp-web.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 "vp-web.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 "vp-web.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "vp-web.labels" -}}
helm.sh/chart: {{ include "vp-web.chart" . }}
{{ include "vp-web.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "vp-web.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vp-web.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "vp-web.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "vp-web.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "vp-web.fullname" . }}
labels:
{{- include "vp-web.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "vp-web.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "vp-web.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: app
image: "hleiding/uwsgi-new"
imagePullPolicy: IfNotPresent
- name: web
image: "hleiding/nginx"
imagePullPolicy: IfNotPresent

View file

@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "vp-web.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "vp-web.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- 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: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,31 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "vp-web.fullname" . }}
labels:
{{- include "vp-web.labels" . | nindent 4 }}
spec:
selector:
{{- include "vp-web.selectorLabels" . | nindent 4 }}
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: {{ .Values.service.port }}
type: {{ .Values.service.type }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "vp-web.fullname" . }}
labels:
{{- include "vp-web.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "vp-web.selectorLabels" . | nindent 4 }}

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "vp-web.fullname" . }}-test-connection"
labels:
{{- include "vp-web.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "vp-web.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View file

@ -0,0 +1,32 @@
# Default values for vp-web.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
service:
type: ClusterIP
port: 32001
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: valley-path.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

3
charts/vp-web/item.yaml Normal file
View file

@ -0,0 +1,3 @@
categories:
- generic
icon_url: "https://www.fullstackpython.com/img/logos/uwsgi.png"