deployment.yaml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ template "openshift-console-plugin.name" . }}
  5. namespace: {{ .Release.Namespace }}
  6. labels:
  7. {{- include "openshift-console-plugin.labels" . | nindent 4 }}
  8. app.openshift.io/runtime-namespace: {{ .Release.Namespace }}
  9. spec:
  10. replicas: {{ .Values.plugin.replicas }}
  11. selector:
  12. matchLabels:
  13. {{- include "openshift-console-plugin.selectorLabels" . | nindent 6 }}
  14. template:
  15. metadata:
  16. labels:
  17. {{- include "openshift-console-plugin.labels" . | nindent 8 }}
  18. spec:
  19. containers:
  20. - name: {{ template "openshift-console-plugin.name" . }}
  21. image: {{ required "Plugin image must be specified!" .Values.plugin.image }}
  22. command:
  23. - /bin/sh
  24. - -c
  25. - |
  26. if echo "$POD_IP" | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
  27. LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME="{{ .Values.plugin.port }}"
  28. else
  29. LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME="[::]:{{ .Values.plugin.port }}"
  30. fi
  31. sed "s/LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME/$LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME/g" /etc/nginx/nginx.conf > /tmp/nginx.conf
  32. exec nginx -c /tmp/nginx.conf -g 'daemon off;'
  33. env:
  34. - name: POD_IP
  35. valueFrom:
  36. fieldRef:
  37. fieldPath: status.podIP
  38. ports:
  39. - containerPort: {{ .Values.plugin.port }}
  40. protocol: TCP
  41. imagePullPolicy: {{ .Values.plugin.imagePullPolicy }}
  42. {{- if and (.Values.plugin.securityContext.enabled) (.Values.plugin.containerSecurityContext) }}
  43. securityContext: {{ tpl (toYaml (omit .Values.plugin.containerSecurityContext "enabled")) $ | nindent 12 }}
  44. {{- end }}
  45. resources:
  46. {{- toYaml .Values.plugin.resources | nindent 12 }}
  47. volumeMounts:
  48. - name: {{ template "openshift-console-plugin.certificateSecret" . }}
  49. readOnly: true
  50. mountPath: /var/cert
  51. - name: nginx-conf
  52. readOnly: true
  53. mountPath: /etc/nginx/nginx.conf
  54. subPath: nginx.conf
  55. volumes:
  56. - name: {{ template "openshift-console-plugin.certificateSecret" . }}
  57. secret:
  58. secretName: {{ template "openshift-console-plugin.certificateSecret" . }}
  59. defaultMode: 420
  60. - name: nginx-conf
  61. configMap:
  62. name: {{ template "openshift-console-plugin.name" . }}
  63. defaultMode: 420
  64. restartPolicy: Always
  65. dnsPolicy: ClusterFirst
  66. {{- if and (.Values.plugin.securityContext.enabled) (.Values.plugin.podSecurityContext) }}
  67. securityContext: {{ tpl (toYaml (omit .Values.plugin.podSecurityContext "enabled")) $ | nindent 8 }}
  68. {{- end }}
  69. strategy:
  70. type: RollingUpdate
  71. rollingUpdate:
  72. maxUnavailable: 25%
  73. maxSurge: 25%