deployment.yaml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. securityContext:
  22. sysctls:
  23. - name: net.ipv4.ip_forward
  24. value: "1"
  25. {{- if .Values.registry_secret_data }}
  26. imagePullSecrets:
  27. - name: {{ include "openvpn.fullname" . }}-registry-secret
  28. {{- end }}
  29. # hostNetwork: true
  30. {{- if .Values.openvpn.scripts.initscript }}
  31. initContainers:
  32. - name: {{ .Chart.Name }}-init
  33. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  34. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  35. command: ["/scripts/initscript"]
  36. volumeMounts:
  37. - name: scripts
  38. mountPath: /scripts/
  39. securityContext:
  40. capabilities:
  41. add:
  42. - NET_ADMIN
  43. - MKNOD
  44. {{- end }}
  45. containers:
  46. - name: {{ .Chart.Name }}
  47. {{- if .Values.openvpn.scripts.startscript }}
  48. command: ["/scripts/startscript"]
  49. {{- end }}
  50. {{- if .Values.openvpn.scripts.healthcheck }}
  51. livenessProbe:
  52. exec:
  53. command:
  54. - /scripts/healthcheck
  55. initialDelaySeconds: 20
  56. periodSeconds: 60
  57. failureThreshold: 5
  58. {{- end }}
  59. securityContext:
  60. capabilities:
  61. add:
  62. - NET_ADMIN
  63. - MKNOD
  64. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  65. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  66. env:
  67. - name: TZ
  68. value: Europe/Moscow
  69. resources:
  70. {{- toYaml .Values.openvpn.resources | nindent 12 }}
  71. volumeMounts:
  72. - name: keys
  73. mountPath: /etc/openvpn/keys/
  74. - name: ccd
  75. mountPath: /etc/openvpn/ccd/
  76. - name: configuration
  77. mountPath: /etc/openvpn/configuration/
  78. {{- if .Values.openvpn.scripts }}
  79. - name: scripts
  80. mountPath: /scripts/
  81. {{- end }}
  82. {{- if .Values.openvpn.scripts.stopscript }}
  83. - name: {{ .Chart.Name }}-stop
  84. image: "{{ .Values.openvpn.image }}:{{ .Values.openvpn.tag | default "latest" }}"
  85. imagePullPolicy: {{ .Values.openvpn.pullPolicy }}
  86. command: ["sleep","infinity"]
  87. lifecycle:
  88. preStop:
  89. exec:
  90. command: ["/bin/bash","-c","/scripts/stopscript"]
  91. volumeMounts:
  92. - name: scripts
  93. mountPath: /scripts/
  94. securityContext:
  95. capabilities:
  96. add:
  97. - NET_ADMIN
  98. - MKNOD
  99. {{- end }}
  100. volumes:
  101. - name: keys
  102. secret:
  103. secretName: {{ include "openvpn.fullname" . }}-keys
  104. - name: ccd
  105. configMap:
  106. name: {{ include "openvpn.fullname" . }}-ccd
  107. - name: configuration
  108. configMap:
  109. name: {{ include "openvpn.fullname" . }}-configuration
  110. {{- if .Values.openvpn.scripts }}
  111. - name: scripts
  112. configMap:
  113. name: {{ include "openvpn.fullname" . }}-scripts
  114. defaultMode: 0755
  115. {{- end }}