Skip to content

Commit a7d80a4

Browse files
authored
feat: switch between client and headless service (#109)
* feat: switch between client and headless service
1 parent 155bae2 commit a7d80a4

8 files changed

Lines changed: 39 additions & 8 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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
{{- include "etcd.labels" . | nindent 4 }}
6+
prometheus.io/metrics: "true"
7+
name: {{ include "client.serviceName" . }}
8+
namespace: {{ .Release.Namespace }}
9+
spec:
10+
type: ClusterIP
11+
ports:
12+
- port: {{ .Values.clientPort }}
13+
name: client
14+
- port: {{ .Values.metricsPort }}
15+
name: metrics
16+
selector:
17+
{{- 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/templates/etcd_service_monitor.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ spec:
3838
{{- if .Values.serviceMonitor.matchLabels }}
3939
{{- toYaml .Values.serviceMonitor.matchLabels | nindent 6 }}
4040
{{- else }}
41-
{{- include "etcd.labels" . | nindent 6 }}
41+
prometheus.io/metrics: "true"
42+
{{- include "etcd.selectorLabels" . | nindent 6 }}
4243
{{- end }}
4344
namespaceSelector:
4445
matchNames:

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)