Skip to content

Commit bfadd37

Browse files
[BACKPORT 2.6] Add PostgreSQL service (#77)
1 parent 79c7c99 commit bfadd37

File tree

3 files changed

+215
-176
lines changed

3 files changed

+215
-176
lines changed

stable/yugaware/templates/service.yaml

Lines changed: 18 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -41,186 +41,30 @@ spec:
4141
loadBalancerIP: "{{ .Values.yugaware.service.ip }}"
4242
{{- end }}
4343
{{- end }}
44+
{{- if .Values.postgres.service.enabled }}
4445
---
45-
apiVersion: apps/v1
46-
kind: StatefulSet
46+
apiVersion: v1
47+
kind: Service
4748
metadata:
48-
name: {{ .Release.Name }}-yugaware
49+
name: {{ .Release.Name }}-postgres
50+
{{- if .Values.postgres.service.annotations }}
51+
annotations:
52+
{{ toYaml .Values.postgres.service.annotations | indent 4 }}
53+
{{- end }}
4954
labels:
5055
app: {{ .Release.Name }}-yugaware
5156
chart: {{ template "yugaware.chart" . }}
5257
release: {{ .Release.Name }}
5358
heritage: {{ .Values.helm2Legacy | ternary "Tiller" (.Release.Service | quote) }}
5459
spec:
55-
serviceName: {{ .Release.Name }}-yugaware
56-
replicas: {{ .Values.yugaware.replicas }}
60+
ports:
61+
- name: postgres
62+
port: 5432
63+
targetPort: 5432
5764
selector:
58-
matchLabels:
59-
app: {{ .Release.Name }}-yugaware
60-
template:
61-
metadata:
62-
labels:
63-
app: {{ .Release.Name }}-yugaware
64-
spec:
65-
serviceAccountName: {{ .Release.Name }}
66-
imagePullSecrets:
67-
- name: {{ .Values.image.pullSecret }}
68-
{{- if .Values.securityContext.enabled }}
69-
securityContext:
70-
fsGroup: {{ .Values.securityContext.fsGroup }}
71-
{{- end }}
72-
volumes:
73-
- name: yugaware-storage
74-
persistentVolumeClaim:
75-
claimName: {{ .Release.Name }}-yugaware-storage
76-
- name: yugaware-ui
77-
emptyDir: {}
78-
- name: yugaware-config
79-
configMap:
80-
name: {{ .Release.Name }}-yugaware-app-config
81-
items:
82-
- key: application.docker.conf
83-
path: application.docker.conf
84-
- name: nginx-config
85-
configMap:
86-
name: {{ .Release.Name }}-yugaware-nginx-config
87-
items:
88-
- key: default.conf
89-
path: default.conf
90-
- name: prometheus-config
91-
configMap:
92-
name: {{ .Release.Name }}-yugaware-prometheus-config
93-
items:
94-
- key: prometheus.yml
95-
path: prometheus.yml
96-
97-
{{- if .Values.tls.enabled }}
98-
- name: {{ .Release.Name }}-yugaware-tls-cert
99-
secret:
100-
secretName: {{ .Release.Name }}-yugaware-tls-cert
101-
{{- end }}
102-
containers:
103-
- image: {{ include "full_image" (dict "containerName" "postgres" "root" .) }}
104-
name: postgres
105-
env:
106-
- name: POSTGRES_USER
107-
valueFrom:
108-
configMapKeyRef:
109-
name: {{ .Release.Name }}-yugaware-global-config
110-
key: postgres_user
111-
- name: POSTGRES_PASSWORD
112-
valueFrom:
113-
configMapKeyRef:
114-
name: {{ .Release.Name }}-yugaware-global-config
115-
key: postgres_password
116-
- name: POSTGRES_DB
117-
valueFrom:
118-
configMapKeyRef:
119-
name: {{ .Release.Name }}-yugaware-global-config
120-
key: postgres_db
121-
- name: PGDATA
122-
value: /var/lib/postgresql/data/pgdata
123-
ports:
124-
- containerPort: 5432
125-
name: postgres
126-
volumeMounts:
127-
- name: yugaware-storage
128-
mountPath: /var/lib/postgresql/data
129-
subPath: postgres_data
130-
- name: prometheus
131-
image: {{ include "full_image" (dict "containerName" "prometheus" "root" .) }}
132-
{{- if (not .Values.ocpCompatibility.enabled) }}
133-
securityContext:
134-
runAsUser: 0
135-
{{- end }}
136-
volumeMounts:
137-
- name: yugaware-storage
138-
mountPath: /prometheus_configs
139-
subPath: prometheus.yml
140-
- name: yugaware-storage
141-
mountPath: /prometheus/
142-
- name: yugaware-storage
143-
mountPath: /opt/yugabyte/prometheus/targets
144-
subPath: swamper_targets
145-
args:
146-
- --config.file=/prometheus_configs/prometheus.yml
147-
- --storage.tsdb.path=/prometheus/
148-
- --web.enable-admin-api
149-
- --web.enable-lifecycle
150-
ports:
151-
- containerPort: 9090
152-
- name: yugaware
153-
image: {{ include "full_yugaware_image" . }}
154-
{{- if .Values.securityContext.enabled }}
155-
securityContext:
156-
runAsUser: {{ .Values.securityContext.runAsUser }}
157-
{{- end }}
158-
imagePullPolicy: {{ .Values.image.pullPolicy }}
159-
{{- if .Values.yugaware.resources }}
160-
resources:
161-
{{ toYaml .Values.yugaware.resources | indent 12 }}
162-
{{- end }}
163-
command: [ "/bin/bash", "-c"]
164-
args:
165-
- "cp /default_prometheus_config/prometheus.yml /prometheus_configs/prometheus.yml && bin/yugaware -Dconfig.file=/data/application.docker.conf"
166-
env:
167-
- name: POSTGRES_USER
168-
valueFrom:
169-
configMapKeyRef:
170-
name: {{ .Release.Name }}-yugaware-global-config
171-
key: postgres_user
172-
- name: POSTGRES_PASSWORD
173-
valueFrom:
174-
configMapKeyRef:
175-
name: {{ .Release.Name }}-yugaware-global-config
176-
key: postgres_password
177-
- name: POSTGRES_DB
178-
valueFrom:
179-
configMapKeyRef:
180-
name: {{ .Release.Name }}-yugaware-global-config
181-
key: postgres_db
182-
- name: APP_SECRET
183-
valueFrom:
184-
configMapKeyRef:
185-
name: {{ .Release.Name }}-yugaware-global-config
186-
key: app_secret
187-
ports:
188-
- containerPort: 9000
189-
name: yugaware
190-
volumeMounts:
191-
- name: yugaware-config
192-
mountPath: /data
193-
- name: yugaware-storage
194-
mountPath: /opt/yugabyte/yugaware/data/
195-
subPath: data
196-
# old path for backward compatibility
197-
- name: yugaware-storage
198-
mountPath: /opt/yugaware_data/
199-
subPath: data
200-
- name: yugaware-storage
201-
mountPath: /opt/yugabyte/releases/
202-
subPath: releases
203-
# old path for backward compatibility
204-
- name: yugaware-storage
205-
mountPath: /opt/releases/
206-
subPath: releases
207-
- name: yugaware-storage
208-
mountPath: /opt/yugabyte/prometheus/targets
209-
subPath: swamper_targets
210-
- name: prometheus-config
211-
mountPath: /default_prometheus_config
212-
- name: yugaware-storage
213-
mountPath: /prometheus_configs
214-
subPath: prometheus.yml
215-
- name: nginx
216-
image: {{ include "full_image" (dict "containerName" "nginx" "root" .) }}
217-
ports:
218-
- containerPort: 8080
219-
volumeMounts:
220-
- mountPath: /etc/nginx/conf.d/
221-
name: nginx-config
222-
{{- if .Values.tls.enabled }}
223-
- name: {{ .Release.Name }}-yugaware-tls-cert
224-
mountPath: /opt/certs/
225-
readOnly: true
226-
{{- end }}
65+
app: {{ .Release.Name }}-yugaware
66+
type: {{ .Values.postgres.service.type }}
67+
{{- if and (eq .Values.postgres.service.type "LoadBalancer") (.Values.postgres.service.ip) }}
68+
loadBalancerIP: "{{ .Values.postgres.service.ip }}"
69+
{{- end }}
70+
{{- end }}
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Copyright (c) YugaByte, Inc.
2+
3+
---
4+
apiVersion: apps/v1
5+
kind: StatefulSet
6+
metadata:
7+
name: {{ .Release.Name }}-yugaware
8+
labels:
9+
app: {{ .Release.Name }}-yugaware
10+
chart: {{ template "yugaware.chart" . }}
11+
release: {{ .Release.Name }}
12+
heritage: {{ .Values.helm2Legacy | ternary "Tiller" (.Release.Service | quote) }}
13+
spec:
14+
serviceName: {{ .Release.Name }}-yugaware
15+
replicas: {{ .Values.yugaware.replicas }}
16+
selector:
17+
matchLabels:
18+
app: {{ .Release.Name }}-yugaware
19+
template:
20+
metadata:
21+
labels:
22+
app: {{ .Release.Name }}-yugaware
23+
spec:
24+
serviceAccountName: {{ .Release.Name }}
25+
imagePullSecrets:
26+
- name: {{ .Values.image.pullSecret }}
27+
{{- if .Values.securityContext.enabled }}
28+
securityContext:
29+
fsGroup: {{ .Values.securityContext.fsGroup }}
30+
{{- end }}
31+
volumes:
32+
- name: yugaware-storage
33+
persistentVolumeClaim:
34+
claimName: {{ .Release.Name }}-yugaware-storage
35+
- name: yugaware-ui
36+
emptyDir: {}
37+
- name: yugaware-config
38+
configMap:
39+
name: {{ .Release.Name }}-yugaware-app-config
40+
items:
41+
- key: application.docker.conf
42+
path: application.docker.conf
43+
- name: nginx-config
44+
configMap:
45+
name: {{ .Release.Name }}-yugaware-nginx-config
46+
items:
47+
- key: default.conf
48+
path: default.conf
49+
- name: prometheus-config
50+
configMap:
51+
name: {{ .Release.Name }}-yugaware-prometheus-config
52+
items:
53+
- key: prometheus.yml
54+
path: prometheus.yml
55+
56+
{{- if .Values.tls.enabled }}
57+
- name: {{ .Release.Name }}-yugaware-tls-cert
58+
secret:
59+
secretName: {{ .Release.Name }}-yugaware-tls-cert
60+
{{- end }}
61+
containers:
62+
- image: {{ include "full_image" (dict "containerName" "postgres" "root" .) }}
63+
name: postgres
64+
env:
65+
- name: POSTGRES_USER
66+
valueFrom:
67+
configMapKeyRef:
68+
name: {{ .Release.Name }}-yugaware-global-config
69+
key: postgres_user
70+
- name: POSTGRES_PASSWORD
71+
valueFrom:
72+
configMapKeyRef:
73+
name: {{ .Release.Name }}-yugaware-global-config
74+
key: postgres_password
75+
- name: POSTGRES_DB
76+
valueFrom:
77+
configMapKeyRef:
78+
name: {{ .Release.Name }}-yugaware-global-config
79+
key: postgres_db
80+
- name: PGDATA
81+
value: /var/lib/postgresql/data/pgdata
82+
ports:
83+
- containerPort: 5432
84+
name: postgres
85+
volumeMounts:
86+
- name: yugaware-storage
87+
mountPath: /var/lib/postgresql/data
88+
subPath: postgres_data
89+
- name: prometheus
90+
image: {{ include "full_image" (dict "containerName" "prometheus" "root" .) }}
91+
{{- if (not .Values.ocpCompatibility.enabled) }}
92+
securityContext:
93+
runAsUser: 0
94+
{{- end }}
95+
volumeMounts:
96+
- name: yugaware-storage
97+
mountPath: /prometheus_configs
98+
subPath: prometheus.yml
99+
- name: yugaware-storage
100+
mountPath: /prometheus/
101+
- name: yugaware-storage
102+
mountPath: /opt/yugabyte/prometheus/targets
103+
subPath: swamper_targets
104+
args:
105+
- --config.file=/prometheus_configs/prometheus.yml
106+
- --storage.tsdb.path=/prometheus/
107+
- --web.enable-admin-api
108+
- --web.enable-lifecycle
109+
ports:
110+
- containerPort: 9090
111+
- name: yugaware
112+
image: {{ include "full_yugaware_image" . }}
113+
{{- if .Values.securityContext.enabled }}
114+
securityContext:
115+
runAsUser: {{ .Values.securityContext.runAsUser }}
116+
{{- end }}
117+
imagePullPolicy: {{ .Values.image.pullPolicy }}
118+
{{- if .Values.yugaware.resources }}
119+
resources:
120+
{{ toYaml .Values.yugaware.resources | indent 12 }}
121+
{{- end }}
122+
command: [ "/bin/bash", "-c"]
123+
args:
124+
- "cp /default_prometheus_config/prometheus.yml /prometheus_configs/prometheus.yml && bin/yugaware -Dconfig.file=/data/application.docker.conf"
125+
env:
126+
- name: POSTGRES_USER
127+
valueFrom:
128+
configMapKeyRef:
129+
name: {{ .Release.Name }}-yugaware-global-config
130+
key: postgres_user
131+
- name: POSTGRES_PASSWORD
132+
valueFrom:
133+
configMapKeyRef:
134+
name: {{ .Release.Name }}-yugaware-global-config
135+
key: postgres_password
136+
- name: POSTGRES_DB
137+
valueFrom:
138+
configMapKeyRef:
139+
name: {{ .Release.Name }}-yugaware-global-config
140+
key: postgres_db
141+
- name: APP_SECRET
142+
valueFrom:
143+
configMapKeyRef:
144+
name: {{ .Release.Name }}-yugaware-global-config
145+
key: app_secret
146+
ports:
147+
- containerPort: 9000
148+
name: yugaware
149+
volumeMounts:
150+
- name: yugaware-config
151+
mountPath: /data
152+
- name: yugaware-storage
153+
mountPath: /opt/yugabyte/yugaware/data/
154+
subPath: data
155+
# old path for backward compatibility
156+
- name: yugaware-storage
157+
mountPath: /opt/yugaware_data/
158+
subPath: data
159+
- name: yugaware-storage
160+
mountPath: /opt/yugabyte/releases/
161+
subPath: releases
162+
# old path for backward compatibility
163+
- name: yugaware-storage
164+
mountPath: /opt/releases/
165+
subPath: releases
166+
- name: yugaware-storage
167+
mountPath: /opt/yugabyte/prometheus/targets
168+
subPath: swamper_targets
169+
- name: prometheus-config
170+
mountPath: /default_prometheus_config
171+
- name: yugaware-storage
172+
mountPath: /prometheus_configs
173+
subPath: prometheus.yml
174+
- name: nginx
175+
image: {{ include "full_image" (dict "containerName" "nginx" "root" .) }}
176+
ports:
177+
- containerPort: 8080
178+
volumeMounts:
179+
- mountPath: /etc/nginx/conf.d/
180+
name: nginx-config
181+
{{- if .Values.tls.enabled }}
182+
- name: {{ .Release.Name }}-yugaware-tls-cert
183+
mountPath: /opt/certs/
184+
readOnly: true
185+
{{- end }}

0 commit comments

Comments
 (0)