nginx.yaml 1.98 KB
Newer Older
carlosribas's avatar
carlosribas 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
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: {{ .Values.nginxPort }}
    targetPort: {{ .Values.nginxTargetPort }}
    protocol: TCP
  selector:
    app: rnacentral
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  local.conf: |-
    # Gunicorn application
    upstream rnacentral {
        server rnacentral:{{ .Values.rnacentralPort }};
    }

    server {
        listen {{ .Values.nginxTargetPort }};

        location /static/ {
            autoindex on;
31
            alias /srv/rnacentral/static/;
carlosribas's avatar
carlosribas committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        }

        location / {
            # everything is passed to Gunicorn
            proxy_pass http://rnacentral;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_redirect off;
        }
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: {{ .Values.nginxReplicas }}
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
56 57
      annotations:
        rollme: {{ randAlphaNum 5 | quote }}
carlosribas's avatar
carlosribas committed
58 59
    spec:
      containers:
60
        - image: nginx:1.20-alpine
carlosribas's avatar
carlosribas committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
          name: nginx
          resources:
            requests:
              memory: {{ .Values.nginxRequestsMemory }}
              cpu: {{ .Values.nginxRequestsCPU }}
            limits:
              memory: {{ .Values.nginxLimitssMemory }}
              cpu: {{ .Values.nginxLimitsCPU }}
          ports:
            - containerPort: {{ .Values.nginxTargetPort }}
          volumeMounts:
            - name: nginx-config
              mountPath: /etc/nginx/conf.d/local.conf
              subPath: local.conf
            - name: static-volume
76
              mountPath: /srv/rnacentral/static
carlosribas's avatar
carlosribas committed
77 78 79 80 81 82 83 84
      restartPolicy: Always
      volumes:
        - name: nginx-config
          configMap:
            name: nginx-config
        - name: static-volume
          persistentVolumeClaim:
            claimName: static-volume