From 308366ca60167cd5bd712e71b8e1a2d508433b21 Mon Sep 17 00:00:00 2001 From: David Burke Date: Sun, 9 Feb 2020 16:56:26 -0500 Subject: [PATCH] beat --- ...b-deployment.yaml => deployment-beat.yaml} | 53 +++++------ ...deployment.yaml => deployment-worker.yaml} | 23 ++++- templates/deployment.yaml | 90 +++++++++++++++++++ templates/web-hpa.yaml | 6 +- templates/worker-hpa.yaml | 2 +- values-sample.yaml | 14 +++ values.yaml | 20 +++-- 7 files changed, 168 insertions(+), 40 deletions(-) rename templates/{web-deployment.yaml => deployment-beat.yaml} (52%) rename templates/{worker-deployment.yaml => deployment-worker.yaml} (67%) create mode 100644 templates/deployment.yaml create mode 100644 values-sample.yaml diff --git a/templates/web-deployment.yaml b/templates/deployment-beat.yaml similarity index 52% rename from templates/web-deployment.yaml rename to templates/deployment-beat.yaml index 7cf24a1..e4c8992 100644 --- a/templates/web-deployment.yaml +++ b/templates/deployment-beat.yaml @@ -1,28 +1,25 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "glitchtip.fullname" . }}-web + name: {{ include "glitchtip.fullname" . }}-beat labels: {{- include "glitchtip.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount }} + replicas: 1 selector: matchLabels: {{- include "glitchtip.selectorLabels" . | nindent 6 }} - role: web template: metadata: + annotations: + checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} labels: {{- include "glitchtip.selectorLabels" . | nindent 8 }} - role: web - annotations: - checksum/secrets.yaml: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "glitchtip.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: @@ -31,31 +28,35 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 8080 - protocol: TCP resources: - {{- toYaml .Values.resources | nindent 12 }} + limits: + cpu: 50m + memory: 96Mi + requests: + cpu: 1m + memory: 32Mi env: - name: DEBUG value: "False" - name: STATIC_URL value: / - - name: ENABLE_SOCIAL_AUTH - value: {{ .Values.enableSocialAuth | quote }} + - name: SERVER_ROLE + value: "beat" + {{- if .Values.redisURL }} + - name: REDIS_URL + value: {{ .Values.redisURL }} + {{- end }} + {{- if .Values.redis.enabled }} + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + key: redis-password + name: {{ include "glitchtip.fullname" . }}-glitchtip-redis + - name: REDIS_HOST + value: {{ template "glitchtip.redis.host" . }} + - name: REDIS_PORT + value: {{ template "glitchtip.redis.port" . }} + {{- end }} envFrom: - secretRef: name: {{ include "glitchtip.fullname" . }} - {{- 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/templates/worker-deployment.yaml b/templates/deployment-worker.yaml similarity index 67% rename from templates/worker-deployment.yaml rename to templates/deployment-worker.yaml index ca8c0eb..7605d56 100644 --- a/templates/worker-deployment.yaml +++ b/templates/deployment-worker.yaml @@ -5,16 +5,16 @@ metadata: labels: {{- include "glitchtip.labels" . | nindent 4 }} spec: - replicas: {{ .Values.image.replicaCount }} + replicas: {{ .Values.worker.replicaCount }} selector: matchLabels: {{- include "glitchtip.selectorLabels" . | nindent 6 }} template: metadata: + annotations: + checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} labels: {{- include "glitchtip.selectorLabels" . | nindent 8 }} - annotations: - checksum/secrets.yaml: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: @@ -37,6 +37,21 @@ spec: value: / - name: SERVER_ROLE value: "worker" + {{- if .Values.redisURL }} + - name: REDIS_URL + value: {{ .Values.redisURL }} + {{- end }} + {{- if .Values.redis.enabled }} + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + key: redis-password + name: {{ include "glitchtip.fullname" . }}-glitchtip-redis + - name: REDIS_HOST + value: {{ template "glitchtip.redis.host" . }} + - name: REDIS_PORT + value: {{ template "glitchtip.redis.port" . }} + {{- end }} envFrom: - secretRef: name: {{ include "glitchtip.fullname" . }} @@ -51,4 +66,4 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} \ No newline at end of file + {{- end }} diff --git a/templates/deployment.yaml b/templates/deployment.yaml new file mode 100644 index 0000000..31a0f2d --- /dev/null +++ b/templates/deployment.yaml @@ -0,0 +1,90 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "glitchtip.fullname" . }} + labels: + {{- include "glitchtip.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.web.replicaCount }} + selector: + matchLabels: + {{- include "glitchtip.selectorLabels" . | nindent 6 }} + role: web + template: + metadata: + annotations: + checksum/secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} + labels: + {{- include "glitchtip.selectorLabels" . | nindent 8 }} + role: web + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "glitchtip.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }} + httpGet: + path: /_health/ + port: 8080 + initialDelaySeconds: {{ .Values.web.livenessProbe.initialDelaySeconds }} + timeoutSeconds: {{ .Values.web.livenessProbe.timeoutSeconds }} + readinessProbe: + failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }} + httpGet: + path: /_health/ + port: 8080 + initialDelaySeconds: {{ .Values.web.readinessProbe.initialDelaySeconds }} + timeoutSeconds: {{ .Values.web.readinessProbe.timeoutSeconds }} + resources: + {{- toYaml .Values.web.resources | nindent 12 }} + env: + - name: DEBUG + value: "False" + - name: STATIC_URL + value: / + - name: ENABLE_SOCIAL_AUTH + value: {{ .Values.enableSocialAuth | quote }} + {{- if .Values.redisURL }} + - name: REDIS_URL + value: {{ .Values.redisURL }} + {{- end }} + {{- if .Values.redis.enabled }} + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + key: redis-password + name: {{ include "glitchtip.fullname" . }}-glitchtip-redis + - name: REDIS_HOST + value: {{ template "glitchtip.redis.host" . }} + - name: REDIS_PORT + value: {{ template "glitchtip.redis.port" . }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "glitchtip.fullname" . }} + {{- with .Values.web.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.web.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.web.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/templates/web-hpa.yaml b/templates/web-hpa.yaml index ebe36ac..f24629d 100644 --- a/templates/web-hpa.yaml +++ b/templates/web-hpa.yaml @@ -2,7 +2,7 @@ apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: - name: {{ template "glitchtip.fullname" . }}-web + name: {{ template "glitchtip.fullname" . }} labels: app: {{ template "glitchtip.fullname" . }} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" @@ -12,8 +12,8 @@ spec: scaleTargetRef: kind: Deployment apiVersion: apps/v1 - name: {{ template "glitchtip.fullname" . }}-web + name: {{ template "glitchtip.fullname" . }} minReplicas: {{ .Values.web.hpa.minpods }} maxReplicas: {{ .Values.web.hpa.maxpods }} targetCPUUtilizationPercentage: {{ .Values.web.hpa.cputhreshold }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/templates/worker-hpa.yaml b/templates/worker-hpa.yaml index 86a3672..237977b 100644 --- a/templates/worker-hpa.yaml +++ b/templates/worker-hpa.yaml @@ -16,4 +16,4 @@ spec: minReplicas: {{ .Values.worker.hpa.minpods }} maxReplicas: {{ .Values.worker.hpa.maxpods }} targetCPUUtilizationPercentage: {{ .Values.worker.hpa.cputhreshold }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/values-sample.yaml b/values-sample.yaml new file mode 100644 index 0000000..7c68fc1 --- /dev/null +++ b/values-sample.yaml @@ -0,0 +1,14 @@ +web: + hpa: + enabled: true + resources: + limits: + cpu: 1000m + memory: 512Mi + requests: + cpu: 100m + memory: 128Mi + +worker: + hpa: + enabled: true diff --git a/values.yaml b/values.yaml index 61b45eb..3776ccb 100644 --- a/values.yaml +++ b/values.yaml @@ -12,7 +12,7 @@ nameOverride: "" fullnameOverride: "" databaseURL: secretKey: -# redisURL: +redisURL: enableSocialAuth: false web: @@ -20,18 +20,26 @@ web: hpa: enabled: false cputhreshold: 60 - minpods: 1 - maxpods: 10 + minpods: 2 + maxpods: 5 resources: {} # limits: - # cpu: 500m - # memory: 512Mi - # requests: # cpu: 100m + # memory: 256Mi + # requests: + # cpu: 50m # memory: 128Mi nodeSelector: {} tolerations: [] affinity: {} + livenessProbe: + failureThreshold: 5 + initialDelaySeconds: 5 + timeoutSeconds: 2 + readinessProbe: + failureThreshold: 10 + initialDelaySeconds: 5 + timeoutSeconds: 2 worker: replicaCount: 1