deployment.yaml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. {{ include "common.storage.hostPathValidate" .Values }}
  2. apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
  3. kind: Deployment
  4. metadata:
  5. name: {{ template "common.names.fullname" . }}-pihole
  6. labels:
  7. app: {{ template "common.names.name" . }}
  8. chart: {{ template "common.names.chart" . }}
  9. release: {{ .Release.Name }}
  10. heritage: {{ .Release.Service }}
  11. annotations:
  12. rollme: {{ randAlphaNum 5 | quote }}
  13. spec:
  14. replicas: {{ (default 1 .Values.replicas) }}
  15. strategy:
  16. type: "Recreate"
  17. selector:
  18. matchLabels:
  19. app: {{ template "common.names.name" . }}
  20. release: {{ .Release.Name }}
  21. template:
  22. metadata:
  23. name: {{ template "common.names.fullname" . }}
  24. labels:
  25. app: {{ template "common.names.name" . }}
  26. release: {{ .Release.Name }}
  27. {{- include "common.labels.selectorLabels" . | nindent 8 }}
  28. annotations: {{ include "common.annotations" . | nindent 8 }}
  29. spec:
  30. {{/*
  31. Host network is pretty much a requirement for apps like this.
  32. Because NodePort can't bind ports like 53(DNS) or 67(DHCP)
  33. and the majority of devices do not have option to change the port.
  34. */}}
  35. hostNetwork: true
  36. dnsPolicy: ClusterFirstWithHostNet
  37. containers:
  38. - name: {{ .Chart.Name }}
  39. {{ include "common.resources.limitation" . | nindent 10 }}
  40. {{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
  41. volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
  42. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  43. - name: extrappvolume-{{ $index }}
  44. mountPath: {{ $hostPathConfiguration.mountPath }}
  45. {{ end }}
  46. securityContext:
  47. capabilities:
  48. {{/* This is needed to be able to bind 53(DNS) and 67(DHCP) ports */}}
  49. add: ["NET_ADMIN"]
  50. ports:
  51. - name: web
  52. containerPort: {{ .Values.web_port }}
  53. - name: dns-tcp
  54. containerPort: 53
  55. protocol: TCP
  56. - name: dns-udp
  57. containerPort: 53
  58. protocol: UDP
  59. {{ if .Values.dhcp }}
  60. - name: dhcp
  61. containerPort: 67
  62. protocol: UDP
  63. {{ end }}
  64. readinessProbe:
  65. httpGet:
  66. path: /admin/login.php
  67. port: {{ .Values.web_port }}
  68. initialDelaySeconds: 10
  69. periodSeconds: 10
  70. timeoutSeconds: 5
  71. failureThreshold: 5
  72. successThreshold: 2
  73. livenessProbe:
  74. httpGet:
  75. path: /admin/login.php
  76. port: {{ .Values.web_port }}
  77. initialDelaySeconds: 10
  78. periodSeconds: 10
  79. timeoutSeconds: 5
  80. failureThreshold: 5
  81. successThreshold: 1
  82. startupProbe:
  83. httpGet:
  84. path: /admin/login.php
  85. port: {{ .Values.web_port }}
  86. initialDelaySeconds: 10
  87. periodSeconds: 5
  88. timeoutSeconds: 2
  89. failureThreshold: 60
  90. successThreshold: 1
  91. env:
  92. {{ $secretName := (include "common.names.fullname" .) }}
  93. {{ $envList := (default list .Values.environmentVariables) }}
  94. {{ $envList = mustAppend $envList (dict "name" "WEBPASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "password") }}
  95. {{ $envList = mustAppend $envList (dict "name" "TZ" "value" (printf "%s" .Values.timezone)) }}
  96. {{ $envList = mustAppend $envList (dict "name" "WEB_PORT" "value" .Values.web_port) }}
  97. {{ if .Values.dhcp }}
  98. {{ $envList = mustAppend $envList (dict "name" "DHCP_ACTIVE" "value" "true") }}
  99. {{ $envList = mustAppend $envList (dict "name" "DHCP_START" "value" .Values.dhcp_start) }}
  100. {{ $envList = mustAppend $envList (dict "name" "DHCP_END" "value" .Values.dhcp_end) }}
  101. {{ $envList = mustAppend $envList (dict "name" "DHCP_ROUTER" "value" .Values.dhcp_gateway) }}
  102. {{ end }}
  103. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
  104. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  105. volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  106. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  107. - name: extrappvolume-{{ $index }}
  108. hostPath:
  109. path: {{ $hostPathConfiguration.hostPath }}
  110. {{ end }}