From c84ebf1fa1ee3e0e7bbc7672c3fe08a051ffb26c Mon Sep 17 00:00:00 2001 From: Arko Dasgupta Date: Mon, 3 Jun 2024 16:03:32 -0700 Subject: [PATCH] api: support user provided names for generated k8s resources * Users prefer setting their own custom names for generated k8s resources for the Envoy Proxy fleet instead of the autogenerated resources * https://envoyproxy.slack.com/archives/C03E6NHLESV/p1717068088779319 * https://github.com/knative-extensions/net-gateway-api/pull/738 * https://github.com/envoyproxy/gateway/issues/2141 Signed-off-by: Arko Dasgupta --- api/v1alpha1/shared_types.go | 18 ++++++++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 15 +++++++++++++++ .../gateway.envoyproxy.io_envoyproxies.yaml | 15 +++++++++++++++ site/content/en/latest/api/extension_types.md | 3 +++ site/content/zh/latest/api/extension_types.md | 3 +++ 5 files changed, 54 insertions(+) diff --git a/api/v1alpha1/shared_types.go b/api/v1alpha1/shared_types.go index 4511bd3e8fd..81a83c49913 100644 --- a/api/v1alpha1/shared_types.go +++ b/api/v1alpha1/shared_types.go @@ -90,6 +90,11 @@ type KubernetesDeploymentSpec struct { // +optional InitContainers []corev1.Container `json:"initContainers,omitempty"` + // Name of the deployment. + // When unset, this defaults to an autogenerated name. + // + // +optional + Name *string `json:"name,omitempty"` // TODO: Expose config as use cases are better understood, e.g. labels. } @@ -113,6 +118,12 @@ type KubernetesDaemonSetSpec struct { // // +optional Container *KubernetesContainerSpec `json:"container,omitempty"` + + // Name of the daemonSet. + // When unset, this defaults to an autogenerated name. + // + // +optional + Name *string `json:"name,omitempty"` } // KubernetesPodSpec defines the desired state of the Kubernetes pod resource. @@ -301,6 +312,13 @@ type KubernetesServiceSpec struct { // // +optional Patch *KubernetesPatchSpec `json:"patch,omitempty"` + + // Name of the service. + // When unset, this defaults to an autogenerated name. + // + // +optional + Name *string `json:"name,omitempty"` + // TODO: Expose config as use cases are better understood, e.g. labels. } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 77a4b2c8b1f..144d9436695 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -2884,6 +2884,11 @@ func (in *KubernetesDaemonSetSpec) DeepCopyInto(out *KubernetesDaemonSetSpec) { *out = new(KubernetesContainerSpec) (*in).DeepCopyInto(*out) } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesDaemonSetSpec. @@ -2946,6 +2951,11 @@ func (in *KubernetesDeploymentSpec) DeepCopyInto(out *KubernetesDeploymentSpec) (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesDeploymentSpec. @@ -3133,6 +3143,11 @@ func (in *KubernetesServiceSpec) DeepCopyInto(out *KubernetesServiceSpec) { *out = new(KubernetesPatchSpec) (*in).DeepCopyInto(*out) } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesServiceSpec. diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml index c8d07451964..070602cfe50 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml @@ -837,6 +837,11 @@ spec: type: object type: array type: object + name: + description: |- + Name of the daemonSet. + When unset, this defaults to an autogenerated name. + type: string patch: description: Patch defines how to perform the patch operation to daemonset @@ -6095,6 +6100,11 @@ spec: - name type: object type: array + name: + description: |- + Name of the deployment. + When unset, this defaults to an autogenerated name. + type: string patch: description: Patch defines how to perform the patch operation to deployment @@ -10103,6 +10113,11 @@ spec: items: type: string type: array + name: + description: |- + Name of the service. + When unset, this defaults to an autogenerated name. + type: string patch: description: Patch defines how to perform the patch operation to the service diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index f3683ceee9c..4b93006d7ff 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -2116,6 +2116,7 @@ _Appears in:_ | `strategy` | _[DaemonSetUpdateStrategy](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#daemonsetupdatestrategy-v1-apps)_ | false | The daemonset strategy to use to replace existing pods with new ones. | | `pod` | _[KubernetesPodSpec](#kubernetespodspec)_ | false | Pod defines the desired specification of pod. | | `container` | _[KubernetesContainerSpec](#kubernetescontainerspec)_ | false | Container defines the desired specification of main container. | +| `name` | _string_ | false | Name of the daemonSet.
When unset, this defaults to an autogenerated name. | #### KubernetesDeployMode @@ -2148,6 +2149,7 @@ _Appears in:_ | `pod` | _[KubernetesPodSpec](#kubernetespodspec)_ | false | Pod defines the desired specification of pod. | | `container` | _[KubernetesContainerSpec](#kubernetescontainerspec)_ | false | Container defines the desired specification of main container. | | `initContainers` | _[Container](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#container-v1-core) array_ | false | List of initialization containers belonging to the pod.
More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ | +| `name` | _string_ | false | Name of the deployment.
When unset, this defaults to an autogenerated name. | #### KubernetesHorizontalPodAutoscalerSpec @@ -2229,6 +2231,7 @@ _Appears in:_ | `loadBalancerIP` | _string_ | false | LoadBalancerIP defines the IP Address of the underlying load balancer service. This field
may be ignored if the load balancer provider does not support this feature.
This field has been deprecated in Kubernetes, but it is still used for setting the IP Address in some cloud
providers such as GCP. | | `externalTrafficPolicy` | _[ServiceExternalTrafficPolicy](#serviceexternaltrafficpolicy)_ | false | ExternalTrafficPolicy determines the externalTrafficPolicy for the Envoy Service. Valid options
are Local and Cluster. Default is "Local". "Local" means traffic will only go to pods on the node
receiving the traffic. "Cluster" means connections are loadbalanced to all pods in the cluster. | | `patch` | _[KubernetesPatchSpec](#kubernetespatchspec)_ | false | Patch defines how to perform the patch operation to the service | +| `name` | _string_ | false | Name of the service.
When unset, this defaults to an autogenerated name. | #### KubernetesWatchMode diff --git a/site/content/zh/latest/api/extension_types.md b/site/content/zh/latest/api/extension_types.md index f3683ceee9c..4b93006d7ff 100644 --- a/site/content/zh/latest/api/extension_types.md +++ b/site/content/zh/latest/api/extension_types.md @@ -2116,6 +2116,7 @@ _Appears in:_ | `strategy` | _[DaemonSetUpdateStrategy](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#daemonsetupdatestrategy-v1-apps)_ | false | The daemonset strategy to use to replace existing pods with new ones. | | `pod` | _[KubernetesPodSpec](#kubernetespodspec)_ | false | Pod defines the desired specification of pod. | | `container` | _[KubernetesContainerSpec](#kubernetescontainerspec)_ | false | Container defines the desired specification of main container. | +| `name` | _string_ | false | Name of the daemonSet.
When unset, this defaults to an autogenerated name. | #### KubernetesDeployMode @@ -2148,6 +2149,7 @@ _Appears in:_ | `pod` | _[KubernetesPodSpec](#kubernetespodspec)_ | false | Pod defines the desired specification of pod. | | `container` | _[KubernetesContainerSpec](#kubernetescontainerspec)_ | false | Container defines the desired specification of main container. | | `initContainers` | _[Container](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#container-v1-core) array_ | false | List of initialization containers belonging to the pod.
More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ | +| `name` | _string_ | false | Name of the deployment.
When unset, this defaults to an autogenerated name. | #### KubernetesHorizontalPodAutoscalerSpec @@ -2229,6 +2231,7 @@ _Appears in:_ | `loadBalancerIP` | _string_ | false | LoadBalancerIP defines the IP Address of the underlying load balancer service. This field
may be ignored if the load balancer provider does not support this feature.
This field has been deprecated in Kubernetes, but it is still used for setting the IP Address in some cloud
providers such as GCP. | | `externalTrafficPolicy` | _[ServiceExternalTrafficPolicy](#serviceexternaltrafficpolicy)_ | false | ExternalTrafficPolicy determines the externalTrafficPolicy for the Envoy Service. Valid options
are Local and Cluster. Default is "Local". "Local" means traffic will only go to pods on the node
receiving the traffic. "Cluster" means connections are loadbalanced to all pods in the cluster. | | `patch` | _[KubernetesPatchSpec](#kubernetespatchspec)_ | false | Patch defines how to perform the patch operation to the service | +| `name` | _string_ | false | Name of the service.
When unset, this defaults to an autogenerated name. | #### KubernetesWatchMode