Skip to content

Commit e967591

Browse files
committed
feat: switch between client and headless service
1 parent 0b3be44 commit e967591

7 files changed

Lines changed: 36 additions & 7 deletions

File tree

charts/kamaji-etcd/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Here the values you can override:
6767
| clusterDomain | string | `"cluster.local"` | Domain of the Kubernetes cluster. |
6868
| datastore.annotations | object | `{}` | Assign additional Annotations to the datastore |
6969
| datastore.enabled | bool | `false` | Create a datastore custom resource for Kamaji |
70+
| datastore.headless | bool | `true` | Expose the headless service endpoints in the datastore. Set to false to expose with regular service. |
7071
| datastore.name | string | `""` | Name of Kamaji datastore, set to fully qualified etcd name when null or not provided |
7172
| extraArgs | list | `[]` | A list of extra arguments to add to the etcd default ones |
7273
| fullnameOverride | string | `""` | |

charts/kamaji-etcd/templates/_helpers.tpl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ Create the name of the Service to use
4242
{{- printf "%s" (include "etcd.fullname" .) | trunc 63 | trimSuffix "-" }}
4343
{{- end }}
4444

45+
{{/*
46+
Create the name of the client Service to use
47+
*/}}
48+
{{- define "client.serviceName" -}}
49+
{{- printf "%s-client" (include "etcd.fullname" .) | trunc 63 | trimSuffix "-" }}
50+
{{- end }}
51+
4552
{{/*
4653
Common labels
4754
*/}}
@@ -157,8 +164,8 @@ Space separated list of etcd cluster endpoints.
157164
{{- end }}
158165

159166
{{/*
160-
Create the minio-client fully-qualified Docker image to use
167+
Client cluster endpoints.
161168
*/}}
162-
{{- define "minio-client.fullyQualifiedDockerImage" -}}
163-
{{- printf "%s:%s" .Values.backup.s3.image.repository .Values.backup.s3.image.tag -}}
164-
{{- end }}
169+
{{- define "client.endpointsYAML" }}
170+
{{ printf "- %s.%s.svc.%s:%d\n" ( include "client.serviceName" .) $.Release.Namespace $.Values.clusterDomain (int $.Values.clientPort) }}
171+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
{{- include "etcd.labels" . | nindent 4 }}
6+
name: {{ include "client.serviceName" . }}
7+
namespace: {{ .Release.Namespace }}
8+
spec:
9+
type: ClusterIP
10+
ports:
11+
- port: {{ .Values.clientPort }}
12+
name: client
13+
- port: {{ .Values.metricsPort }}
14+
name: metrics
15+
selector:
16+
{{- include "etcd.selectorLabels" . | nindent 4 }}

charts/kamaji-etcd/templates/etcd_cm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ data:
5858
{{- range $count := until (int $.Values.replicas) -}}
5959
{{ printf "\"%s-%d.%s.%s.svc.%s\"," ( include "etcd.fullname" $outer ) $count (include "etcd.serviceName" $outer) $.Release.Namespace $.Values.clusterDomain }}
6060
{{- end }}
61+
{{ printf "\"%s.%s.svc.%s\"," (include "client.serviceName" .) $.Release.Namespace $.Values.clusterDomain }}
6162
"etcd-server.{{ .Release.Namespace }}.svc.{{ $.Values.clusterDomain }}",
6263
"etcd-server.{{ .Release.Namespace }}.svc",
6364
"etcd-server",

charts/kamaji-etcd/templates/etcd_datastore.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ metadata:
1212
spec:
1313
driver: etcd
1414
endpoints:
15-
{{- include "etcd.endpointsYAML" . | nindent 4 }}
15+
{{- if or (not (hasKey .Values.datastore "headless")) .Values.datastore.headless }}
16+
{{- include "etcd.endpointsYAML" . | nindent 4 }}
17+
{{- else }}
18+
{{- include "client.endpointsYAML" . | nindent 4 }}
19+
{{- end }}
1620
tlsConfig:
1721
certificateAuthority:
1822
certificate:

charts/kamaji-etcd/templates/etcd_service.yaml renamed to charts/kamaji-etcd/templates/etcd_headless_service.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ spec:
1212
name: client
1313
- port: {{ .Values.peerApiPort }}
1414
name: peer
15-
- port: {{ .Values.metricsPort }}
16-
name: metrics
1715
selector:
1816
{{- include "etcd.selectorLabels" . | nindent 4 }}

charts/kamaji-etcd/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ datastore:
128128
enabled: false
129129
# -- Name of Kamaji datastore, set to fully qualified etcd name when null or not provided
130130
name: ""
131+
# -- Expose the headless service endpoints in the datastore. Set to false to expose with regular service.
132+
headless: true # https://github.com/clastix/kamaji/issues/856
131133
# -- Assign additional Annotations to the datastore
132134
annotations: {}
133135
# helm.sh/resource-policy: keep

0 commit comments

Comments
 (0)