From cf2dd6a7737db33d4200b2f0e4393ec563cf5c55 Mon Sep 17 00:00:00 2001 From: Avinash Upadhyaya Date: Fri, 20 Dec 2024 14:28:37 +0530 Subject: [PATCH 1/4] service per pod in statefulset deployment --- .../warpstream-agent/templates/service.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/charts/warpstream-agent/templates/service.yaml b/charts/warpstream-agent/templates/service.yaml index 8ea57af..c4ffda6 100644 --- a/charts/warpstream-agent/templates/service.yaml +++ b/charts/warpstream-agent/templates/service.yaml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: Service metadata: @@ -32,3 +33,47 @@ spec: {{- end }} selector: {{- include "warpstream-agent.selectorLabels" . | nindent 4 }} +... +{{- if eq (include "warpstream-agent.deploymentKind" .) "StatefulSet" }} +{{ $replicas := (.Values.replicas | int) }} +{{- range $i, $e := until $replicas }} +{{- with $ }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "warpstream-agent.fullname" . }}-{{ $i }} + labels: + {{- include "warpstream-agent.labels" . | nindent 4 }} + {{- with .Values.service.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + {{- if or (.Values.config.playground) (not (hasPrefix "vci_sr_" .Values.config.virtualClusterID)) }} + - port: {{ .Values.service.port }} + targetPort: kafka + protocol: TCP + name: kafka + {{- end }} + - port: {{ .Values.service.httpPort }} + targetPort: http + protocol: TCP + name: http + {{- if or (.Values.config.playground) (hasPrefix "vci_sr_" .Values.config.virtualClusterID) }} + - port: {{ .Values.service.schemaRegistryPort | default 9094 }} + targetPort: schema-registry + protocol: TCP + name: schema-registry + {{- end }} + selector: + statefulset.kubernetes.io/pod-name: {{ include "warpstream-agent.fullname" . }}-{{ $i }} +... +{{- end }} +{{- end }} +{{- end }} From 7389dc93e0ee9d949b38ad3c385a41e5304abdd1 Mon Sep 17 00:00:00 2001 From: Avinash Upadhyaya Date: Fri, 20 Dec 2024 22:45:07 +0530 Subject: [PATCH 2/4] add flag for service per pod --- charts/warpstream-agent/templates/service.yaml | 2 +- charts/warpstream-agent/values.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/charts/warpstream-agent/templates/service.yaml b/charts/warpstream-agent/templates/service.yaml index c4ffda6..f2643d3 100644 --- a/charts/warpstream-agent/templates/service.yaml +++ b/charts/warpstream-agent/templates/service.yaml @@ -34,7 +34,7 @@ spec: selector: {{- include "warpstream-agent.selectorLabels" . | nindent 4 }} ... -{{- if eq (include "warpstream-agent.deploymentKind" .) "StatefulSet" }} +{{- if and (eq (include "warpstream-agent.deploymentKind" .) "StatefulSet") (.Values.service.perPod.enabled) }} {{ $replicas := (.Values.replicas | int) }} {{- range $i, $e := until $replicas }} {{- with $ }} diff --git a/charts/warpstream-agent/values.yaml b/charts/warpstream-agent/values.yaml index ca3d1b1..5400299 100644 --- a/charts/warpstream-agent/values.yaml +++ b/charts/warpstream-agent/values.yaml @@ -89,6 +89,8 @@ service: port: 9092 httpPort: 8080 schemaRegistryPort: 9094 + perPod: + enabled: false labels: {} # A service that only contains the Kafka TCP port From eaa2a52e5c3b5fa7eb073beeffe46704aaef7e88 Mon Sep 17 00:00:00 2001 From: Ryan Belgrave Date: Mon, 23 Dec 2024 15:05:25 -0600 Subject: [PATCH 3/4] bump chart + comments --- charts/warpstream-agent/CHANGELOG.md | 6 +++++- charts/warpstream-agent/Chart.yaml | 2 +- charts/warpstream-agent/values.yaml | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/charts/warpstream-agent/CHANGELOG.md b/charts/warpstream-agent/CHANGELOG.md index 15cefa6..cb44657 100644 --- a/charts/warpstream-agent/CHANGELOG.md +++ b/charts/warpstream-agent/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.13.69] - 2024-12-XX +## [0.13.70] - 2024-12-23 + +- Add the ability to create services per pod to expose each pod outside of the cluster + +## [0.13.69] - 2024-12-19 - Make certificates first class variables so it is easier to configure without having to use volumes and env variables diff --git a/charts/warpstream-agent/Chart.yaml b/charts/warpstream-agent/Chart.yaml index 6f19c4c..554137b 100644 --- a/charts/warpstream-agent/Chart.yaml +++ b/charts/warpstream-agent/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: warpstream-agent description: WarpStream Agent for Kubernetes. type: application -version: 0.13.69 +version: 0.13.70 appVersion: v609 icon: https://avatars.githubusercontent.com/u/132156278 home: https://docs.warpstream.com/warpstream/ diff --git a/charts/warpstream-agent/values.yaml b/charts/warpstream-agent/values.yaml index 5400299..343e2c3 100644 --- a/charts/warpstream-agent/values.yaml +++ b/charts/warpstream-agent/values.yaml @@ -89,9 +89,13 @@ service: port: 9092 httpPort: 8080 schemaRegistryPort: 9094 + labels: {} + + # Create services per pod, this can be used in combination with deploymentKind=StatefulSet and statefulSetConfig.clusterDomain + # to expose each pod outside of the cluster when using Kong or Isto ingresses. + # See https://github.com/warpstreamlabs/charts/pull/156 for details perPod: enabled: false - labels: {} # A service that only contains the Kafka TCP port # Typically used to help with exposing only Kafka via a Load Balancer From 88af0b8ba4aa270f421af16682f53325f9216914 Mon Sep 17 00:00:00 2001 From: Ryan Belgrave Date: Mon, 23 Dec 2024 15:13:35 -0600 Subject: [PATCH 4/4] need to check for perPod first --- charts/warpstream-agent/templates/service.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/warpstream-agent/templates/service.yaml b/charts/warpstream-agent/templates/service.yaml index f2643d3..564a7fe 100644 --- a/charts/warpstream-agent/templates/service.yaml +++ b/charts/warpstream-agent/templates/service.yaml @@ -34,6 +34,7 @@ spec: selector: {{- include "warpstream-agent.selectorLabels" . | nindent 4 }} ... +{{- if .Values.service.perPod }} {{- if and (eq (include "warpstream-agent.deploymentKind" .) "StatefulSet") (.Values.service.perPod.enabled) }} {{ $replicas := (.Values.replicas | int) }} {{- range $i, $e := until $replicas }} @@ -77,3 +78,4 @@ spec: {{- end }} {{- end }} {{- end }} +{{- end }}