diff --git a/api/gateway.html b/api/gateway.html index bee9afc0c7..f5ad15edec 100644 --- a/api/gateway.html +++ b/api/gateway.html @@ -627,7 +627,25 @@
The list of ports that are exposed by this service.
+The list of ports that are exposed by this ClusterIP service.
+clusterIP
+
+string
+
+clusterIP is the IP address of the service and is usually assigned +randomly by the master. If an address is specified manually and is not in +use by others, it will be allocated to the service; otherwise, creation +of the service will fail. This field can not be changed through updates. +Valid values are “None”, empty string (“”), or a valid IP address. “None” +can be specified for headless services when proxying is not required. +More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
affinity
+
+
+Kubernetes core/v1.Affinity
+
+
+If specified, the pod’s scheduling constraints
+tolerations
+
+
+[]Kubernetes core/v1.Toleration
+
+
+If specified, the pod’s tolerations.
+spec
diff --git a/api/gateway.md b/api/gateway.md
index d13d4e2360..ef025a6c5b 100644
--- a/api/gateway.md
+++ b/api/gateway.md
@@ -1242,7 +1242,36 @@ Description
-The list of ports that are exposed by this service. +The list of ports that are exposed by this ClusterIP service. + +
+ +clusterIP
string
+
++ +clusterIP is the IP address of the service and is usually assigned +randomly by the master. If an address is specified manually and is not +in use by others, it will be allocated to the service; otherwise, +creation of the service will fail. This field can not be changed through +updates. Valid values are “None”, empty string (“”), or a valid IP +address. “None” can be specified for headless services when proxying is +not required. More info: +https://kubernetes.io/docs/concepts/services-networking/service/\#virtual-ips-and-service-proxies
@@ -1524,6 +1553,54 @@ values of each field.affinity
+
+Kubernetes core/v1.Affinity
+
++ +If specified, the pod’s scheduling constraints + +
+ +tolerations
+
+\[\]Kubernetes core/v1.Toleration
+
++ +If specified, the pod’s tolerations. + +
+ +spec
Kubernetes core/v1.PodSpec
diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json
index 0e74a48a07..9223d0ccd5 100644
--- a/api/openapi-spec/swagger.json
+++ b/api/openapi-spec/swagger.json
@@ -899,8 +899,12 @@
"description": "Service holds the service information gateway exposes",
"type": "object",
"properties": {
+ "clusterIP": {
+ "description": "clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are \"None\", empty string (\"\"), or a valid IP address. \"None\" can be specified for headless services when proxying is not required. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
+ "type": "string"
+ },
"ports": {
- "description": "The list of ports that are exposed by this service.",
+ "description": "The list of ports that are exposed by this ClusterIP service.",
"type": "array",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.ServicePort"
@@ -944,6 +948,10 @@
"description": "Template holds the information of a Gateway deployment template",
"type": "object",
"properties": {
+ "affinity": {
+ "description": "If specified, the pod's scheduling constraints",
+ "$ref": "#/definitions/io.k8s.api.core.v1.Affinity"
+ },
"container": {
"description": "Container is the main container image to run in the gateway pod",
"$ref": "#/definitions/io.k8s.api.core.v1.Container"
@@ -960,6 +968,13 @@
"description": "Spec holds the gateway deployment spec. DEPRECATED: Use Container instead.",
"$ref": "#/definitions/io.k8s.api.core.v1.PodSpec"
},
+ "tolerations": {
+ "description": "If specified, the pod's tolerations.",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/io.k8s.api.core.v1.Toleration"
+ }
+ },
"volumes": {
"description": "Volumes is a list of volumes that can be mounted by containers in a workflow.",
"type": "array",
diff --git a/controllers/gateway/resource.go b/controllers/gateway/resource.go
index 60fa9c5f78..448070af3f 100644
--- a/controllers/gateway/resource.go
+++ b/controllers/gateway/resource.go
@@ -54,9 +54,10 @@ func (ctx *gatewayContext) buildServiceResource() (*corev1.Service, error) {
Name: fmt.Sprintf("%s-gateway", ctx.gateway.Name),
},
Spec: corev1.ServiceSpec{
- Ports: ctx.gateway.Spec.Service.Ports,
- Type: corev1.ServiceTypeClusterIP,
- Selector: labels,
+ Ports: ctx.gateway.Spec.Service.Ports,
+ Type: corev1.ServiceTypeClusterIP,
+ ClusterIP: ctx.gateway.Spec.Service.ClusterIP,
+ Selector: labels,
},
}
if err := controllerscommon.SetObjectMeta(ctx.gateway, svc, v1alpha1.SchemaGroupVersionKind); err != nil {
@@ -144,6 +145,8 @@ func (ctx *gatewayContext) makeDeploymentSpec() (*appv1.DeploymentSpec, error) {
},
eventContainer,
},
+ Affinity: ctx.gateway.Spec.Template.Affinity,
+ Tolerations: ctx.gateway.Spec.Template.Tolerations,
Volumes: ctx.gateway.Spec.Template.Volumes,
SecurityContext: ctx.gateway.Spec.Template.SecurityContext,
},
diff --git a/pkg/apis/gateway/v1alpha1/openapi_generated.go b/pkg/apis/gateway/v1alpha1/openapi_generated.go
index f9ac7ea95f..131d027f88 100644
--- a/pkg/apis/gateway/v1alpha1/openapi_generated.go
+++ b/pkg/apis/gateway/v1alpha1/openapi_generated.go
@@ -430,7 +430,7 @@ func schema_pkg_apis_gateway_v1alpha1_Service(ref common.ReferenceCallback) comm
},
},
SchemaProps: spec.SchemaProps{
- Description: "The list of ports that are exposed by this service.",
+ Description: "The list of ports that are exposed by this ClusterIP service.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
@@ -441,6 +441,13 @@ func schema_pkg_apis_gateway_v1alpha1_Service(ref common.ReferenceCallback) comm
},
},
},
+ "clusterIP": {
+ SchemaProps: spec.SchemaProps{
+ Description: "clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are \"None\", empty string (\"\"), or a valid IP address. \"None\" can be specified for headless services when proxying is not required. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec holds the gateway service spec. DEPRECATED: Use Ports to declare the ports to be exposed.",
@@ -551,6 +558,25 @@ func schema_pkg_apis_gateway_v1alpha1_Template(ref common.ReferenceCallback) com
Ref: ref("k8s.io/api/core/v1.PodSecurityContext"),
},
},
+ "affinity": {
+ SchemaProps: spec.SchemaProps{
+ Description: "If specified, the pod's scheduling constraints",
+ Ref: ref("k8s.io/api/core/v1.Affinity"),
+ },
+ },
+ "tolerations": {
+ SchemaProps: spec.SchemaProps{
+ Description: "If specified, the pod's tolerations.",
+ Type: []string{"array"},
+ Items: &spec.SchemaOrArray{
+ Schema: &spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Ref: ref("k8s.io/api/core/v1.Toleration"),
+ },
+ },
+ },
+ },
+ },
"spec": {
SchemaProps: spec.SchemaProps{
Description: "Spec holds the gateway deployment spec. DEPRECATED: Use Container instead.",
@@ -561,6 +587,6 @@ func schema_pkg_apis_gateway_v1alpha1_Template(ref common.ReferenceCallback) com
},
},
Dependencies: []string{
- "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.PodSpec", "k8s.io/api/core/v1.Volume"},
+ "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.PodSpec", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.Volume"},
}
}
diff --git a/pkg/apis/gateway/v1alpha1/types.go b/pkg/apis/gateway/v1alpha1/types.go
index 3124b886a7..84c9d9de87 100644
--- a/pkg/apis/gateway/v1alpha1/types.go
+++ b/pkg/apis/gateway/v1alpha1/types.go
@@ -94,23 +94,38 @@ type Template struct {
// Optional: Defaults to empty. See type description for default values of each field.
// +optional
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty" protobuf:"bytes,4,opt,name=securityContext"`
+ // If specified, the pod's scheduling constraints
+ // +optional
+ Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,5,opt,name=affinity"`
+ // If specified, the pod's tolerations.
+ // +optional
+ Tolerations []corev1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,6,opt,name=tolerations"`
// Spec holds the gateway deployment spec.
// DEPRECATED: Use Container instead.
- Spec *corev1.PodSpec `json:"spec,omitempty" protobuf:"bytes,5,opt,name=spec"`
+ Spec *corev1.PodSpec `json:"spec,omitempty" protobuf:"bytes,7,opt,name=spec"`
}
// Service holds the service information gateway exposes
type Service struct {
- // The list of ports that are exposed by this service.
+ // The list of ports that are exposed by this ClusterIP service.
// +patchMergeKey=port
// +patchStrategy=merge
// +listType=map
// +listMapKey=port
// +listMapKey=protocol
Ports []corev1.ServicePort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"port" protobuf:"bytes,1,rep,name=ports"`
+ // clusterIP is the IP address of the service and is usually assigned
+ // randomly by the master. If an address is specified manually and is not in
+ // use by others, it will be allocated to the service; otherwise, creation
+ // of the service will fail. This field can not be changed through updates.
+ // Valid values are "None", empty string (""), or a valid IP address. "None"
+ // can be specified for headless services when proxying is not required.
+ // More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
+ // +optional
+ ClusterIP string `json:"clusterIP,omitempty" protobuf:"bytes,2,opt,name=clusterIP"`
// Spec holds the gateway service spec.
// DEPRECATED: Use Ports to declare the ports to be exposed.
- Spec *corev1.ServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
+ Spec *corev1.ServiceSpec `json:"spec,omitempty" protobuf:"bytes,3,opt,name=spec"`
}
type Subscribers struct {
diff --git a/pkg/apis/gateway/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/gateway/v1alpha1/zz_generated.deepcopy.go
index 7c7d0c6dbe..927849bfd8 100644
--- a/pkg/apis/gateway/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/gateway/v1alpha1/zz_generated.deepcopy.go
@@ -296,6 +296,18 @@ func (in *Template) DeepCopyInto(out *Template) {
*out = new(corev1.PodSecurityContext)
(*in).DeepCopyInto(*out)
}
+ if in.Affinity != nil {
+ in, out := &in.Affinity, &out.Affinity
+ *out = new(corev1.Affinity)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.Tolerations != nil {
+ in, out := &in.Tolerations, &out.Tolerations
+ *out = make([]corev1.Toleration, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
if in.Spec != nil {
in, out := &in.Spec, &out.Spec
*out = new(corev1.PodSpec)