deploy: add static deployment, add resource reservations/limits
This commit is contained in:
		@ -28,8 +28,10 @@ spec:
 | 
			
		||||
        - name: {{ .Chart.Name }}
 | 
			
		||||
          image: "docker.beryju.org/passbook/server:{{ .Values.image.tag }}"
 | 
			
		||||
          imagePullPolicy: IfNotPresent
 | 
			
		||||
          command: ["/bin/sh","-c"]
 | 
			
		||||
          args: ["./manage.py migrate && ./manage.py app_gw_web"]
 | 
			
		||||
          command:
 | 
			
		||||
            - ./manage.py
 | 
			
		||||
          args:
 | 
			
		||||
            - app_gw_web
 | 
			
		||||
          ports:
 | 
			
		||||
            - name: http
 | 
			
		||||
              containerPort: 8000
 | 
			
		||||
@ -52,16 +54,9 @@ spec:
 | 
			
		||||
                - name: Host
 | 
			
		||||
                  value: kubernetes-healthcheck-host
 | 
			
		||||
          resources:
 | 
			
		||||
{{ toYaml .Values.resources | indent 12 }}
 | 
			
		||||
    {{- with .Values.nodeSelector }}
 | 
			
		||||
      nodeSelector:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- with .Values.affinity }}
 | 
			
		||||
      affinity:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- with .Values.tolerations }}
 | 
			
		||||
      tolerations:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
            requests:
 | 
			
		||||
              cpu: 150m
 | 
			
		||||
              memory: 300M
 | 
			
		||||
            limits:
 | 
			
		||||
              cpu: 500m
 | 
			
		||||
              memory: 500M
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
{{- if .Values.ingress.enabled -}}
 | 
			
		||||
{{- $fullName := include "passbook.fullname" . -}}
 | 
			
		||||
{{- $ingressPath := .Values.ingress.path -}}
 | 
			
		||||
apiVersion: extensions/v1beta1
 | 
			
		||||
kind: Ingress
 | 
			
		||||
metadata:
 | 
			
		||||
@ -30,16 +29,20 @@ spec:
 | 
			
		||||
    - host: {{ . | quote }}
 | 
			
		||||
      http:
 | 
			
		||||
        paths:
 | 
			
		||||
          - path: {{ $ingressPath }}
 | 
			
		||||
          - path: /
 | 
			
		||||
            backend:
 | 
			
		||||
              serviceName: {{ $fullName }}-web
 | 
			
		||||
              servicePort: http
 | 
			
		||||
          - path: /static/
 | 
			
		||||
            backend:
 | 
			
		||||
              serviceName: {{ $fullname }}-static
 | 
			
		||||
              servicePort: http
 | 
			
		||||
  {{- end }}
 | 
			
		||||
  {{- range .Values.ingress.app_gw_hosts }}
 | 
			
		||||
    - host: {{ . | quote }}
 | 
			
		||||
      http:
 | 
			
		||||
        paths:
 | 
			
		||||
          - path: {{ $ingressPath }}
 | 
			
		||||
          - path: /
 | 
			
		||||
            backend:
 | 
			
		||||
              serviceName: {{ $fullName }}-appgw
 | 
			
		||||
              servicePort: http
 | 
			
		||||
							
								
								
									
										56
									
								
								helm/passbook/templates/static-deployment.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								helm/passbook/templates/static-deployment.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,56 @@
 | 
			
		||||
apiVersion: apps/v1beta2
 | 
			
		||||
kind: Deployment
 | 
			
		||||
metadata:
 | 
			
		||||
  name: {{ include "passbook.fullname" . }}-static
 | 
			
		||||
  labels:
 | 
			
		||||
    app.kubernetes.io/name: {{ include "passbook.name" . }}
 | 
			
		||||
    helm.sh/chart: {{ include "passbook.chart" . }}
 | 
			
		||||
    app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
    app.kubernetes.io/managed-by: {{ .Release.Service }}
 | 
			
		||||
spec:
 | 
			
		||||
  selector:
 | 
			
		||||
    matchLabels:
 | 
			
		||||
      app.kubernetes.io/name: {{ include "passbook.name" . }}
 | 
			
		||||
      app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
  template:
 | 
			
		||||
    metadata:
 | 
			
		||||
      labels:
 | 
			
		||||
        app.kubernetes.io/name: {{ include "passbook.name" . }}
 | 
			
		||||
        app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
        k8s.passbook.io/component: static
 | 
			
		||||
      annotations:
 | 
			
		||||
        prometheus.io/scrape: "true"
 | 
			
		||||
        prometheus.io/port: '9113'
 | 
			
		||||
        field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9113,"schema":"HTTP"}]'
 | 
			
		||||
    spec:
 | 
			
		||||
      containers:
 | 
			
		||||
        - name: {{ .Chart.Name }}-static-prometheus
 | 
			
		||||
          image: nginx/nginx-prometheus-exporter:0.4.1
 | 
			
		||||
          imagePullPolicy: IfNotPresent
 | 
			
		||||
        - name: {{ .Chart.Name }}-static
 | 
			
		||||
          image: "docker.beryju.org/passbook/static:{{ .Values.image.tag }}"
 | 
			
		||||
          imagePullPolicy: IfNotPresent
 | 
			
		||||
          ports:
 | 
			
		||||
            - name: http
 | 
			
		||||
              containerPort: 80
 | 
			
		||||
              protocol: TCP
 | 
			
		||||
          livenessProbe:
 | 
			
		||||
            initialDelaySeconds: 10
 | 
			
		||||
            timeoutSeconds: 5
 | 
			
		||||
            httpGet:
 | 
			
		||||
              path: /_/healthz
 | 
			
		||||
              port: http
 | 
			
		||||
          readinessProbe:
 | 
			
		||||
            initialDelaySeconds: 10
 | 
			
		||||
            timeoutSeconds: 5
 | 
			
		||||
            httpGet:
 | 
			
		||||
              path: /_/healthz
 | 
			
		||||
              port: http
 | 
			
		||||
          resources:
 | 
			
		||||
            requests:
 | 
			
		||||
              cpu: 10m
 | 
			
		||||
              memory: 10M
 | 
			
		||||
            limits:
 | 
			
		||||
              cpu: 20m
 | 
			
		||||
              memory: 20M
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								helm/passbook/templates/static-service.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								helm/passbook/templates/static-service.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
apiVersion: v1
 | 
			
		||||
