Skip to content

Commit 07d66d8

Browse files
authored
ReplicaSet, node ID, AWS NLB (#37)
* ReplicaSet * Chart version
1 parent e820bf7 commit 07d66d8

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
apiVersion: v1
22
name: pgdog
3-
version: v0.22
3+
version: v0.23

templates/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
apiVersion: apps/v1
2+
{{- if .Values.statefulSet.enabled }}
3+
kind: StatefulSet
4+
{{- else }}
25
kind: Deployment
6+
{{- end }}
37
metadata:
48
name: {{ include "pgdog.fullname" . }}
59
labels:
610
{{- include "pgdog.labels" . | nindent 4 }}
711
spec:
12+
{{- if .Values.statefulSet.enabled }}
13+
serviceName: {{ include "pgdog.fullname" . }}-headless
14+
{{- end }}
815
replicas: {{ .Values.replicas }}
916
selector:
1017
matchLabels:
@@ -35,6 +42,11 @@ spec:
3542
- "/etc/pgdog/pgdog.toml"
3643
- "--users"
3744
- "/etc/secrets/pgdog/users.toml"
45+
env:
46+
- name: NODE_ID
47+
valueFrom:
48+
fieldRef:
49+
fieldPath: metadata.name
3850
ports:
3951
- name: pgdog
4052
containerPort: {{ .Values.port }}

templates/service-headless.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.statefulSet.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "pgdog.fullname" . }}-headless
6+
labels:
7+
{{- include "pgdog.labels" . | nindent 4 }}
8+
spec:
9+
type: ClusterIP
10+
clusterIP: None
11+
selector:
12+
{{- include "pgdog.selectorLabels" . | nindent 4 }}
13+
ports:
14+
- name: pgdog
15+
protocol: TCP
16+
port: {{ .Values.port }}
17+
targetPort: {{ .Values.port }}
18+
- name: openmetrics
19+
protocol: TCP
20+
port: {{ .Values.openMetricsPort }}
21+
targetPort: {{ .Values.openMetricsPort }}
22+
{{- end }}

templates/service.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: {{ include "pgdog.fullname" . }}
5-
{{- if .Values.service.annotations }}
5+
{{- if or .Values.service.annotations .Values.service.aws.enabled }}
66
annotations:
7-
{{- toYaml .Values.service.annotations | nindent 4 }}
7+
{{- if .Values.service.aws.enabled }}
8+
service.beta.kubernetes.io/aws-load-balancer-scheme: {{ .Values.service.aws.scheme | quote }}
9+
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
10+
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip"
11+
service.beta.kubernetes.io/aws-load-balancer-type: "external"
12+
service.beta.kubernetes.io/aws-load-balancer-manage-backend-security-group-rules: "true"
13+
service.beta.kubernetes.io/aws-load-balancer-listener-attributes.TCP-{{ .Values.port }}: tcp.idle_timeout.seconds=1800
14+
{{- end }}
15+
{{- with .Values.service.annotations }}
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
818
{{- end }}
919
labels:
1020
{{- include "pgdog.labels" . | nindent 4 }}
1121
spec:
22+
{{- if .Values.service.aws.enabled }}
23+
type: LoadBalancer
24+
loadBalancerClass: service.k8s.aws/nlb
25+
{{- else }}
1226
type: {{ .Values.service.type }}
27+
{{- end }}
1328
selector:
1429
{{- include "pgdog.selectorLabels" . | nindent 4 }}
1530
{{- if .Values.service.trafficDistribution }}

values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ port: 6432
4040
# replicas indicates how many instances of PgDog will run (HA).
4141
replicas: 2
4242

43+
# statefulSet controls whether to deploy as StatefulSet instead of Deployment
44+
# StatefulSet provides stable DNS hostnames for each pod (e.g., pgdog-0, pgdog-1)
45+
statefulSet:
46+
# enabled switches from Deployment to StatefulSet
47+
enabled: false
48+
4349
# resources define resource requests and limits for the pgdog container
4450
# Note: requests and limits are set to the same values for Guaranteed QoS
4551
# Ratio: 1GB memory per 1 CPU (1000m CPU = 1Gi memory)
@@ -106,6 +112,14 @@ service:
106112
# (PreferClose, PreferSameZone, PreferSameNode)
107113
# see https://kubernetes.io/docs/reference/networking/virtual-ips/#traffic-distribution for more details.
108114
trafficDistribution: ""
115+
# aws configures AWS Load Balancer Controller annotations
116+
# When enabled, service type is automatically set to LoadBalancer
117+
aws:
118+
# enabled controls whether to add AWS LB annotations
119+
enabled: false
120+
# scheme controls whether the load balancer is internet-facing or internal
121+
# Valid values: "internet-facing" or "internal"
122+
scheme: "internal"
109123

110124

111125
# nodeSelector allows scheduling pods on nodes with specific labels

0 commit comments

Comments
 (0)