You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2022/11/18 09:59:23 UTC
[skywalking-kubernetes] branch master updated: Refactor oap init job, and support postgresql storage (#96)
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 5084206 Refactor oap init job, and support postgresql storage (#96)
5084206 is described below
commit 5084206da311eab0f38d65ee63b89ce9347228b8
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri Nov 18 17:59:18 2022 +0800
Refactor oap init job, and support postgresql storage (#96)
---
chart/skywalking/Chart.yaml | 4 ++
chart/skywalking/README.md | 6 +--
chart/skywalking/templates/_helpers.tpl | 59 ++++++++++++++++++++++++--
chart/skywalking/templates/oap-deployment.yaml | 23 +---------
chart/skywalking/templates/oap-init.job.yaml | 37 +++++-----------
chart/skywalking/values.yaml | 20 ++++++++-
6 files changed, 94 insertions(+), 55 deletions(-)
diff --git a/chart/skywalking/Chart.yaml b/chart/skywalking/Chart.yaml
index 87072cf..78ee446 100644
--- a/chart/skywalking/Chart.yaml
+++ b/chart/skywalking/Chart.yaml
@@ -34,3 +34,7 @@ dependencies:
version: ~7.5.1
repository: https://helm.elastic.co/
condition: elasticsearch.enabled
+ - name: postgresql
+ version: 12.1.2
+ repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
+ condition: postgresql.enabled
diff --git a/chart/skywalking/README.md b/chart/skywalking/README.md
index d629244..74b5acc 100644
--- a/chart/skywalking/README.md
+++ b/chart/skywalking/README.md
@@ -80,9 +80,9 @@ The following table lists the configurable parameters of the Skywalking chart an
| `ui.service.loadBalancerIP` | Load Balancer IP address | `nil` |
| `ui.service.annotations` | Kubernetes service annotations | `{}` |
| `ui.service.loadBalancerSourceRanges` | Limit load balancer source IPs to list of CIDRs (where available)) | `[]` |
-| `esInit.nodeAffinity` | ES init job node affinity policy | `{}` |
-| `esInit.nodeSelector` | ES init job labels for master pod assignment | `{}` |
-| `esInit.tolerations` | ES init job tolerations | `[]` |
+| `oapInit.nodeAffinity` | OAP init job node affinity policy | `{}` |
+| `oapInit.nodeSelector` | OAP init job labels for master pod assignment | `{}` |
+| `oapInit.tolerations` | OAP init job tolerations | `[]` |
| `elasticsearch.enabled` | Spin up a new elasticsearch cluster for SkyWalking | `true` |
| `elasticsearch.clusterName` | This will be used as the Elasticsearch [cluster.name](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.name.html) and should be unique per cluster in the namespace | `elasticsearch` |
| `elasticsearch.nodeGroup` | This is the name that will be used for each group of nodes in the cluster. The name will be `clusterName-nodeGroup-X` | `master` |
diff --git a/chart/skywalking/templates/_helpers.tpl b/chart/skywalking/templates/_helpers.tpl
index f218240..a7b6ad9 100644
--- a/chart/skywalking/templates/_helpers.tpl
+++ b/chart/skywalking/templates/_helpers.tpl
@@ -85,13 +85,66 @@ Create the name of the service account to use for the satellite cluster
{{ default (include "skywalking.satellite.fullname" .) .Values.serviceAccounts.satellite }}
{{- end -}}
-{{- define "skywalking.containers.wait-for-es" -}}
+{{- define "skywalking.containers.wait-for-storage" -}}
+{{- if eq .Values.oap.storageType "elasticsearch" }}
- name: wait-for-elasticsearch
image: {{ .Values.initContainer.image }}:{{ .Values.initContainer.tag }}
imagePullPolicy: IfNotPresent
-{{- if .Values.elasticsearch.enabled }}
+ {{- if .Values.elasticsearch.enabled }}
command: ['sh', '-c', 'for i in $(seq 1 60); do nc -z -w3 {{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }} {{ .Values.elasticsearch.httpPort }} && exit 0 || sleep 5; done; exit 1']
-{{- else }}
+ {{- else }}
command: ['sh', '-c', 'for i in $(seq 1 60); do nc -z -w3 {{ .Values.elasticsearch.config.host }} {{ .Values.elasticsearch.config.port.http }} && exit 0 || sleep 5; done; exit 1']
+ {{- end }}
+{{- else if eq .Values.oap.storageType "postgresql" -}}
+- name: wait-for-postgresql
+ image: postgres:13
+ imagePullPolicy: IfNotPresent
+ command:
+ - sh
+ - -c
+ - |
+ {{- if .Values.postgresql.enabled }}
+ until pg_isready -h '{{ template "skywalking.name" . }}-postgresql' -p '{{ .Values.postgresql.containerPorts.postgresql }}' -U '{{ .Values.postgresql.auth.username }}'; do
+ {{- else }}
+ until pg_isready -h '{{ .Values.postgresql.config.host }}' -p '{{ .Values.postgresql.containerPorts.postgresql }}' -U '{{ .Values.postgresql.auth.username }}'; do
+ {{- end }}
+ echo "Waiting for postgresql..."
+ sleep 3
+ done
+{{- end }}
+{{- end -}}
+
+# Storage-related environment variables are defined here.
+{{- define "skywalking.oap.envs.storage" -}}
+- name: SW_STORAGE
+ value: {{ required "oap.storageType is required" .Values.oap.storageType }}
+{{- if eq .Values.oap.storageType "elasticsearch" }}
+- name: SW_STORAGE_ES_CLUSTER_NODES
+ {{- if .Values.elasticsearch.enabled }}
+ value: "{{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }}:{{ .Values.elasticsearch.httpPort }}"
+ {{- else }}
+ value: "{{ .Values.elasticsearch.config.host }}:{{ .Values.elasticsearch.config.port.http }}"
+ {{- end }}
+ {{- if not .Values.elasticsearch.enabled }}
+ {{- if .Values.elasticsearch.config.user }}
+- name: SW_ES_USER
+ value: "{{ .Values.elasticsearch.config.user }}"
+ {{- end }}
+ {{- if .Values.elasticsearch.config.password }}
+- name: SW_ES_PASSWORD
+ value: "{{ .Values.elasticsearch.config.password }}"
+ {{- end }}
+ {{- end }}
+{{- else if eq .Values.oap.storageType "postgresql" }}
+{{- $postgresqlHost := print (include "skywalking.name" .) "-postgresql" -}}
+{{- if not .Values.postgresql.enabled -}}
+{{- $postgresqlHost = .Values.postgresql.config.host -}}
+{{- end }}
+- name: SW_JDBC_URL
+ value: "jdbc:postgresql://{{ $postgresqlHost }}:{{ .Values.postgresql.containerPorts.postgresql }}/{{ .Values.postgresql.auth.database }}"
+- name: SW_DATA_SOURCE_USER
+ value: "{{ .Values.postgresql.auth.username }}"
+- name: SW_DATA_SOURCE_PASSWORD
+ value: "{{ .Values.postgresql.auth.password }}"
{{- end }}
{{- end -}}
diff --git a/chart/skywalking/templates/oap-deployment.yaml b/chart/skywalking/templates/oap-deployment.yaml
index d627a97..5406f64 100644
--- a/chart/skywalking/templates/oap-deployment.yaml
+++ b/chart/skywalking/templates/oap-deployment.yaml
@@ -81,9 +81,7 @@ spec:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
initContainers:
- {{- if hasPrefix "elasticsearch" .Values.oap.storageType }}
- {{- include "skywalking.containers.wait-for-es" . | nindent 6 }}
- {{- end }}
+ {{- include "skywalking.containers.wait-for-storage" . | nindent 6 }}
containers:
- name: {{ .Values.oap.name }}
image: {{ .Values.oap.image.repository }}:{{ required "oap.image.tag is required" .Values.oap.image.tag }}
@@ -126,24 +124,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.uid
- - name: SW_STORAGE
- value: {{ required "oap.storageType is required" .Values.oap.storageType }}
- - name: SW_STORAGE_ES_CLUSTER_NODES
-{{- if .Values.elasticsearch.enabled }}
- value: "{{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }}:{{ .Values.elasticsearch.httpPort }}"
-{{- else }}
- value: "{{ .Values.elasticsearch.config.host }}:{{ .Values.elasticsearch.config.port.http }}"
-{{- end }}
-{{- if not .Values.elasticsearch.enabled }}
- {{- if .Values.elasticsearch.config.user }}
- - name: SW_ES_USER
- value: "{{ .Values.elasticsearch.config.user }}"
- {{- end }}
- {{- if .Values.elasticsearch.config.password }}
- - name: SW_ES_PASSWORD
- value: "{{ .Values.elasticsearch.config.password }}"
- {{- end }}
-{{- end }}
+ {{- include "skywalking.oap.envs.storage" . | nindent 8 }}
{{- range $key, $value := .Values.oap.env }}
- name: {{ $key }}
value: {{ $value | quote }}
diff --git a/chart/skywalking/templates/oap-init.job.yaml b/chart/skywalking/templates/oap-init.job.yaml
index 60db860..d061066 100644
--- a/chart/skywalking/templates/oap-init.job.yaml
+++ b/chart/skywalking/templates/oap-init.job.yaml
@@ -18,7 +18,7 @@
apiVersion: batch/v1
kind: Job
metadata:
- name: "{{ .Release.Name }}-es-init"
+ name: "{{ .Release.Name }}-oap-init"
labels:
app: {{ template "skywalking.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
@@ -31,27 +31,27 @@ metadata:
spec:
template:
metadata:
- name: "{{ .Release.Name }}-es-init"
+ name: "{{ .Release.Name }}-oap-init"
labels:
app: {{ template "skywalking.name" . }}
component: "{{ template "skywalking.fullname" . }}-job"
release: {{ .Release.Name }}
spec:
serviceAccountName: {{ template "skywalking.serviceAccountName.oap" . }}
- {{- if .Values.esInit.nodeAffinity }}
+ {{- if .Values.oapInit.nodeAffinity }}
affinity:
{{- end }}
- {{- with .Values.esInit.nodeAffinity }}
+ {{- with .Values.oapInit.nodeAffinity }}
nodeAffinity:
{{ toYaml . | indent 10 }}
{{- end }}
-{{- if .Values.esInit.nodeSelector }}
+{{- if .Values.oapInit.nodeSelector }}
nodeSelector:
-{{ toYaml .Values.esInit.nodeSelector | indent 8 }}
+{{ toYaml .Values.oapInit.nodeSelector | indent 8 }}
{{- end }}
-{{- if .Values.esInit.tolerations }}
+{{- if .Values.oapInit.tolerations }}
tolerations:
-{{ toYaml .Values.esInit.tolerations | indent 8 }}
+{{ toYaml .Values.oapInit.tolerations | indent 8 }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
@@ -59,7 +59,7 @@ spec:
{{- end }}
restartPolicy: Never
initContainers:
- {{- include "skywalking.containers.wait-for-es" . | nindent 6 }}
+ {{- include "skywalking.containers.wait-for-storage" . | nindent 6 }}
containers:
- name: {{ .Values.oap.name }}
image: {{ .Values.oap.image.repository }}:{{ required "oap.image.tag is required" .Values.oap.image.tag }}
@@ -71,24 +71,7 @@ spec:
env:
- name: JAVA_OPTS
value: "{{ .Values.oap.javaOpts }} -Dmode=init"
- - name: SW_STORAGE
- value: {{ required "oap.storageType is required" .Values.oap.storageType }}
- - name: SW_STORAGE_ES_CLUSTER_NODES
-{{- if .Values.elasticsearch.enabled }}
- value: "{{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }}:{{ .Values.elasticsearch.httpPort }}"
-{{- else }}
- value: "{{ .Values.elasticsearch.config.host }}:{{ .Values.elasticsearch.config.port.http }}"
-{{- end }}
-{{- if not .Values.elasticsearch.enabled }}
- {{- if .Values.elasticsearch.config.user }}
- - name: SW_ES_USER
- value: "{{ .Values.elasticsearch.config.user }}"
- {{- end }}
- {{- if .Values.elasticsearch.config.password }}
- - name: SW_ES_PASSWORD
- value: "{{ .Values.elasticsearch.config.password }}"
- {{- end }}
-{{- end }}
+ {{- include "skywalking.oap.envs.storage" . | nindent 8 }}
{{- range $key, $value := .Values.oap.env }}
- name: {{ $key }}
value: {{ $value | quote }}
diff --git a/chart/skywalking/values.yaml b/chart/skywalking/values.yaml
index ade4916..f228e3d 100644
--- a/chart/skywalking/values.yaml
+++ b/chart/skywalking/values.yaml
@@ -117,7 +117,7 @@ ui:
## Limit load balancer source ips to list of CIDRs (where available)
# loadBalancerSourceRanges: []
-esInit:
+oapInit:
nodeAffinity: {}
nodeSelector: {}
tolerations: []
@@ -371,6 +371,24 @@ elasticsearch:
keystore: []
+postgresql:
+ enabled: false # Whether to start a demo postgresql deployment, don't use this for production.
+ config:
+ # The hostname of your own postgresql service, this only takes effect when postgresql.enabled is false.
+ host: postgresql-service.your-awesome-company.com
+ auth:
+ username: postgres
+ password: "123456"
+ database: skywalking
+ containerPorts:
+ postgresql: 5432
+ primary:
+ persistence:
+ enabled: false
+ readReplicas:
+ persistence:
+ enabled: false
+
satellite:
name: satellite
replicas: 1