deployment.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. selector:
  10. matchLabels:
  11. {{- include "openvpn.selectorLabels" . | nindent 6 }}
  12. template:
  13. metadata:
  14. {{- with .Values.openvpn.podAnnotations }}
  15. annotations:
  16. {{- toYaml . | nindent 8 }}
  17. {{- end }}
  18. labels:
  19. {{- include "openvpn.selectorLabels" . | nindent 8 }}
  20. spec:
  21. {{- if .Values.registry_secret_data }}
  22. imagePullSecrets:
  23. - name: {{ include "openvpn.fullname" . }}-registry-secret
  24. {{- end }}
  25. hostNetwork: true
  26. {{- if .Values.openvpn.scripts.initscript }}
  27. initContainers:
  28. - name: {{ .Chart.Name }}-init
  29. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  30. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  31. command: ["/scripts/initscript"]
  32. volumeMounts:
  33. - name: scripts
  34. mountPath: /scripts/
  35. securityContext:
  36. capabilities:
  37. add:
  38. - NET_ADMIN
  39. {{- end }}
  40. containers:
  41. - name: {{ .Chart.Name }}
  42. {{- if .Values.openvpn.scripts.startscript }}
  43. command: ["/scripts/startscript"]
  44. {{- end }}
  45. {{- if .Values.openvpn.scripts.healthcheck }}
  46. livenessProbe:
  47. exec:
  48. command:
  49. - /scripts/healthcheck
  50. initialDelaySeconds: 20
  51. periodSeconds: 60
  52. failureThreshold: 5
  53. {{- end }}
  54. securityContext:
  55. capabilities:
  56. add:
  57. - NET_ADMIN
  58. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  59. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  60. env:
  61. - name: TZ
  62. value: Europe/Moscow
  63. resources:
  64. {{- toYaml .Values.openvpn.resources | nindent 12 }}
  65. volumeMounts:
  66. - name: keys
  67. mountPath: /etc/openvpn/keys/
  68. - name: ccd
  69. mountPath: /etc/openvpn/ccd/
  70. - name: configuration
  71. mountPath: /etc/openvpn/configuration/
  72. {{- if .Values.openvpn.scripts }}
  73. - name: scripts
  74. mountPath: /scripts/
  75. {{- end }}
  76. {{- if .Values.openvpn.scripts.stopscript }}
  77. - name: {{ .Chart.Name }}-stop
  78. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  79. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  80. command: ["sleep","infinity"]
  81. lifecycle:
  82. preStop:
  83. exec:
  84. command: ["/bin/bash","-c","/scripts/stopscript"]
  85. volumeMounts:
  86. - name: scripts
  87. mountPath: /scripts/
  88. securityContext:
  89. capabilities:
  90. add:
  91. - NET_ADMIN
  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. {{- if .Values.openvpn.scripts }}
  104. - name: scripts
  105. configMap:
  106. name: {{ include "openvpn.fullname" . }}-scripts
  107. defaultMode: 0755
  108. {{- end }}