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