deployment.yaml 8.35 KB
Newer Older
Dominik Hebeler's avatar
Dominik Hebeler committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
{{- if not .Values.application.initializeCommand -}}
apiVersion: extensions/v1beta1
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:
  replicas: {{ .Values.replicaCount }}
  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:
33 34 35 36 37
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
38
              - key: worker
39 40
                operator: NotIn
                values:
41
                - temp
Dominik Hebeler's avatar
Dominik Hebeler committed
42 43
      imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
Dominik Hebeler's avatar
Dominik Hebeler committed
44 45
      securityContext:
        fsGroup: 2000
46 47 48
      volumes:
      - name: mglogs-persistent-storage
        persistentVolumeClaim:
49
          claimName: mg-logs
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
      - 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
65
      containers:
Dominik Hebeler's avatar
Dominik Hebeler committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
      # Main PHP-FPM Container
      - 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
          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 }}-phpfpm"
          containerPort: 9000
        livenessProbe:
          tcpSocket:
            port: "{{ .Values.service.name }}-phpfpm"
          initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
        readinessProbe:
          tcpSocket:
            port: "{{ .Values.service.name }}-phpfpm"
          initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
          timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
        volumeMounts:
        - name: mglogs-persistent-storage
          mountPath: /html/storage/logs/metager
          readOnly: false
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
        - name: env-files
          mountPath: /root/.env
          subPath: .env
          readOnly: true
        - name: env-files
          mountPath: /html/database/seeds/UsersSeeder.php
          subPath: UsersSeeder.php
          readOnly: true
        - name: env-files
          mountPath: /html/config/spam.txt
          subPath: spam.txt
          readOnly: true
        - name: sumas
          mountPath: /html/config/sumas.json
          subPath: sumas.json
          readOnly: true
        - name: sumas-en
          mountPath: /html/config/sumasEn.json
          subPath: sumasEn.json
          readOnly: true
        - name: blacklist
          mountPath: /html/config/blacklistUrl.txt
          subPath: blacklistUrl.txt
          readOnly: true
        - name: blacklist
          mountPath: /html/config/blacklistDomains.txt
          subPath: blacklistDomains.txt
          readOnly: true
        - name: blacklist-ad
          mountPath: /html/config/adBlacklistUrl.txt
          subPath: adBlacklistUrl.txt
          readOnly: true
        - name: blacklist-ad
          mountPath: /html/config/adBlacklistDomains.txt
          subPath: adBlacklistDomains.txt
          readOnly: true
Dominik Hebeler's avatar
Dominik Hebeler committed
135
        resources:
136 137 138
          requests:
            cpu: 500m
            memory: 500m
Dominik Hebeler's avatar
Dominik Hebeler committed
139
      # Nginx Container
140
      - name: {{ .Chart.Name }}-nginx
Dominik Hebeler's avatar
Dominik Hebeler committed
141
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
142
        command: ["nginx"]
Dominik Hebeler's avatar
Dominik Hebeler committed
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
        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 }}
183 184 185 186
        resources:
          requests:
            cpu: 100m
            memory: 100m
187 188
      # Redis Container
      - name: {{ .Chart.Name }}-redis
Dominik Hebeler's avatar
Dominik Hebeler committed
189
        image: "redis:5.0.3-alpine"
190 191 192 193 194 195 196 197 198 199 200 201 202 203
        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 }}
204 205 206 207
        resources:
          requests:
            cpu: 100m
            memory: 1Gi
208 209 210 211 212 213
      # 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 }}
214 215 216 217 218 219 220 221 222 223 224 225 226 227
        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 }}
228 229 230 231
        resources:
          requests:
            cpu: 500m
            memory: 100m
Dominik Hebeler's avatar
Dominik Hebeler committed
232
{{- end -}}