oap-deployment.yaml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. apiVersion: apps/v1
  16. kind: Deployment
  17. metadata:
  18. labels:
  19. app: {{ template "skywalking.name" . }}
  20. chart: {{ .Chart.Name }}-{{ .Chart.Version }}
  21. component: "{{ .Values.oap.name }}"
  22. heritage: {{ .Release.Service }}
  23. release: {{ .Release.Name }}
  24. name: {{ template "skywalking.oap.fullname" . }}
  25. spec:
  26. replicas: {{ .Values.oap.replicas }}
  27. selector:
  28. matchLabels:
  29. app: {{ template "skywalking.name" . }}
  30. component: "{{ .Values.oap.name }}"
  31. release: {{ .Release.Name }}
  32. template:
  33. metadata:
  34. labels:
  35. app: {{ template "skywalking.name" . }}
  36. component: "{{ .Values.oap.name }}"
  37. release: {{ .Release.Name }}
  38. {{- if .Values.oap.podAnnotations }}
  39. annotations:
  40. {{ toYaml .Values.oap.podAnnotations | indent 8 }}
  41. {{- end }}
  42. spec:
  43. serviceAccountName: {{ template "skywalking.serviceAccountName.oap" . }}
  44. affinity:
  45. {{- if eq .Values.oap.antiAffinity "hard" }}
  46. podAntiAffinity:
  47. requiredDuringSchedulingIgnoredDuringExecution:
  48. - topologyKey: "kubernetes.io/hostname"
  49. labelSelector:
  50. matchLabels:
  51. app: "{{ template "skywalking.name" . }}"
  52. release: "{{ .Release.Name }}"
  53. component: "{{ .Values.oap.name }}"
  54. {{- else if eq .Values.oap.antiAffinity "soft" }}
  55. podAntiAffinity:
  56. preferredDuringSchedulingIgnoredDuringExecution:
  57. - weight: 1
  58. podAffinityTerm:
  59. topologyKey: kubernetes.io/hostname
  60. labelSelector:
  61. matchLabels:
  62. app: "{{ template "skywalking.name" . }}"
  63. release: "{{ .Release.Name }}"
  64. component: "{{ .Values.oap.name }}"
  65. {{- end }}
  66. {{- with .Values.oap.nodeAffinity }}
  67. nodeAffinity:
  68. {{ toYaml . | indent 10 }}
  69. {{- end }}
  70. {{- if .Values.oap.nodeSelector }}
  71. nodeSelector:
  72. {{ toYaml .Values.oap.nodeSelector | indent 8 }}
  73. {{- end }}
  74. {{- if .Values.oap.tolerations }}
  75. tolerations:
  76. {{ toYaml .Values.oap.tolerations | indent 8 }}
  77. {{- end }}
  78. {{- if .Values.imagePullSecrets }}
  79. imagePullSecrets:
  80. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  81. {{- end }}
  82. initContainers:
  83. {{- if hasPrefix "elasticsearch" .Values.oap.storageType }}
  84. {{- include "skywalking.containers.wait-for-es" . | nindent 6 }}
  85. {{- end }}
  86. containers:
  87. - name: {{ .Values.oap.name }}
  88. image: {{ .Values.oap.image.repository }}:{{ required "oap.image.tag is required" .Values.oap.image.tag }}
  89. imagePullPolicy: {{ .Values.oap.image.pullPolicy }}
  90. livenessProbe:
  91. tcpSocket:
  92. port: 12800
  93. initialDelaySeconds: 15
  94. periodSeconds: 20
  95. readinessProbe:
  96. tcpSocket:
  97. port: 12800
  98. initialDelaySeconds: 15
  99. periodSeconds: 20
  100. ports:
  101. {{- range $key, $value := .Values.oap.ports }}
  102. - containerPort: {{ $value }}
  103. name: {{ $key }}
  104. {{- end }}
  105. {{- if .Values.oap.resources }}
  106. resources:
  107. {{ toYaml .Values.oap.resources | indent 10 }}
  108. {{- end }}
  109. env:
  110. - name: JAVA_OPTS
  111. value: "-Dmode=no-init {{ .Values.oap.javaOpts }}"
  112. - name: SW_CLUSTER
  113. value: kubernetes
  114. - name: SW_CLUSTER_K8S_NAMESPACE
  115. value: "{{ .Release.Namespace }}"
  116. {{- if .Values.oap.dynamicConfigEnabled }}
  117. - name: SW_CONFIGURATION
  118. value: k8s-configmap
  119. - name: SW_CONFIG_CONFIGMAP_PERIOD
  120. value: "60"
  121. {{- end }}
  122. - name: SW_CLUSTER_K8S_LABEL
  123. value: "{{ template "skywalking.oap.labels" . }}"
  124. - name: SKYWALKING_COLLECTOR_UID
  125. valueFrom:
  126. fieldRef:
  127. fieldPath: metadata.uid
  128. - name: SW_STORAGE
  129. value: {{ required "oap.storageType is required" .Values.oap.storageType }}
  130. - name: SW_STORAGE_ES_CLUSTER_NODES
  131. {{- if .Values.elasticsearch.enabled }}
  132. value: "{{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }}:{{ .Values.elasticsearch.httpPort }}"
  133. {{- else }}
  134. value: "{{ .Values.elasticsearch.config.host }}:{{ .Values.elasticsearch.config.port.http }}"
  135. {{- end }}
  136. {{- if not .Values.elasticsearch.enabled }}
  137. {{- if .Values.elasticsearch.config.user }}
  138. - name: SW_ES_USER
  139. value: "{{ .Values.elasticsearch.config.user }}"
  140. {{- end }}
  141. {{- if .Values.elasticsearch.config.password }}
  142. - name: SW_ES_PASSWORD
  143. value: "{{ .Values.elasticsearch.config.password }}"
  144. {{- end }}
  145. {{- end }}
  146. {{- range $key, $value := .Values.oap.env }}
  147. - name: {{ $key }}
  148. value: {{ $value | quote }}
  149. {{- end }}
  150. volumeMounts:
  151. {{- if (.Files.Glob "files/conf.d/oap/**") }}
  152. {{ range $path, $bytes := .Files.Glob "files/conf.d/oap/**" }}
  153. - name: skywalking-oap-override
  154. mountPath: {{ print "/skywalking/config/" ($path | replace "files/conf.d/oap/" "") }}
  155. subPath: {{ $path | replace "files/conf.d/oap/" "" | b64enc | replace "=" "-" }}
  156. {{- end }}
  157. {{- end }}
  158. volumes:
  159. {{- if (.Files.Glob "files/conf.d/oap/**") }}
  160. - name: skywalking-oap-override
  161. configMap:
  162. name: {{ template "skywalking.fullname" . }}-oap-cm-override
  163. {{- end }}