From 42abc2a73b939d1565d747b5f1247aa368da2275 Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Tue, 18 Feb 2025 11:05:41 +0100 Subject: [PATCH] Mark StatefulSet's .spec.serviceName optional The API reference doc (https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/stateful-set-v1/#StatefulSetSpec) mentions .spec.serviceName field is required, because it doesn't have optional tag, nor omitempty. In practice this field is optional, and can be empty. This change explicitly marks the field optional. Signed-off-by: Maciej Szulik --- pkg/apis/apps/types.go | 1 + staging/src/k8s.io/api/apps/v1/types.go | 1 + staging/src/k8s.io/api/apps/v1beta1/types.go | 1 + staging/src/k8s.io/api/apps/v1beta2/types.go | 1 + 4 files changed, 4 insertions(+) diff --git a/pkg/apis/apps/types.go b/pkg/apis/apps/types.go index 8d228de8e4b..a3b7786d462 100644 --- a/pkg/apis/apps/types.go +++ b/pkg/apis/apps/types.go @@ -198,6 +198,7 @@ type StatefulSetSpec struct { // the network identity of the set. Pods get DNS/hostnames that follow the // pattern: pod-specific-string.serviceName.default.svc.cluster.local // where "pod-specific-string" is managed by the StatefulSet controller. + // +optional ServiceName string // PodManagementPolicy controls how pods are created during initial scale up, diff --git a/staging/src/k8s.io/api/apps/v1/types.go b/staging/src/k8s.io/api/apps/v1/types.go index 0f4102907ca..7368e8ebb47 100644 --- a/staging/src/k8s.io/api/apps/v1/types.go +++ b/staging/src/k8s.io/api/apps/v1/types.go @@ -220,6 +220,7 @@ type StatefulSetSpec struct { // the network identity of the set. Pods get DNS/hostnames that follow the // pattern: pod-specific-string.serviceName.default.svc.cluster.local // where "pod-specific-string" is managed by the StatefulSet controller. + // +optional ServiceName string `json:"serviceName" protobuf:"bytes,5,opt,name=serviceName"` // podManagementPolicy controls how pods are created during initial scale up, diff --git a/staging/src/k8s.io/api/apps/v1beta1/types.go b/staging/src/k8s.io/api/apps/v1beta1/types.go index 85710264fe3..b97a050bfde 100644 --- a/staging/src/k8s.io/api/apps/v1beta1/types.go +++ b/staging/src/k8s.io/api/apps/v1beta1/types.go @@ -259,6 +259,7 @@ type StatefulSetSpec struct { // the network identity of the set. Pods get DNS/hostnames that follow the // pattern: pod-specific-string.serviceName.default.svc.cluster.local // where "pod-specific-string" is managed by the StatefulSet controller. + // +optional ServiceName string `json:"serviceName" protobuf:"bytes,5,opt,name=serviceName"` // podManagementPolicy controls how pods are created during initial scale up, diff --git a/staging/src/k8s.io/api/apps/v1beta2/types.go b/staging/src/k8s.io/api/apps/v1beta2/types.go index cc7d6582f50..2d88bfba534 100644 --- a/staging/src/k8s.io/api/apps/v1beta2/types.go +++ b/staging/src/k8s.io/api/apps/v1beta2/types.go @@ -269,6 +269,7 @@ type StatefulSetSpec struct { // the network identity of the set. Pods get DNS/hostnames that follow the // pattern: pod-specific-string.serviceName.default.svc.cluster.local // where "pod-specific-string" is managed by the StatefulSet controller. + // +optional ServiceName string `json:"serviceName" protobuf:"bytes,5,opt,name=serviceName"` // podManagementPolicy controls how pods are created during initial scale up,