Use more generic name "django" instead of glitchtip for template

variables
This commit is contained in:
David Burke 2021-02-19 20:20:53 +00:00
parent efc58de740
commit 976c6799dd
19 changed files with 233 additions and 201 deletions

View file

@ -1,21 +1,21 @@
1. Get the application URL by running these commands: 1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }} {{- if .Values.web.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }} {{- range $host := .Values.web.ingress.hosts }}
{{- range .paths }} {{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} http{{ if $.Values.web.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- else if contains "NodePort" .Values.service.type }} {{- else if contains "NodePort" .Values.web.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "glitchtip.fullname" . }}) export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "django.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }} {{- else if contains "LoadBalancer" .Values.web.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available. 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 "glitchtip.fullname" . }}' You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "django.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "glitchtip.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "django.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }} echo http://$SERVICE_IP:{{ .Values.web.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }} {{- else if contains "ClusterIP" .Values.web.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "glitchtip.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "django.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" echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }} {{- end }}

View file

@ -2,7 +2,7 @@
{{/* {{/*
Expand the name of the chart. Expand the name of the chart.
*/}} */}}
{{- define "glitchtip.name" -}} {{- define "django.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
@ -11,7 +11,7 @@ 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). 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. If release name contains chart name it will be used as a full name.
*/}} */}}
{{- define "glitchtip.fullname" -}} {{- define "django.fullname" -}}
{{- if .Values.fullnameOverride -}} {{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name.
{{/* {{/*
Create chart name and version as used by the chart label. Create chart name and version as used by the chart label.
*/}} */}}
{{- define "glitchtip.chart" -}} {{- define "django.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/* {{/*
Common labels Common labels
*/}} */}}
{{- define "glitchtip.labels" -}} {{- define "django.labels" -}}
helm.sh/chart: {{ include "glitchtip.chart" . }} helm.sh/chart: {{ include "django.chart" . }}
{{ include "glitchtip.selectorLabels" . }} {{ include "django.selectorLabels" . }}
{{- if .Chart.AppVersion }} {{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }} {{- end }}
@ -46,17 +46,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/* {{/*
Selector labels Selector labels
*/}} */}}
{{- define "glitchtip.selectorLabels" -}} {{- define "django.selectorLabels" -}}
app.kubernetes.io/name: {{ include "glitchtip.name" . }} app.kubernetes.io/name: {{ include "django.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}} {{- end -}}
{{/* {{/*
Create the name of the service account to use Create the name of the service account to use
*/}} */}}
{{- define "glitchtip.serviceAccountName" -}} {{- define "django.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}} {{- if .Values.serviceAccount.create -}}
{{ default (include "glitchtip.fullname" .) .Values.serviceAccount.name }} {{ default (include "django.fullname" .) .Values.serviceAccount.name }}
{{- else -}} {{- else -}}
{{ default "default" .Values.serviceAccount.name }} {{ default "default" .Values.serviceAccount.name }}
{{- end -}} {{- end -}}
@ -66,7 +66,7 @@ Create the name of the service account to use
Create a default fully qualified app name. 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). We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}} */}}
{{- define "glitchtip.postgresql.fullname" -}} {{- define "django.postgresql.fullname" -}}
{{- if .Values.postgresql.fullnameOverride -}} {{- if .Values.postgresql.fullnameOverride -}}
{{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
@ -74,11 +74,11 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- if contains $name .Release.Name -}} {{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
{{- printf "%s-%s" .Release.Name "glitchtip-postgresql" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Release.Name "django-postgresql" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- define "glitchtip.redis.fullname" -}} {{- define "django.redis.fullname" -}}
{{- if .Values.redis.fullnameOverride -}} {{- if .Values.redis.fullnameOverride -}}
{{- .Values.redis.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- .Values.redis.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
@ -86,7 +86,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- if contains $name .Release.Name -}} {{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
{{- printf "%s-%s" .Release.Name "glitchtip-redis" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Release.Name "django-redis" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
@ -94,9 +94,9 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{/* {{/*
Set redis host Set redis host
*/}} */}}
{{- define "glitchtip.redis.host" -}} {{- define "django.redis.host" -}}
{{- if .Values.redis.enabled -}} {{- if .Values.redis.enabled -}}
{{- template "glitchtip.redis.fullname" . -}}-redis-master {{- template "django.redis.fullname" . -}}-redis-master
{{- else -}} {{- else -}}
{{- .Values.redis.host | quote -}} {{- .Values.redis.host | quote -}}
{{- end -}} {{- end -}}
@ -105,16 +105,16 @@ Set redis host
{{/* {{/*
Set redis url Set redis url
*/}} */}}
{{- define "glitchtip.redis.url" -}} {{- define "django.redis.url" -}}
{{- if .Values.redis.enabled -}} {{- if .Values.redis.enabled -}}
redis://{{- template "glitchtip.redis.password" -}}{{- template "glitchtip.redis.fullname" . -}}-master redis://{{- template "django.redis.password" -}}{{- template "django.redis.fullname" . -}}-master
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{/* {{/*
Set redis port Set redis port
*/}} */}}
{{- define "glitchtip.redis.port" -}} {{- define "django.redis.port" -}}
{{- if .Values.redis.enabled -}} {{- if .Values.redis.enabled -}}
"6379" "6379"
{{- else -}} {{- else -}}

