deployment.yaml 8.63 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
  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 }}
Dominik Hebeler's avatar
Dominik Hebeler committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
      volumes:
      - name: mglogs-persistent-storage
        persistentVolumeClaim:
          claimName: mg-logs
      - name: env-files
        secret:
          secretName: metager-env
      - name: sumas
        secret:
          secretName: metager-sumas
      - name: sumas-en
        secret:
          secretName: metager-sumas-en
      - name: blacklist
        secret:
          secretName: metager-blacklist
      - name: blacklist-ad
        secret:
          secretName: metager-ad-blacklist
Dominik Hebeler's avatar
Dominik Hebeler committed
66 67 68
      - name: metager-config
        configMap:
          name: metager
Dominik Hebeler's avatar
Dominik Hebeler committed
69
      containers:
Dominik Hebeler's avatar
Dominik Hebeler committed
70 71 72 73 74 75 76 77 78 79
      - 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
80
          value: {{ .Values.application.database_url | quote }}
Dominik Hebeler's avatar
Dominik Hebeler committed
81
        - name: GITLAB_ENVIRONMENT_NAME
Dominik Hebeler's avatar
Dominik Hebeler committed
82
          value: {{ .Values.gitlab.envName }}
Dominik Hebeler's avatar
Dominik Hebeler committed
83
        - name: GITLAB_ENVIRONMENT_URL
Dominik Hebeler's avatar
Dominik Hebeler committed
84
          value: {{ .Values.gitlab.envURL }}
Dominik Hebeler's avatar
Dominik Hebeler committed
85 86
        ports:
        - name: "{{ .Values.service.name }}-phpfpm"
Dominik Hebeler's avatar
Dominik Hebeler committed
87
          containerPort: 9000
Dominik Hebeler's avatar
Dominik Hebeler committed
88
        livenessProbe:
Dominik Hebeler's avatar
Dominik Hebeler committed
89
          tcpSocket:
Dominik Hebeler's avatar
Dominik Hebeler committed
90
            port: "{{ .Values.service.name }}-phpfpm"
Dominik Hebeler's avatar
Dominik Hebeler committed
91 92
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
Dominik Hebeler's avatar
Dominik Hebeler committed
93
        readinessProbe:
Dominik Hebeler's avatar
Dominik Hebeler committed
94
          tcpSocket:
Dominik Hebeler's avatar
Dominik Hebeler committed
95
            port: "{{ .Values.service.name }}-phpfpm"
Dominik Hebeler's avatar
Dominik Hebeler committed
96 97
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
Dominik Hebeler's avatar
Dominik Hebeler committed
98
        volumeMounts:
Dominik Hebeler's avatar
Dominik Hebeler committed
99
        - name: metager-config
100
          mountPath: /html/config/metager
Dominik Hebeler's avatar
Dominik Hebeler committed
101
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
102
        - name: mglogs-persistent-storage
Dominik Hebeler's avatar
Dominik Hebeler committed
103 104
          mountPath: /html/storage/logs/metager
          readOnly: false
Dominik Hebeler's avatar
Dominik Hebeler committed
105
        - name: env-files
Dominik Hebeler's avatar
Dominik Hebeler committed
106 107 108
          mountPath: /root/.env
          subPath: .env
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
109
        - name: env-files
Dominik Hebeler's avatar
Dominik Hebeler committed
110 111 112
          mountPath: /html/database/seeds/UsersSeeder.php
          subPath: UsersSeeder.php
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
113
        - name: env-files
Dominik Hebeler's avatar
Dominik Hebeler committed
114 115 116
          mountPath: /html/config/spam.txt
          subPath: spam.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
117
        - name: sumas
Dominik Hebeler's avatar
Dominik Hebeler committed
118 119 120
          mountPath: /html/config/sumas.json
          subPath: sumas.json
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
121
        - name: sumas-en
Dominik Hebeler's avatar
Dominik Hebeler committed
122 123 124
          mountPath: /html/config/sumasEn.json
          subPath: sumasEn.json
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
125
        - name: blacklist
Dominik Hebeler's avatar
Dominik Hebeler committed
126 127 128
          mountPath: /html/config/blacklistUrl.txt
          subPath: blacklistUrl.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
129
        - name: blacklist
Dominik Hebeler's avatar
Dominik Hebeler committed
130 131 132
          mountPath: /html/config/blacklistDomains.txt
          subPath: blacklistDomains.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
133
        - name: blacklist-ad
Dominik Hebeler's avatar
Dominik Hebeler committed
134 135 136
          mountPath: /html/config/adBlacklistUrl.txt
          subPath: adBlacklistUrl.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
137
        - name: blacklist-ad
Dominik Hebeler's avatar
Dominik Hebeler committed
138 139 140
          mountPath: /html/config/adBlacklistDomains.txt
          subPath: adBlacklistDomains.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
141
        resources:
Dominik Hebeler's avatar
Dominik Hebeler committed
142
          requests:
Dominik Hebeler's avatar
Dominik Hebeler committed
143 144
            cpu: 500m
            memory: 500m
Dominik Hebeler's avatar
Dominik Hebeler committed
145
      # Nginx Container
Dominik Hebeler's avatar
Dominik Hebeler committed
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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
      - 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
238
{{- end -}}