kind: Service
 | 
			
		||||
metadata:
 | 
			
		||||
  name: {{ include "passbook.fullname" . }}-static
 | 
			
		||||
  labels:
 | 
			
		||||
    app.kubernetes.io/name: {{ include "passbook.name" . }}
 | 
			
		||||
    helm.sh/chart: {{ include "passbook.chart" . }}
 | 
			
		||||
    app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
    app.kubernetes.io/managed-by: {{ .Release.Service }}
 | 
			
		||||
    k8s.passbook.io/component: static
 | 
			
		||||
spec:
 | 
			
		||||
  type: ClusterIP
 | 
			
		||||
  ports:
 | 
			
		||||
    - port: 80
 | 
			
		||||
      targetPort: http
 | 
			
		||||
      protocol: TCP
 | 
			
		||||
      name: http
 | 
			
		||||
  selector:
 | 
			
		||||
    app.kubernetes.io/name: {{ include "passbook.name" . }}
 | 
			
		||||
    app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
    k8s.passbook.io/component: static
 | 
			
		||||
@ -24,12 +24,24 @@ spec:
 | 
			
		||||
        - name: config-volume
 | 
			
		||||
          configMap:
 | 
			
		||||
            name: {{ include "passbook.fullname" . }}-config
 | 
			
		||||
      initContainers:
 | 
			
		||||
        - name: passbook-database-migrations
 | 
			
		||||
          image: "docker.beryju.org/passbook/server:{{ .Values.image.tag }}"
 | 
			
		||||
          command:
 | 
			
		||||
            - ./manage.py
 | 
			
		||||
          args:
 | 
			
		||||
            - migrate
 | 
			
		||||
          volumeMounts:
 | 
			
		||||
            - mountPath: /etc/passbook
 | 
			
		||||
              name: config-volume
 | 
			
		||||
      containers:
 | 
			
		||||
        - name: {{ .Chart.Name }}
 | 
			
		||||
          image: "docker.beryju.org/passbook/server:{{ .Values.image.tag }}"
 | 
			
		||||
          imagePullPolicy: IfNotPresent
 | 
			
		||||
          command: ["/bin/sh","-c"]
 | 
			
		||||
          args: ["./manage.py migrate && ./manage.py web"]
 | 
			
		||||
          command:
 | 
			
		||||
            - ./manage.py
 | 
			
		||||
          args:
 | 
			
		||||
            - web
 | 
			
		||||
          ports:
 | 
			
		||||
            - name: http
 | 
			
		||||
              containerPort: 8000
 | 
			
		||||
@ -52,16 +64,9 @@ spec:
 | 
			
		||||
                - name: Host
 | 
			
		||||
                  value: kubernetes-healthcheck-host
 | 
			
		||||
          resources:
 | 
			
		||||
{{ toYaml .Values.resources | indent 12 }}
 | 
			
		||||
    {{- with .Values.nodeSelector }}
 | 
			
		||||
      nodeSelector:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- with .Values.affinity }}
 | 
			
		||||
      affinity:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- with .Values.tolerations }}
 | 
			
		||||
      tolerations:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
            requests:
 | 
			
		||||
              cpu: 50m
 | 
			
		||||
              memory: 150M
 | 
			
		||||
            limits:
 | 
			
		||||
              cpu: 200m
 | 
			
		||||
              memory: 300M
 | 
			
		||||
@ -28,7 +28,10 @@ spec:
 | 
			
		||||
        - name: {{ .Chart.Name }}
 | 
			
		||||
          image: "docker.beryju.org/passbook/server:{{ .Values.image.tag }}"
 | 
			
		||||
          imagePullPolicy: IfNotPresent
 | 
			
		||||
          command: ["./manage.py", "worker"]
 | 
			
		||||
          command:
 | 
			
		||||
            - ./manage.py
 | 
			
		||||
          args:
 | 
			
		||||
            - worker
 | 
			
		||||
          ports:
 | 
			
		||||
            - name: http
 | 
			
		||||
              containerPort: 8000
 | 
			
		||||
@ -37,16 +40,9 @@ spec:
 | 
			
		||||
            - mountPath: /etc/passbook
 | 
			
		||||
              name: config-volume
 | 
			
		||||
          resources:
 | 
			
		||||
{{ toYaml .Values.resources | indent 12 }}
 | 
			
		||||
    {{- with .Values.nodeSelector }}
 | 
			
		||||
      nodeSelector:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- with .Values.affinity }}
 | 
			
		||||
      affinity:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- with .Values.tolerations }}
 | 
			
		||||
      tolerations:
 | 
			
		||||
{{ toYaml . | indent 8 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
            requests:
 | 
			
		||||
              cpu: 150m
 | 
			
		||||
              memory: 400M
 | 
			
		||||
            limits:
 | 
			
		||||
              cpu: 300m
 | 
			
		||||
              memory: 600M
 | 
			
		||||
		Reference in New Issue
	
	Block a user