deployment.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ include "openvpn.fullname" . }}
  5. labels:
  6. {{- include "openvpn.labels" . | nindent 4 }}
  7. spec:
  8. replicas: 1
  9. strategy:
  10. type: Recreate
  11. selector:
  12. matchLabels:
  13. {{- include "openvpn.selectorLabels" . | nindent 6 }}
  14. template:
  15. metadata:
  16. annotations:
  17. {{- if .Values.multus }}
  18. v1.multus-cni.io/default-network: "{{ .Release.Namespace }}/{{ .Release.Name }}-net"
  19. {{- end }}
  20. checksum/config: {{ include (print $.Template.BasePath "/cm-configuration.yaml") . | sha256sum }}
  21. checksum/config2: {{ include (print $.Template.BasePath "/secret-keys.yaml") . | sha256sum }}
  22. checksum/config3: {{ include (print $.Template.BasePath "/cm-openvpnscripts.yaml") . | sha256sum }}
  23. {{- with .Values.openvpn.podAnnotations }}
  24. {{- toYaml . | nindent 8 }}
  25. {{- end }}
  26. labels:
  27. {{- include "openvpn.selectorLabels" . | nindent 8 }}
  28. spec:
  29. {{- if .Values.registry_secret_data }}
  30. imagePullSecrets:
  31. - name: {{ include "openvpn.fullname" . }}-registry-secret
  32. {{- end }}
  33. {{- if not .Values.multus }}
  34. hostNetwork: true
  35. {{- end }}
  36. containers:
  37. - name: {{ .Chart.Name }}
  38. command: ["/scripts/startscript"]
  39. {{- if .Values.openvpn.healthcheck }}
  40. livenessProbe:
  41. exec:
  42. command:
  43. - /scripts/healthcheck
  44. initialDelaySeconds: 20
  45. periodSeconds: 60
  46. failureThreshold: 5
  47. {{- end }}
  48. securityContext:
  49. capabilities:
  50. add:
  51. - NET_ADMIN
  52. - MKNOD
  53. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  54. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  55. env:
  56. - name: TZ
  57. value: Europe/Moscow
  58. resources:
  59. {{- toYaml .Values.openvpn.resources | nindent 12 }}
  60. volumeMounts:
  61. - name: keys
  62. mountPath: /etc/openvpn/keys/
  63. - name: ccd
  64. mountPath: /etc/openvpn/ccd/
  65. - name: configuration
  66. mountPath: /etc/openvpn/configuration/
  67. - name: scripts
  68. mountPath: /scripts/
  69. {{- if and .Values.virtIP_addr .Values.virtIP_dev }}
  70. - name: {{ .Chart.Name }}-stop
  71. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  72. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  73. command: ["sleep","infinity"]
  74. lifecycle:
  75. preStop:
  76. exec:
  77. command: ["/bin/bash","-c","/scripts/stopscript"]
  78. volumeMounts:
  79. - name: scripts
  80. mountPath: /scripts/
  81. securityContext:
  82. capabilities:
  83. add:
  84. - NET_ADMIN
  85. - MKNOD
  86. {{- end }}
  87. {{- if .Values.multus }}
  88. dnsPolicy: "None"
  89. dnsConfig:
  90. nameservers:
  91. - {{ .Values.multus.dnsIP }}
  92. {{- end }}
  93. volumes:
  94. - name: keys
  95. secret:
  96. secretName: {{ include "openvpn.fullname" . }}-keys
  97. - name: ccd
  98. configMap:
  99. name: {{ include "openvpn.fullname" . }}-ccd
  100. - name: configuration
  101. configMap:
  102. name: {{ include "openvpn.fullname" . }}-configuration
  103. - name: scripts
  104. configMap:
  105. name: {{ include "openvpn.fullname" . }}-scripts
  106. defaultMode: 0755