api-deployment.yaml 5.02 KB
Newer Older
Markus Scheidgen's avatar
Markus Scheidgen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "nomad.fullname" . }}-api-gunicorn-log-config
  labels:
    app.kubernetes.io/name: {{ include "nomad.name" . }}-api-gunicorn-log-config
    helm.sh/chart: {{ include "nomad.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
  gunicorn.log.conf: |
    [loggers]
    keys=root, gunicorn.error, gunicorn.access
Markus Scheidgen's avatar
Markus Scheidgen committed
14

Markus Scheidgen's avatar
Markus Scheidgen committed
15
16
    [handlers]
    keys=console, access, error
Markus Scheidgen's avatar
Markus Scheidgen committed
17

Markus Scheidgen's avatar
Markus Scheidgen committed
18
19
    [formatters]
    keys=generic
Markus Scheidgen's avatar
Markus Scheidgen committed
20

Markus Scheidgen's avatar
Markus Scheidgen committed
21
22
23
    [logger_root]
    level=INFO
    handlers=console
Markus Scheidgen's avatar
Markus Scheidgen committed
24

Markus Scheidgen's avatar
Markus Scheidgen committed
25
26
27
28
    [logger_gunicorn.error]
    level=INFO
    handlers=error
    qualname=gunicorn.error
Markus Scheidgen's avatar
Markus Scheidgen committed
29

Markus Scheidgen's avatar
Markus Scheidgen committed
30
31
32
33
    [logger_gunicorn.access]
    level=INFO
    handlers=access
    qualname=gunicorn.access
Markus Scheidgen's avatar
Markus Scheidgen committed
34

Markus Scheidgen's avatar
Markus Scheidgen committed
35
36
37
38
    [handler_console]
    class=StreamHandler
    formatter=generic
    args=(sys.stdout, )
Markus Scheidgen's avatar
Markus Scheidgen committed
39

Markus Scheidgen's avatar
Markus Scheidgen committed
40
41
42
43
    [handler_access]
    class=StreamHandler
    formatter=generic
    args=(sys.stdout, )
Markus Scheidgen's avatar
Markus Scheidgen committed
44

Markus Scheidgen's avatar
Markus Scheidgen committed
45
46
47
48
    [handler_error]
    class=StreamHandler
    formatter=generic
    args=(sys.stdout, )
Markus Scheidgen's avatar
Markus Scheidgen committed
49

Markus Scheidgen's avatar
Markus Scheidgen committed
50
51
52
53
54
    [formatter_generic]
    format=%(asctime)s [%(process)d] [%(levelname)s] %(message)s
    datefmt=%Y-%m-%d %H:%M:%S
    class=logging.Formatter
---
55
56
57
58
59
60
61
62
63
64
65
66
67
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "nomad.fullname" . }}-api-gunicorn-config
  labels:
    app.kubernetes.io/name: {{ include "nomad.name" . }}-api-gunicorn-config
    helm.sh/chart: {{ include "nomad.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
  gunicorn.conf: |
    secure_scheme_headers = {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
---
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
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "nomad.fullname" . }}-api
  labels:
    app.kubernetes.io/name: {{ include "nomad.name" . }}-api
    helm.sh/chart: {{ include "nomad.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: {{ .Values.api.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "nomad.name" . }}-api
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "nomad.name" . }}-api
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
      - name: {{ include "nomad.name" . }}-api
        image: "{{ .Values.images.nomad.name }}:{{ .Values.images.nomad.tag }}"
        volumeMounts:
Markus Scheidgen's avatar
Markus Scheidgen committed
93
        - mountPath: /app/nomad.yaml
94
          name: nomad-conf
Markus Scheidgen's avatar
Markus Scheidgen committed
95
96
97
98
          subPath: nomad.yaml
        - mountPath: /app/gunicorn.log.conf
          name: gunicorn-log-conf
          subPath: gunicorn.log.conf
Markus Scheidgen's avatar
Markus Scheidgen committed
99
100
101
        - mountPath: /app/gunicorn.conf
          name: gunicorn-conf
          subPath: gunicorn.conf
102
        - mountPath: /app/.volumes/fs/public
103
104
105
          name: public-volume
        - mountPath: /app/.volumes/fs/staging
          name: staging-volume
106
107
        - mountPath: /nomad
          name: nomad-volume
Markus Scheidgen's avatar
Markus Scheidgen committed
108
        env:
109
110
111
        - name: NOMAD_SERVICE
          value: "api"
        - name: NOMAD_CONSOLE_LOGLEVEL
112
          value: "{{ .Values.api.console_loglevel }}"
113
        - name: NOMAD_LOGSTASH_LEVEL
114
          value: "{{ .Values.api.logstash_loglevel }}"
115
116
117
118
119
120
121
        {{ if .Values.api.adminPasswordSecret }}
        - name: NOMAD_SERVICES_ADMIN_PASSWORD
          valueFrom
            secretKeyRef:
              name: {{ .Values.api.adminPasswordSecret }}
              key: password
        {{ end }}
Markus Scheidgen's avatar
Markus Scheidgen committed
122
        command: ["python", "-m", "gunicorn.app.wsgiapp", "--timeout", "3600", "--config", "gunicorn.conf", "--log-config", "gunicorn.log.conf", "-w", "{{ .Values.api.worker }}", "-b 0.0.0.0:8000", "nomad.api:app"]
123
124
        livenessProbe:
          httpGet:
125
            path: "{{ .Values.proxy.external.path }}/api/alive"
126
127
128
129
130
            port: 8000
          initialDelaySeconds: 15
          periodSeconds: 15
        readinessProbe:
          httpGet:
131
            path: "{{ .Values.proxy.external.path }}/api/alive"
132
133
134
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 5
135
136
      nodeSelector:
        nomadtype: public
137
138
      imagePullSecrets:
      - name: {{ .Values.images.secret }}
139
      imagePullPolicy: always
140
      volumes:
Markus Scheidgen's avatar
Markus Scheidgen committed
141
142
143
      - name: gunicorn-log-conf
        configMap:
          name: {{ include "nomad.fullname" . }}-api-gunicorn-log-config
Markus Scheidgen's avatar
Markus Scheidgen committed
144
145
146
      - name: gunicorn-conf
        configMap:
          name: {{ include "nomad.fullname" . }}-api-gunicorn-config
147
148
149
      - name: nomad-conf
        configMap:
          name: {{ include "nomad.fullname" . }}-configmap
150
      - name: public-volume
151
        hostPath:
152
          path: {{ .Values.volumes.public }}
153
          type: Directory
154
      - name: staging-volume
155
        {{ if (eq .Values.worker.storage "memory") }}
156
157
158
159
        emptyDir:
          medium: 'Memory'
        {{ else }}
        hostPath:
160
          path: {{ .Values.volumes.staging}}
161
162
          type: Directory
        {{ end }}
163
164
165
166
      - name: nomad-volume
        hostPath:
          path: {{ .Values.volumes.nomad }}
          type: Directory