View file

@ -1,14 +1,16 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ include "glitchtip.fullname" . }}-beat name: {{ include "django.fullname" . }}-beat
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
app.kubernetes.io/component: beat
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
{{- include "glitchtip.selectorLabels" . | nindent 6 }} {{- include "django.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: beat
template: template:
metadata: metadata:
annotations: annotations:
@ -16,7 +18,8 @@ spec:
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
tag: "{{ .Values.image.tag }}" tag: "{{ .Values.image.tag }}"
labels: labels:
{{- include "glitchtip.selectorLabels" . | nindent 8 }} {{- include "django.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: beat
spec: spec:
{{- with .Values.imagePullSecrets }} {{- with .Values.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
@ -38,10 +41,6 @@ spec:
cpu: 1m cpu: 1m
memory: 32Mi memory: 32Mi
env: env:
- name: DEBUG
value: "False"
- name: STATIC_URL
value: /
- name: SERVER_ROLE - name: SERVER_ROLE
value: "beat" value: "beat"
{{- if .Values.redisURL }} {{- if .Values.redisURL }}
@ -53,14 +52,14 @@ spec:
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
key: redis-password key: redis-password
name: {{ include "glitchtip.fullname" . }}-redis name: {{ include "django.fullname" . }}-redis
- name: REDIS_HOST - name: REDIS_HOST
value: {{ template "glitchtip.redis.host" . }} value: {{ template "django.redis.host" . }}
- name: REDIS_PORT - name: REDIS_PORT
value: {{ template "glitchtip.redis.port" . }} value: {{ template "django.redis.port" . }}
{{- end }} {{- end }}
envFrom: envFrom:
- secretRef: - secretRef:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
- configMapRef: - configMapRef:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}

View file

@ -1,9 +1,9 @@
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
annotations: annotations:
"helm.sh/hook-weight": "-1" "helm.sh/hook-weight": "-1"
data: data:

View file

@ -1,9 +1,9 @@
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
annotations: annotations:
"helm.sh/hook": post-install,pre-upgrade "helm.sh/hook": post-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded

View file

@ -1,9 +1,9 @@
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
type: Opaque type: Opaque
data: data:
DATABASE_URL: {{ required "databaseURL is a required value." .Values.databaseURL | b64enc | quote }} DATABASE_URL: {{ required "databaseURL is a required value." .Values.databaseURL | b64enc | quote }}

View file

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

View file

@ -2,7 +2,11 @@
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: {{ include "glitchtip.serviceAccountName" . }} name: {{ include "django.serviceAccountName" . }}
labels: labels:
{{ include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
{{- end -}} {{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View file

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

View file

@ -1,19 +0,0 @@
{{- if .Values.web.hpa.enabled -}}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "glitchtip.fullname" . }}
labels:
app: {{ template "glitchtip.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
scaleTargetRef:
kind: Deployment
apiVersion: apps/v1
name: {{ template "glitchtip.fullname" . }}
minReplicas: {{ .Values.web.hpa.minpods }}
maxReplicas: {{ .Values.web.hpa.maxpods }}
targetCPUUtilizationPercentage: {{ .Values.web.hpa.cputhreshold }}
{{- end }}

View file

@ -1,15 +1,18 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}-web
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
app.kubernetes.io/component: web
spec: spec:
{{- if not .Values.web.autoscaling.enabled }}
replicas: {{ .Values.web.replicaCount }} replicas: {{ .Values.web.replicaCount }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
{{- include "glitchtip.selectorLabels" . | nindent 6 }} {{- include "django.selectorLabels" . | nindent 6 }}
role: web app.kubernetes.io/component: web
template: template:
metadata: metadata:
annotations: annotations:
@ -17,21 +20,21 @@ spec:
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
tag: "{{ .Values.image.tag }}" tag: "{{ .Values.image.tag }}"
labels: labels:
{{- include "glitchtip.selectorLabels" . | nindent 8 }} {{- include "django.selectorLabels" . | nindent 8 }}
role: web app.kubernetes.io/component: web
spec: spec:
{{- with .Values.imagePullSecrets }} {{- with .Values.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
serviceAccountName: {{ include "glitchtip.serviceAccountName" . }} serviceAccountName: {{ include "django.serviceAccountName" . }}
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
containers: containers:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
securityContext: securityContext:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
ports: ports:
- name: http - name: http
@ -54,10 +57,6 @@ spec:
resources: resources:
{{- toYaml .Values.web.resources | nindent 12 }} {{- toYaml .Values.web.resources | nindent 12 }}
env: env:
- name: DEBUG
value: "False"
- name: STATIC_URL
value: /
{{- if .Values.redisURL }} {{- if .Values.redisURL }}
- name: REDIS_URL - name: REDIS_URL
value: {{ .Values.redisURL }} value: {{ .Values.redisURL }}
@ -67,11 +66,11 @@ spec:
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
key: redis-password key: redis-password
name: {{ include "glitchtip.fullname" . }}-redis name: {{ include "django.fullname" . }}-redis
- name: REDIS_HOST - name: REDIS_HOST
value: {{ template "glitchtip.redis.host" . }} value: {{ template "django.redis.host" . }}
- name: REDIS_PORT - name: REDIS_PORT
value: {{ template "glitchtip.redis.port" . }} value: {{ template "django.redis.port" . }}
{{- end }} {{- end }}
- name: POD_IP - name: POD_IP
valueFrom: valueFrom:
@ -79,9 +78,9 @@ spec:
fieldPath: status.podIP fieldPath: status.podIP
envFrom: envFrom:
- secretRef: - secretRef:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
- configMapRef: - configMapRef:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
{{- with .Values.web.nodeSelector }} {{- with .Values.web.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}

28
templates/web/hpa.yaml Normal file
View file

@ -0,0 +1,28 @@
{{- if .Values.web.autoscaling.enabled -}}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "django.fullname" . }}-web
labels:
{{- include "django.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "django.fullname" . }}-web
minReplicas: {{ .Values.web.autoscaling.minReplicas }}
maxReplicas: {{ .Values.web.autoscaling.maxReplicas }}
metrics:
{{- if .Values.web.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.web.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.web.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.web.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View file

@ -1,6 +1,6 @@
{{- if .Values.ingress.enabled -}} {{- if .Values.web.ingress.enabled -}}
{{- $fullName := include "glitchtip.fullname" . -}} {{- $fullName := include "django.fullname" . -}}
{{- $svcPort := .Values.service.port -}} {{- $svcPort := .Values.web.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} {{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1 apiVersion: networking.k8s.io/v1beta1
{{- else -}} {{- else -}}
@ -10,15 +10,15 @@ kind: Ingress
metadata: metadata:
name: {{ $fullName }} name: {{ $fullName }}
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }} {{- with .Values.web.ingress.annotations }}
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.ingress.tls }} {{- if .Values.web.ingress.tls }}
tls: tls:
{{- range .Values.ingress.tls }} {{- range .Values.web.ingress.tls }}
- hosts: - hosts:
{{- range .hosts }} {{- range .hosts }}
- {{ . | quote }} - {{ . | quote }}
@ -27,13 +27,15 @@ spec:
{{- end }} {{- end }}
{{- end }} {{- end }}
rules: rules:
{{- range .Values.ingress.hosts }} {{- range .Values.web.ingress.hosts }}
- host: {{ .host | quote }} - host: {{ .host | quote }}
http: http:
paths: paths:
- pathType: ImplementationSpecific {{- range .paths }}
- path: {{ .path }}
backend: backend:
serviceName: {{ $fullName }} serviceName: {{ $fullName }}-web
servicePort: {{ $svcPort }} servicePort: {{ $svcPort }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View file

@ -3,14 +3,14 @@
apiVersion: policy/v1beta1 apiVersion: policy/v1beta1
kind: PodDisruptionBudget kind: PodDisruptionBudget
metadata: metadata:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}-web
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
spec: spec:
minAvailable: {{ .Values.web.budget.minAvailable }} minAvailable: {{ .Values.web.budget.minAvailable }}
selector: selector:
matchLabels: matchLabels:
{{- include "glitchtip.selectorLabels" . | nindent 6 }} {{- include "django.selectorLabels" . | nindent 6 }}
role: web app.kubernetes.io/component: web
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "django.fullname" . }}-web
labels:
{{- include "django.labels" . | nindent 4 }}
spec:
type: {{ .Values.web.service.type }}
ports:
- port: {{ .Values.web.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "django.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: web

View file

@ -1,19 +0,0 @@
{{- if .Values.worker.hpa.enabled -}}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "glitchtip.fullname" . }}-worker
labels:
app: {{ template "glitchtip.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
scaleTargetRef:
kind: Deployment
apiVersion: apps/v1
name: {{ template "glitchtip.fullname" . }}-worker
minReplicas: {{ .Values.worker.hpa.minpods }}
maxReplicas: {{ .Values.worker.hpa.maxpods }}
targetCPUUtilizationPercentage: {{ .Values.worker.hpa.cputhreshold }}
{{- end }}

View file

@ -1,14 +1,16 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ include "glitchtip.fullname" . }}-worker name: {{ include "django.fullname" . }}-worker
labels: labels:
{{- include "glitchtip.labels" . | nindent 4 }} {{- include "django.labels" . | nindent 4 }}
app.kubernetes.io/component: worker
spec: spec:
replicas: {{ .Values.worker.replicaCount }} replicas: {{ .Values.worker.replicaCount }}
selector: selector:
matchLabels: matchLabels:
{{- include "glitchtip.selectorLabels" . | nindent 6 }} {{- include "django.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: worker
template: template:
metadata: metadata:
annotations: annotations:
@ -16,7 +18,8 @@ spec:
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
tag: "{{ .Values.image.tag }}" tag: "{{ .Values.image.tag }}"
labels: labels:
{{- include "glitchtip.selectorLabels" . | nindent 8 }} {{- include "django.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: worker
spec: spec:
{{- with .Values.imagePullSecrets }} {{- with .Values.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
@ -33,10 +36,6 @@ spec:
resources: resources:
{{- toYaml .Values.worker.resources | nindent 12 }} {{- toYaml .Values.worker.resources | nindent 12 }}
env: env:
- name: DEBUG
value: "False"
- name: STATIC_URL
value: /
- name: SERVER_ROLE - name: SERVER_ROLE
value: "worker" value: "worker"
{{- if .Values.redisURL }} {{- if .Values.redisURL }}
@ -48,26 +47,26 @@ spec:
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
key: redis-password key: redis-password
name: {{ include "glitchtip.fullname" . }}-redis name: {{ include "django.fullname" . }}-redis
- name: REDIS_HOST - name: REDIS_HOST
value: {{ template "glitchtip.redis.host" . }} value: {{ template "django.redis.host" . }}
- name: REDIS_PORT - name: REDIS_PORT
value: {{ template "glitchtip.redis.port" . }} value: {{ template "django.redis.port" . }}
{{- end }} {{- end }}
envFrom: envFrom:
- secretRef: - secretRef:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
- configMapRef: - configMapRef:
name: {{ include "glitchtip.fullname" . }} name: {{ include "django.fullname" . }}
{{- with .Values.nodeSelector }} {{- with .Values.worker.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- with .Values.affinity }} {{- with .Values.worker.affinity }}
affinity: affinity:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- with .Values.tolerations }} {{- with .Values.worker.tolerations }}
tolerations: tolerations:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}

28
templates/worker/hpa.yaml Normal file
View file

@ -0,0 +1,28 @@
{{- if .Values.worker.autoscaling.enabled -}}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "django.fullname" . }}-worker
labels:
{{- include "django.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "django.fullname" . }}-worker
minReplicas: {{ .Values.worker.autoscaling.minReplicas }}
maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }}
metrics:
{{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View file

@ -22,25 +22,37 @@ environmentVariables:
GLITCHTIP_DOMAIN: https://example.com GLITCHTIP_DOMAIN: https://example.com
web: web:
replicaCount: 1 replicaCount: 2
hpa: autoscaling:
enabled: false enabled: false
cputhreshold: 70 minReplicas: 1
minpods: 2 maxReplicas: 10
maxpods: 4 targetCPUUtilizationPercentage: 80
# budget: # targetMemoryUtilizationPercentage: 80
# minAvailable: 1
budget:
minAvailable: 1
resources: resources:
{} limits:
# limits: cpu: 1000m
# cpu: 100m memory: 512Mi
# memory: 256Mi requests:
# requests: cpu: 100m
# cpu: 50m memory: 128Mi
# memory: 128Mi
nodeSelector: {} nodeSelector: {}
tolerations: [] tolerations: []
affinity: {} affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- glitchtip-prod-web
topologyKey: kubernetes.io/hostname
livenessProbe: livenessProbe:
failureThreshold: 5 failureThreshold: 5
initialDelaySeconds: 5 initialDelaySeconds: 5
@ -49,22 +61,39 @@ web:
failureThreshold: 10 failureThreshold: 10
initialDelaySeconds: 5 initialDelaySeconds: 5
timeoutSeconds: 2 timeoutSeconds: 2
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
worker: worker:
replicaCount: 1 replicaCount: 1
hpa: autoscaling:
enabled: false enabled: false
cputhreshold: 90 minReplicas: 1
minpods: 1 maxReplicas: 100
maxpods: 4 targetCPUUtilizationPercentage: 90
# targetMemoryUtilizationPercentage: 80
resources: resources:
{} limits:
# limits: cpu: 900m
# cpu: 500m memory: 768Mi
# memory: 256Mi requests:
# requests: cpu: 100m
# cpu: 100m memory: 128Mi
# memory: 128Mi
nodeSelector: {} nodeSelector: {}
tolerations: [] tolerations: []
affinity: {} affinity: {}
@ -76,24 +105,6 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template # If not set and create is true, a name is generated using the fullname template
name: name:
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
redis: redis:
enabled: true enabled: true
master: master: