deployment.yaml 7.97 KB
Newer Older
Dominik Hebeler's avatar
Dominik Hebeler committed
1
{{- if not .Values.application.initializeCommand -}}
2
apiVersion: {{ default "extensions/v1beta1" .Values.deploymentApiVersion }}
Dominik Hebeler's avatar
Dominik Hebeler committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
kind: Deployment
metadata:
  name: {{ template "trackableappname" . }}
  annotations:
    {{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
    {{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
  labels:
    app: {{ template "appname" . }}
    track: "{{ .Values.application.track }}"
    tier: "{{ .Values.application.tier }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
17 18 19 20 21 22 23 24
{{- if or .Values.enableSelector (eq (default "extensions/v1beta1" .Values.deploymentApiVersion) "apps/v1") }}
  selector:
    matchLabels:
      app: {{ template "appname" . }}
      track: "{{ .Values.application.track }}"
      tier: "{{ .Values.application.tier }}"
      release: {{ .Release.Name }}
{{- end }}
Dominik Hebeler's avatar
Dominik Hebeler committed
25
  replicas: {{ .Values.replicaCount }}
26 27 28 29
{{- if .Values.strategyType }}
  strategy:
    type: {{ .Values.strategyType | quote }}
{{- end }}
Dominik Hebeler's avatar
Dominik Hebeler committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  template:
    metadata:
      annotations:
        checksum/application-secrets: "{{ .Values.application.secretChecksum }}"
        {{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
        {{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
      labels:
        app: {{ template "appname" . }}
        track: "{{ .Values.application.track }}"
        tier: "{{ .Values.application.tier }}"
        release: {{ .Release.Name }}
    spec:
      imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
      containers:
Dominik Hebeler's avatar
Dominik Hebeler committed
48 49 50 51 52 53 54 55 56 57
      - name: {{ .Chart.Name }}-phpfpm
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        {{- if .Values.application.secretName }}
        envFrom:
        - secretRef:
            name: {{ .Values.application.secretName }}
        {{- end }}
        env:
        - name: DATABASE_URL
Dominik Hebeler's avatar
Dominik Hebeler committed
58
          value: {{ .Values.application.database_url | quote }}
Dominik Hebeler's avatar
Dominik Hebeler committed
59
        - name: GITLAB_ENVIRONMENT_NAME
Dominik Hebeler's avatar
Dominik Hebeler committed
60
          value: {{ .Values.gitlab.envName }}
Dominik Hebeler's avatar
Dominik Hebeler committed
61
        - name: GITLAB_ENVIRONMENT_URL
Dominik Hebeler's avatar
Dominik Hebeler committed
62
          value: {{ .Values.gitlab.envURL }}
Dominik Hebeler's avatar
Dominik Hebeler committed
63 64
        ports:
        - name: "{{ .Values.service.name }}-phpfpm"
Dominik Hebeler's avatar
Dominik Hebeler committed
65
          containerPort: 9000
Dominik Hebeler's avatar
Dominik Hebeler committed
66
        livenessProbe:
Dominik Hebeler's avatar
Dominik Hebeler committed
67
          tcpSocket:
Dominik Hebeler's avatar
Dominik Hebeler committed
68
            port: "{{ .Values.service.name }}-phpfpm"
Dominik Hebeler's avatar
Dominik Hebeler committed
69 70
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
Dominik Hebeler's avatar
Dominik Hebeler committed
71
        readinessProbe:
Dominik Hebeler's avatar
Dominik Hebeler committed
72
          tcpSocket:
Dominik Hebeler's avatar
Dominik Hebeler committed
73
            port: "{{ .Values.service.name }}-phpfpm"
Dominik Hebeler's avatar
Dominik Hebeler committed
74 75
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
Dominik Hebeler's avatar
Dominik Hebeler committed
76 77
        volumeMounts:
        - name: mglogs-persistent-storage
Dominik Hebeler's avatar
Dominik Hebeler committed
78 79
          mountPath: /html/storage/logs/metager
          readOnly: false
Dominik Hebeler's avatar
Dominik Hebeler committed
80
        - name: env-files
Dominik Hebeler's avatar
Dominik Hebeler committed
81 82 83
          mountPath: /root/.env
          subPath: .env
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
84
        - name: env-files
Dominik Hebeler's avatar
Dominik Hebeler committed
85 86 87
          mountPath: /html/database/seeds/UsersSeeder.php
          subPath: UsersSeeder.php
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
88
        - name: env-files
Dominik Hebeler's avatar
Dominik Hebeler committed
89 90 91
          mountPath: /html/config/spam.txt
          subPath: spam.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
92
        - name: sumas
Dominik Hebeler's avatar
Dominik Hebeler committed
93 94 95
          mountPath: /html/config/sumas.json
          subPath: sumas.json
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
96
        - name: sumas-en
Dominik Hebeler's avatar
Dominik Hebeler committed
97 98 99
          mountPath: /html/config/sumasEn.json
          subPath: sumasEn.json
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
100
        - name: blacklist
Dominik Hebeler's avatar
Dominik Hebeler committed
101 102 103
          mountPath: /html/config/blacklistUrl.txt
          subPath: blacklistUrl.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
104
        - name: blacklist
Dominik Hebeler's avatar
Dominik Hebeler committed
105 106 107
          mountPath: /html/config/blacklistDomains.txt
          subPath: blacklistDomains.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
108
        - name: blacklist-ad
Dominik Hebeler's avatar
Dominik Hebeler committed
109 110 111
          mountPath: /html/config/adBlacklistUrl.txt
          subPath: adBlacklistUrl.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
112
        - name: blacklist-ad
Dominik Hebeler's avatar
Dominik Hebeler committed
113 114 115
          mountPath: /html/config/adBlacklistDomains.txt
          subPath: adBlacklistDomains.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
116
        resources:
Dominik Hebeler's avatar
Dominik Hebeler committed
117
          requests:
Dominik Hebeler's avatar
Dominik Hebeler committed
118 119
            cpu: 500m
            memory: 500m
Dominik Hebeler's avatar
Dominik Hebeler committed
120
      # Nginx Container
Dominik Hebeler's avatar
Dominik Hebeler committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
      - name: {{ .Chart.Name }}-nginx
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        command: ["nginx"]
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        {{- if .Values.application.secretName }}
        envFrom:
        - secretRef:
            name: {{ .Values.application.secretName }}
        {{- end }}
        env:
        - name: DATABASE_URL
          value: {{ .Values.application.database_url | quote }}
        - name: GITLAB_ENVIRONMENT_NAME
          value: {{ .Values.gitlab.envName }}
        - name: GITLAB_ENVIRONMENT_URL
          value: {{ .Values.gitlab.envURL }}
        ports:
        - name: "{{ .Values.service.name }}"
          containerPort: {{ .Values.service.internalPort }}
        livenessProbe:
{{- if eq .Values.livenessProbe.probeType "httpGet" }}
          httpGet:
            path: {{ .Values.livenessProbe.path }}
            scheme: {{ .Values.livenessProbe.scheme }}
            port: {{ .Values.service.internalPort }}
{{- else if eq .Values.livenessProbe.probeType "tcpSocket" }}
          tcpSocket:
            port: {{ .Values.service.internalPort }}
{{- end }}
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
        readinessProbe:
{{- if eq .Values.readinessProbe.probeType "httpGet" }}
          httpGet:
            path: {{ .Values.readinessProbe.path }}
            scheme: {{ .Values.readinessProbe.scheme }}
            port: {{ .Values.service.internalPort }}
{{- else if eq .Values.readinessProbe.probeType "tcpSocket" }}
          tcpSocket:
            port: {{ .Values.service.internalPort }}
{{- end }}
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
        resources:
          requests:
            cpu: 100m
            memory: 100m
      # Redis Container
      - name: {{ .Chart.Name }}-redis
        image: "redis:5.0.3-alpine"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: "{{ .Values.service.name }}-redis"
          containerPort: 6379
        livenessProbe:
          tcpSocket:
            port: "{{ .Values.service.name }}-redis"
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
        readinessProbe:
          tcpSocket:
            port: "{{ .Values.service.name }}-redis"
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
        resources:
          requests:
            cpu: 100m
            memory: 1Gi
      # Fetcher Container
      - name: {{ .Chart.Name }}-fetcher
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        command: ["su"]
        args: ["-s", "/bin/sh", "-c", "php artisan requests:fetcher", "nginx"]
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        livenessProbe:
          exec:
            command:
            - cat
            - /tmp/fetcher
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
        readinessProbe:
          exec:
            command:
            - cat
            - /tmp/fetcher
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
        resources:
          requests:
            cpu: 500m
            memory: 100m
Dominik Hebeler's avatar
Dominik Hebeler committed
213
{{- end -}}