server-deployment.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ include "deepflow.fullname" . }}-server
  5. labels:
  6. {{- include "deepflow-server.labels" . | nindent 4 }}
  7. spec:
  8. replicas: {{ tpl (toString .Values.server.replicas) . }}
  9. strategy:
  10. type: Recreate
  11. selector:
  12. matchLabels:
  13. {{- include "deepflow-server.selectorLabels" . | nindent 6 }}
  14. template:
  15. metadata:
  16. annotations:
  17. {{- with .Values.podAnnotations }}
  18. {{- toYaml . | nindent 8 }}
  19. {{- end }}
  20. checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
  21. checksum/customConfig: {{ sha256sum (print (tpl (toYaml .Values.configmap) $)) }}
  22. labels:
  23. {{- include "deepflow-server.selectorLabels" . | nindent 8 }}
  24. {{- range $index, $values := .Values.server.featureFlag }}
  25. {{- (printf "deepflow.yunshan.net/%s" (lower $values)) | quote | nindent 8 }}: "true"
  26. {{- end }}
  27. {{- with .Values.server.podLabels }}
  28. {{- toYaml . | nindent 8 }}
  29. {{- end }}
  30. spec:
  31. hostNetwork: {{ tpl (toString .Values.server.hostNetwork) . }}
  32. dnsPolicy: {{ tpl .Values.server.dnsPolicy . }}
  33. dnsConfig:
  34. nameservers:
  35. {{- with .Values.server.nameservers }}
  36. {{- toYaml . | nindent 10 }}
  37. {{- end }}
  38. imagePullSecrets:
  39. {{- with .Values.global.imagePullSecrets }}
  40. {{- toYaml . | nindent 8 }}
  41. {{- end }}
  42. {{- with .Values.imagePullSecrets }}
  43. {{- toYaml . | nindent 8 }}
  44. {{- end }}
  45. securityContext:
  46. {{- toYaml .Values.podSecurityContext | nindent 8 }}
  47. serviceAccountName: {{ include "deepflow.fullname" . }}-server
  48. containers:
  49. - name: deepflow-server
  50. securityContext:
  51. {{- toYaml .Values.securityContext | nindent 12 }}
  52. image: "{{ tpl .Values.image.server.repository . }}:{{ tpl (toString .Values.image.server.tag) . }}"
  53. imagePullPolicy: "{{ tpl .Values.image.server.pullPolicy . }}"
  54. ports:
  55. - name: server
  56. containerPort: 20417
  57. protocol: TCP
  58. - containerPort: 20035
  59. name: grpc
  60. protocol: TCP
  61. - containerPort: 20135
  62. name: ssl-grpc
  63. protocol: TCP
  64. - containerPort: 20416
  65. name: querier
  66. protocol: TCP
  67. livenessProbe:
  68. {{ toYaml .Values.server.livenessProbe | nindent 12 }}
  69. readinessProbe:
  70. {{ toYaml .Values.server.readinessProbe | nindent 12 }}
  71. resources:
  72. {{- toYaml .Values.server.resources | nindent 12 }}
  73. volumeMounts:
  74. - name: server-config
  75. mountPath: /etc/server.yaml
  76. subPath: server.yaml
  77. {{- range .Values.server.extraVolumeMounts }}
  78. - name: {{ .name }}
  79. mountPath: {{ .mountPath }}
  80. subPath: {{ .subPath | default "" }}
  81. readOnly: {{ .readOnly }}
  82. {{- end }}
  83. env:
  84. - name: K8S_NODE_IP_FOR_DEEPFLOW
  85. valueFrom:
  86. fieldRef:
  87. fieldPath: status.hostIP
  88. - name: K8S_NODE_NAME_FOR_DEEPFLOW
  89. valueFrom:
  90. fieldRef:
  91. fieldPath: spec.nodeName
  92. - name: K8S_POD_NAME_FOR_DEEPFLOW
  93. valueFrom:
  94. fieldRef:
  95. fieldPath: metadata.name
  96. - name: K8S_POD_IP_FOR_DEEPFLOW
  97. valueFrom:
  98. fieldRef:
  99. fieldPath: status.podIP
  100. - name: K8S_NAMESPACE_FOR_DEEPFLOW
  101. valueFrom:
  102. fieldRef:
  103. fieldPath: metadata.namespace
  104. - name: TZ
  105. value: "{{ tpl .Values.timezone . }}"
  106. {{- range $index, $values := .Values.server.featureFlag }}
  107. - name: {{ printf "FEATURE_FLAG_%s" $values | quote }}
  108. value: "true"
  109. {{- end }}
  110. volumes:
  111. - name: server-config
  112. configMap:
  113. name: {{ include "deepflow.fullname" . }}
  114. items:
  115. - key: server.yaml
  116. path: server.yaml
  117. {{- range .Values.server.extraVolumeMounts }}
  118. - name: {{ .name }}
  119. {{- if .existingClaim }}
  120. persistentVolumeClaim:
  121. claimName: {{ .existingClaim }}
  122. {{- else if .hostPath }}
  123. hostPath:
  124. path: {{ .hostPath }}
  125. {{- else }}
  126. emptyDir: {}
  127. {{- end }}
  128. {{- end }}
  129. {{- with .Values.server.nodeSelector }}
  130. nodeSelector:
  131. {{- toYaml . | nindent 8 }}
  132. {{- end }}
  133. affinity:
  134. {{- include "serverNodeaffinity" . | indent 6 }}
  135. {{- include "serverPodAffinity" . | indent 6 }}
  136. {{- include "serverPodAntiAffinity" . | indent 6 }}
  137. {{- if or .Values.global.tolerations .Values.tolerations }}
  138. tolerations:
  139. {{- if .Values.global.tolerations }}
  140. {{- toYaml .Values.global.tolerations | nindent 8 }}
  141. {{- end }}
  142. {{- if .Values.tolerations }}
  143. {{- toYaml .Values.tolerations | nindent 8 }}
  144. {{- end }}
  145. {{- end }}