diff --git a/helm/passbook/templates/passbook-appgw-deployment.yaml b/helm/passbook/templates/appgw-deployment.yaml similarity index 79% rename from helm/passbook/templates/passbook-appgw-deployment.yaml rename to helm/passbook/templates/appgw-deployment.yaml index 0c522d3f5..18fc1a85c 100644 --- a/helm/passbook/templates/passbook-appgw-deployment.yaml +++ b/helm/passbook/templates/appgw-deployment.yaml @@ -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 diff --git a/helm/passbook/templates/passbook-appgw-service.yaml b/helm/passbook/templates/appgw-service.yaml similarity index 100% rename from helm/passbook/templates/passbook-appgw-service.yaml rename to helm/passbook/templates/appgw-service.yaml diff --git a/helm/passbook/templates/passbook-configmap.yaml b/helm/passbook/templates/configmap.yaml similarity index 100% rename from helm/passbook/templates/passbook-configmap.yaml rename to helm/passbook/templates/configmap.yaml diff --git a/helm/passbook/templates/passbook-ingress.yaml b/helm/passbook/templates/ingress.yaml similarity index 87% rename from helm/passbook/templates/passbook-ingress.yaml rename to helm/passbook/templates/ingress.yaml index 1c0c0eb75..09da3bec8 100644 --- a/helm/passbook/templates/passbook-ingress.yaml +++ b/helm/passbook/templates/ingress.yaml @@ -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 diff --git a/helm/passbook/templates/static-deployment.yaml b/helm/passbook/templates/static-deployment.yaml new file mode 100644 index 000000000..723485ccd --- /dev/null +++ b/helm/passbook/templates/static-deployment.yaml @@ -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 + diff --git a/helm/passbook/templates/static-service.yaml b/helm/passbook/templates/static-service.yaml new file mode 100644 index 000000000..c8b717429 --- /dev/null +++ b/helm/passbook/templates/static-service.yaml @@ -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 diff --git a/helm/passbook/templates/passbook-web-deployment.yaml b/helm/passbook/templates/web-deployment.yaml similarity index 75% rename from helm/passbook/templates/passbook-web-deployment.yaml rename to helm/passbook/templates/web-deployment.yaml index 5d5da0569..24cb6b488 100644 --- a/helm/passbook/templates/passbook-web-deployment.yaml +++ b/helm/passbook/templates/web-deployment.yaml @@ -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 diff --git a/helm/passbook/templates/passbook-web-service.yaml b/helm/passbook/templates/web-service.yaml similarity index 100% rename from helm/passbook/templates/passbook-web-service.yaml rename to helm/passbook/templates/web-service.yaml diff --git a/helm/passbook/templates/passbook-worker-deployment.yaml b/helm/passbook/templates/worker-deployment.yaml similarity index 77% rename from helm/passbook/templates/passbook-worker-deployment.yaml rename to helm/passbook/templates/worker-deployment.yaml index 50893a7da..dce29feed 100644 --- a/helm/passbook/templates/passbook-worker-deployment.yaml +++ b/helm/passbook/templates/worker-deployment.yaml @@ -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