es-init.job.yaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. # https://docs.sentry.io/server/installation/docker/#running-migrations
  16. {{- if and .Values.oap.initEs (contains "elasticsearch" .Values.oap.storageType) }}
  17. apiVersion: batch/v1
  18. kind: Job
  19. metadata:
  20. name: "{{ .Release.Name }}-es-init"
  21. labels:
  22. app: {{ template "skywalking.name" . }}
  23. chart: {{ .Chart.Name }}-{{ .Chart.Version }}
  24. component: "{{ template "skywalking.fullname" . }}-job"
  25. heritage: {{ .Release.Service }}
  26. release: {{ .Release.Name }}
  27. spec:
  28. template:
  29. metadata:
  30. name: "{{ .Release.Name }}-es-init"
  31. labels:
  32. app: {{ template "skywalking.name" . }}
  33. component: "{{ template "skywalking.fullname" . }}-job"
  34. release: {{ .Release.Name }}
  35. spec:
  36. serviceAccountName: {{ template "skywalking.serviceAccountName.oap" . }}
  37. {{- if .Values.esInit.nodeAffinity }}
  38. affinity:
  39. {{- end }}
  40. {{- with .Values.esInit.nodeAffinity }}
  41. nodeAffinity:
  42. {{ toYaml . | indent 10 }}
  43. {{- end }}
  44. {{- if .Values.esInit.nodeSelector }}
  45. nodeSelector:
  46. {{ toYaml .Values.esInit.nodeSelector | indent 8 }}
  47. {{- end }}
  48. {{- if .Values.esInit.tolerations }}
  49. tolerations:
  50. {{ toYaml .Values.esInit.tolerations | indent 8 }}
  51. {{- end }}
  52. {{- if .Values.imagePullSecrets }}
  53. imagePullSecrets:
  54. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  55. {{- end }}
  56. restartPolicy: Never
  57. initContainers:
  58. {{- include "skywalking.containers.wait-for-es" . | nindent 6 }}
  59. containers:
  60. - name: {{ .Values.oap.name }}
  61. image: {{ .Values.oap.image.repository }}:{{ required "oap.image.tag is required" .Values.oap.image.tag }}
  62. imagePullPolicy: {{ .Values.oap.image.pullPolicy }}
  63. {{- if .Values.oap.resources }}
  64. resources:
  65. {{ toYaml .Values.oap.resources | indent 10 }}
  66. {{- end }}
  67. env:
  68. - name: JAVA_OPTS
  69. value: "{{ .Values.oap.javaOpts }} -Dmode=init"
  70. - name: SW_STORAGE
  71. value: {{ required "oap.storageType is required" .Values.oap.storageType }}
  72. - name: SW_STORAGE_ES_CLUSTER_NODES
  73. {{- if .Values.elasticsearch.enabled }}
  74. value: "{{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }}:{{ .Values.elasticsearch.httpPort }}"
  75. {{- else }}
  76. value: "{{ .Values.elasticsearch.config.host }}:{{ .Values.elasticsearch.config.port.http }}"
  77. {{- end }}
  78. {{- if not .Values.elasticsearch.enabled }}
  79. {{- if .Values.elasticsearch.config.user }}
  80. - name: SW_ES_USER
  81. value: "{{ .Values.elasticsearch.config.user }}"
  82. {{- end }}
  83. {{- if .Values.elasticsearch.config.password }}
  84. - name: SW_ES_PASSWORD
  85. value: "{{ .Values.elasticsearch.config.password }}"
  86. {{- end }}
  87. {{- end }}
  88. {{- range $key, $value := .Values.oap.env }}
  89. - name: {{ $key }}
  90. value: {{ $value | quote }}
  91. {{- end }}
  92. volumeMounts:
  93. {{- if (.Files.Glob "files/conf.d/oap/**") }}
  94. {{ range $path, $bytes := .Files.Glob "files/conf.d/oap/**" }}
  95. - name: skywalking-oap-override
  96. mountPath: {{ print "/skywalking/config/" ($path | replace "files/conf.d/oap/" "") }}
  97. subPath: {{ $path | replace "files/conf.d/oap/" "" | b64enc | replace "=" "-" }}
  98. {{- end }}
  99. {{- end }}
  100. volumes:
  101. {{- if (.Files.Glob "files/conf.d/oap/**") }}
  102. - name: skywalking-oap-override
  103. configMap:
  104. name: {{ template "skywalking.fullname" . }}-oap-cm-override
  105. {{- end }}
  106. {{- end}}