api-deployment.yaml 4.09 KB
Newer Older
Markus Scheidgen's avatar
Markus Scheidgen 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
    
    [handlers]
    keys=console, access, error
    
    [formatters]
    keys=generic
    
    [logger_root]
    level=INFO
    handlers=console
    
    [logger_gunicorn.error]
    level=INFO
    handlers=error
    qualname=gunicorn.error
    
    [logger_gunicorn.access]
    level=INFO
    handlers=access
    qualname=gunicorn.access
    
    [handler_console]
    class=StreamHandler
    formatter=generic
    args=(sys.stdout, )
    
    [handler_access]
    class=StreamHandler
    formatter=generic
    args=(sys.stdout, )
    
    [handler_error]
    class=StreamHandler
    formatter=generic
    args=(sys.stdout, )
    
    [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
68
69
70
71
72
73
74
75
76
77
78
79
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
80
        - mountPath: /app/nomad.yaml
81
          name: nomad-conf
Markus Scheidgen's avatar
Markus Scheidgen committed
82
83
84
85
          subPath: nomad.yaml
        - mountPath: /app/gunicorn.log.conf
          name: gunicorn-log-conf
          subPath: gunicorn.log.conf
86
        - mountPath: /app/.volumes/fs/public
87
88
89
          name: public-volume
        - mountPath: /app/.volumes/fs/staging
          name: staging-volume
90
91
        - mountPath: /nomad
          name: nomad-volume
Markus Scheidgen's avatar
Markus Scheidgen committed
92
        env:
93
94
95
        - name: NOMAD_SERVICE
          value: "api"
        - name: NOMAD_CONSOLE_LOGLEVEL
96
          value: "{{ .Values.api.console_loglevel }}"
97
        - name: NOMAD_LOGSTASH_LEVEL
98
          value: "{{ .Values.api.logstash_loglevel }}"
Markus Scheidgen's avatar
Markus Scheidgen committed
99
        command: ["python", "-m", "gunicorn.app.wsgiapp", "--timeout", "3600", "--log-config", "gunicorn.log.conf", "-w", "{{ .Values.api.worker }}", "-b 0.0.0.0:8000", "nomad.api:app"]
100
101
        livenessProbe:
          httpGet:
102
            path: "{{ .Values.proxy.external.path }}/api/alive"
103
104
105
106
107
            port: 8000
          initialDelaySeconds: 15
          periodSeconds: 15
        readinessProbe:
          httpGet:
108
            path: "{{ .Values.proxy.external.path }}/api/alive"
109
110
111
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 5
112
113
      nodeSelector:
        nomadtype: public
114
115
      imagePullSecrets:
      - name: {{ .Values.images.secret }}
116
      imagePullPolicy: always
117
      volumes:
Markus Scheidgen's avatar
Markus Scheidgen committed
118
119
120
      - name: gunicorn-log-conf
        configMap:
          name: {{ include "nomad.fullname" . }}-api-gunicorn-log-config
121
122
123
      - name: nomad-conf
        configMap:
          name: {{ include "nomad.fullname" . }}-configmap
124
      - name: public-volume
125
        hostPath:
126
          path: {{ .Values.volumes.public }}
127
          type: Directory
128
      - name: staging-volume
129
        {{ if (eq .Values.worker.routing "worker") }}
130
131
132
133
        emptyDir:
          medium: 'Memory'
        {{ else }}
        hostPath:
134
          path: {{ .Values.volumes.staging}}
135
136
          type: Directory
        {{ end }}
137
138
139
140
      - name: nomad-volume
        hostPath:
          path: {{ .Values.volumes.nomad }}
          type: Directory