Skip to content

Commit 750ee92

Browse files
committed
add headless
1 parent 87f9eff commit 750ee92

File tree

4 files changed

+131
-1
lines changed

4 files changed

+131
-1
lines changed

charts/ctrlplane/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: ctrlplane
33
description: Ctrlplane Helm chart for Kubernetes
44
type: application
5-
version: 0.4.6
5+
version: 0.4.7
66
appVersion: "1.16.0"
77

88
maintainers:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- if and .Values.ingress.enabled .Values.service.createIndividualServices }}
2+
{{- range $i := until (.Values.replica | int) }}
3+
---
4+
apiVersion: networking.k8s.io/v1
5+
kind: Ingress
6+
metadata:
7+
name: {{ $.Release.Name }}-engine-{{ $i }}
8+
labels:
9+
{{- include "workspace-engine.labels" $ | nindent 4 }}
10+
{{- if $.Values.ingress.labels -}}
11+
{{- toYaml $.Values.ingress.labels | nindent 4 }}
12+
{{- end }}
13+
pod-index: "{{ $i }}"
14+
annotations:
15+
{{- if $.Values.ingress.annotations -}}
16+
{{- toYaml $.Values.ingress.annotations | nindent 4 }}
17+
{{- end }}
18+
spec:
19+
{{- if $.Values.ingress.className }}
20+
ingressClassName: {{ $.Values.ingress.className }}
21+
{{- end }}
22+
{{- if $.Values.ingress.tls }}
23+
tls:
24+
{{- range $.Values.ingress.tls }}
25+
- hosts:
26+
{{- range .hosts }}
27+
- {{ . | quote }}
28+
{{- end }}
29+
secretName: {{ .secretName }}
30+
{{- end }}
31+
{{- end }}
32+
rules:
33+
{{- range $.Values.ingress.hosts }}
34+
- host: {{ printf "%s-%d.%s" $.Values.ingress.podHostPrefix $i .host | quote }}
35+
http:
36+
paths:
37+
{{- range .paths }}
38+
- path: {{ .path }}
39+
{{- if .pathType }}
40+
pathType: {{ .pathType }}
41+
{{- end }}
42+
backend:
43+
service:
44+
name: {{ $.Release.Name }}-engine-{{ $i }}
45+
port:
46+
number: 8081
47+
{{- end }}
48+
{{- end }}
49+
{{- end }}
50+
{{- end }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{{/* Headless service for StatefulSet */}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ .Release.Name }}-engine
6+
labels:
7+
{{- include "workspace-engine.labels" . | nindent 4 }}
8+
{{- if .Values.service.labels -}}
9+
{{- toYaml .Values.service.labels | nindent 4 }}
10+
{{- end }}
11+
annotations:
12+
{{- if .Values.service.annotations -}}
13+
{{- toYaml .Values.service.annotations | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
clusterIP: None # Headless service for StatefulSet
17+
selector:
18+
{{- include "ctrlplane.selectorLabels" $ | nindent 4 }}
19+
{{- include "workspace-engine.labels" . | nindent 4 }}
20+
ports:
21+
- name: http2
22+
port: 8081
23+
targetPort: http2
24+
protocol: TCP
25+
---
26+
{{/* Individual services for each pod (optional) */}}
27+
{{- if .Values.service.createIndividualServices }}
28+
{{- range $i := until (.Values.replica | int) }}
29+
apiVersion: v1
30+
kind: Service
31+
metadata:
32+
name: {{ $.Release.Name }}-engine-{{ $i }}
33+
labels:
34+
{{- include "workspace-engine.labels" $ | nindent 4 }}
35+
{{- if $.Values.service.labels -}}
36+
{{- toYaml $.Values.service.labels | nindent 4 }}
37+
{{- end }}
38+
pod-index: "{{ $i }}"
39+
annotations:
40+
{{- if $.Values.service.annotations -}}
41+
{{- toYaml $.Values.service.annotations | nindent 4 }}
42+
{{- end }}
43+
spec:
44+
type: {{ $.Values.service.type | default "ClusterIP" }}
45+
selector:
46+
{{- include "ctrlplane.selectorLabels" $ | nindent 4 }}
47+
{{- include "workspace-engine.labels" $ | nindent 4 }}
48+
statefulset.kubernetes.io/pod-name: {{ $.Release.Name }}-engine-{{ $i }}
49+
ports:
50+
- name: http2
51+
port: 8081
52+
targetPort: http2
53+
protocol: TCP
54+
{{- if and (eq ($.Values.service.type | default "ClusterIP") "NodePort") $.Values.service.nodePorts }}
55+
nodePort: {{ add ($.Values.service.nodePorts.basePort | default 30000) $i }}
56+
{{- end }}
57+
---
58+
{{- end }}
59+
{{- end }}

charts/ctrlplane/charts/workspace-engine/values.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ image:
1212
tag: latest
1313
pullPolicy: Always
1414

15+
service:
16+
labels: {}
17+
annotations: {}
18+
type: ClusterIP
19+
createIndividualServices: false # Set to true to create individual services for each pod
20+
nodePorts:
21+
basePort: 30080 # Base port for NodePort services (only used if type is NodePort and createIndividualServices is true)
22+
23+
ingress:
24+
enabled: false
25+
className: ""
26+
labels: {}
27+
annotations: {}
28+
podHostPrefix: "engine" # Creates hostnames like engine-0.example.com, engine-1.example.com
29+
hosts:
30+
- host: example.com
31+
paths:
32+
- path: /
33+
pathType: Prefix
34+
tls: []
35+
1536
extraEnv: {}
1637
extraEnvFrom: {}
1738

0 commit comments

Comments
 (0)