From 362ac31a8e7c8eca70149d00124e85d4c21e16df Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Sun, 11 Sep 2022 17:05:18 +0800 Subject: [PATCH 01/16] add field: updateStrategy/strategy for envoy & contour to crd/ContourDeployment Signed-off-by: Gang Liu --- .../v1alpha1/contourdeployment.go | 15 ++ .../v1alpha1/zz_generated.deepcopy.go | 16 ++ examples/contour/01-crds.yaml | 170 ++++++++++++++++++ examples/render/contour-deployment.yaml | 170 ++++++++++++++++++ .../render/contour-gateway-provisioner.yaml | 170 ++++++++++++++++++ examples/render/contour-gateway.yaml | 170 ++++++++++++++++++ examples/render/contour.yaml | 170 ++++++++++++++++++ internal/provisioner/controller/gateway.go | 15 ++ internal/provisioner/model/model.go | 36 ++++ .../objects/dataplane/dataplane.go | 17 +- .../objects/dataplane/dataplane_test.go | 29 +++ .../objects/deployment/deployment.go | 9 +- .../objects/deployment/deployment_test.go | 10 ++ .../docs/main/config/api-reference.html | 47 +++++ 14 files changed, 1022 insertions(+), 22 deletions(-) diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index 1e942ffbef5..4866be541cb 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -16,6 +16,7 @@ package v1alpha1 import ( "fmt" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -95,6 +96,10 @@ type ContourSettings struct { // // +optional LogLevel LogLevel `json:"logLevel,omitempty"` + + // Strategy describes the deployment strategy to use to replace existing pods with new ones. + // +optional + Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` } // EnvoySettings contains settings for the Envoy part of the installation, @@ -123,6 +128,16 @@ type EnvoySettings struct { // // +optional NodePlacement *NodePlacement `json:"nodePlacement,omitempty"` + + // An update strategy to replace existing Envoy DaemonSet pods with new pods. + // when envoy be running as a `Deployment`,it's must be nil + // +optional + UpdateStrategy *appsv1.DaemonSetUpdateStrategy `json:"updateStrategy,omitempty"` + + // Strategy describes the deployment strategy to use to replace existing Envoy pods with new ones. + // when envoy be running as a `DaemonSet`,it's must be nil + // +optional + Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` } // WorkloadType is the type of Kubernetes workload to use for a component. diff --git a/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go b/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go index 3dc0dc7536b..e756c7ed174 100644 --- a/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go +++ b/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go @@ -23,6 +23,7 @@ package v1alpha1 import ( "github.com/projectcontour/contour/apis/projectcontour/v1" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -332,6 +333,11 @@ func (in *ContourSettings) DeepCopyInto(out *ContourSettings) { *out = new(NodePlacement) (*in).DeepCopyInto(*out) } + if in.Strategy != nil { + in, out := &in.Strategy, &out.Strategy + *out = new(appsv1.DeploymentStrategy) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContourSettings. @@ -517,6 +523,16 @@ func (in *EnvoySettings) DeepCopyInto(out *EnvoySettings) { *out = new(NodePlacement) (*in).DeepCopyInto(*out) } + if in.UpdateStrategy != nil { + in, out := &in.UpdateStrategy, &out.UpdateStrategy + *out = new(appsv1.DaemonSetUpdateStrategy) + (*in).DeepCopyInto(*out) + } + if in.Strategy != nil { + in, out := &in.Strategy, &out.Strategy + *out = new(appsv1.DeploymentStrategy) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvoySettings. diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 7998dd0d479..c2f672c82e8 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -932,6 +932,57 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -1038,6 +1089,125 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing Envoy pods with new ones. when envoy be + running as a `DaemonSet`,it's must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object + updateStrategy: + description: An update strategy to replace existing Envoy DaemonSet + pods with new pods. when envoy be running as a `Deployment`,it's + must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + type = "RollingUpdate". --- TODO: Update this to follow + our convention for oneOf, whatever we decide it to be. Same + as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an existing + available DaemonSet pod that can have an updated DaemonSet + pod during during an update. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up + to a minimum of 1. Default value is 0. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their a new + pod created before the old pod is marked as deleted. + The update starts by launching new pods on 30% of nodes. + Once an updated pod is available (Ready for at least + minReadySeconds) the old DaemonSet pod on that node + is marked deleted. If the old pod becomes unavailable + for any reason (Ready transitions to false, is evicted, + or is drained) an updated pod is immediatedly created + on that node without considering surge limits. Allowing + surge implies the possibility that the resources consumed + by the daemonset on any given node can double if the + readiness check fails, and so resource intensive daemonsets + should take into account that they may cause evictions + during disruption. This is beta field and enabled/disabled + by DaemonSetUpdateSurge feature gate.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods that + can be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of total number + of DaemonSet pods at the start of the update (ex: 10%). + Absolute number is calculated from percentage by rounding + up. This cannot be 0 if MaxSurge is 0 Default value + is 1. Example: when this is set to 30%, at most 30% + of the total number of nodes that should be running + the daemon pod (i.e. status.desiredNumberScheduled) + can have their pods stopped for an update at any given + time. The update starts by stopping at most 30% of those + DaemonSet pods and then brings up new DaemonSet pods + in their place. Once the new pods are available, it + then proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet pods + are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index 47f573704a6..a88edf85ae6 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1141,6 +1141,57 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -1247,6 +1298,125 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing Envoy pods with new ones. when envoy be + running as a `DaemonSet`,it's must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object + updateStrategy: + description: An update strategy to replace existing Envoy DaemonSet + pods with new pods. when envoy be running as a `Deployment`,it's + must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + type = "RollingUpdate". --- TODO: Update this to follow + our convention for oneOf, whatever we decide it to be. Same + as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an existing + available DaemonSet pod that can have an updated DaemonSet + pod during during an update. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up + to a minimum of 1. Default value is 0. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their a new + pod created before the old pod is marked as deleted. + The update starts by launching new pods on 30% of nodes. + Once an updated pod is available (Ready for at least + minReadySeconds) the old DaemonSet pod on that node + is marked deleted. If the old pod becomes unavailable + for any reason (Ready transitions to false, is evicted, + or is drained) an updated pod is immediatedly created + on that node without considering surge limits. Allowing + surge implies the possibility that the resources consumed + by the daemonset on any given node can double if the + readiness check fails, and so resource intensive daemonsets + should take into account that they may cause evictions + during disruption. This is beta field and enabled/disabled + by DaemonSetUpdateSurge feature gate.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods that + can be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of total number + of DaemonSet pods at the start of the update (ex: 10%). + Absolute number is calculated from percentage by rounding + up. This cannot be 0 if MaxSurge is 0 Default value + is 1. Example: when this is set to 30%, at most 30% + of the total number of nodes that should be running + the daemon pod (i.e. status.desiredNumberScheduled) + can have their pods stopped for an update at any given + time. The update starts by stopping at most 30% of those + DaemonSet pods and then brings up new DaemonSet pods + in their place. Once the new pods are available, it + then proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet pods + are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index 88e0b272905..34dc7a25a88 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -945,6 +945,57 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -1051,6 +1102,125 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing Envoy pods with new ones. when envoy be + running as a `DaemonSet`,it's must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object + updateStrategy: + description: An update strategy to replace existing Envoy DaemonSet + pods with new pods. when envoy be running as a `Deployment`,it's + must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + type = "RollingUpdate". --- TODO: Update this to follow + our convention for oneOf, whatever we decide it to be. Same + as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an existing + available DaemonSet pod that can have an updated DaemonSet + pod during during an update. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up + to a minimum of 1. Default value is 0. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their a new + pod created before the old pod is marked as deleted. + The update starts by launching new pods on 30% of nodes. + Once an updated pod is available (Ready for at least + minReadySeconds) the old DaemonSet pod on that node + is marked deleted. If the old pod becomes unavailable + for any reason (Ready transitions to false, is evicted, + or is drained) an updated pod is immediatedly created + on that node without considering surge limits. Allowing + surge implies the possibility that the resources consumed + by the daemonset on any given node can double if the + readiness check fails, and so resource intensive daemonsets + should take into account that they may cause evictions + during disruption. This is beta field and enabled/disabled + by DaemonSetUpdateSurge feature gate.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods that + can be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of total number + of DaemonSet pods at the start of the update (ex: 10%). + Absolute number is calculated from percentage by rounding + up. This cannot be 0 if MaxSurge is 0 Default value + is 1. Example: when this is set to 30%, at most 30% + of the total number of nodes that should be running + the daemon pod (i.e. status.desiredNumberScheduled) + can have their pods stopped for an update at any given + time. The update starts by stopping at most 30% of those + DaemonSet pods and then brings up new DaemonSet pods + in their place. Once the new pods are available, it + then proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet pods + are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index ef5cffa5b06..541f49608cd 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -1146,6 +1146,57 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -1252,6 +1303,125 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing Envoy pods with new ones. when envoy be + running as a `DaemonSet`,it's must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object + updateStrategy: + description: An update strategy to replace existing Envoy DaemonSet + pods with new pods. when envoy be running as a `Deployment`,it's + must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + type = "RollingUpdate". --- TODO: Update this to follow + our convention for oneOf, whatever we decide it to be. Same + as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an existing + available DaemonSet pod that can have an updated DaemonSet + pod during during an update. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up + to a minimum of 1. Default value is 0. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their a new + pod created before the old pod is marked as deleted. + The update starts by launching new pods on 30% of nodes. + Once an updated pod is available (Ready for at least + minReadySeconds) the old DaemonSet pod on that node + is marked deleted. If the old pod becomes unavailable + for any reason (Ready transitions to false, is evicted, + or is drained) an updated pod is immediatedly created + on that node without considering surge limits. Allowing + surge implies the possibility that the resources consumed + by the daemonset on any given node can double if the + readiness check fails, and so resource intensive daemonsets + should take into account that they may cause evictions + during disruption. This is beta field and enabled/disabled + by DaemonSetUpdateSurge feature gate.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods that + can be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of total number + of DaemonSet pods at the start of the update (ex: 10%). + Absolute number is calculated from percentage by rounding + up. This cannot be 0 if MaxSurge is 0 Default value + is 1. Example: when this is set to 30%, at most 30% + of the total number of nodes that should be running + the daemon pod (i.e. status.desiredNumberScheduled) + can have their pods stopped for an update at any given + time. The update starts by stopping at most 30% of those + DaemonSet pods and then brings up new DaemonSet pods + in their place. Once the new pods are available, it + then proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet pods + are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 4389a0d8847..473edbcf90e 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1141,6 +1141,57 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -1247,6 +1298,125 @@ spec: format: int32 minimum: 0 type: integer + strategy: + description: Strategy describes the deployment strategy to use + to replace existing Envoy pods with new ones. when envoy be + running as a `DaemonSet`,it's must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + DeploymentStrategyType = RollingUpdate. --- TODO: Update + this to follow our convention for oneOf, whatever we decide + it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be scheduled + above the desired number of pods. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up. + Defaults to 25%. Example: when this is set to 30%, the + new ReplicaSet can be scaled up immediately when the + rolling update starts, such that the total number of + old and new pods do not exceed 130% of desired pods. + Once old pods have been killed, new ReplicaSet can be + scaled up further, ensuring that total number of pods + running at any time during the update is at most 130% + of desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can be unavailable + during the update. Value can be an absolute number (ex: + 5) or a percentage of desired pods (ex: 10%). Absolute + number is calculated from percentage by rounding down. + This can not be 0 if MaxSurge is 0. Defaults to 25%. + Example: when this is set to 30%, the old ReplicaSet + can be scaled down to 70% of desired pods immediately + when the rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that the + total number of pods available at all times during the + update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or "RollingUpdate". + Default is RollingUpdate. + type: string + type: object + updateStrategy: + description: An update strategy to replace existing Envoy DaemonSet + pods with new pods. when envoy be running as a `Deployment`,it's + must be nil + properties: + rollingUpdate: + description: 'Rolling update config params. Present only if + type = "RollingUpdate". --- TODO: Update this to follow + our convention for oneOf, whatever we decide it to be. Same + as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an existing + available DaemonSet pod that can have an updated DaemonSet + pod during during an update. Value can be an absolute + number (ex: 5) or a percentage of desired pods (ex: + 10%). This can not be 0 if MaxUnavailable is 0. Absolute + number is calculated from percentage by rounding up + to a minimum of 1. Default value is 0. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their a new + pod created before the old pod is marked as deleted. + The update starts by launching new pods on 30% of nodes. + Once an updated pod is available (Ready for at least + minReadySeconds) the old DaemonSet pod on that node + is marked deleted. If the old pod becomes unavailable + for any reason (Ready transitions to false, is evicted, + or is drained) an updated pod is immediatedly created + on that node without considering surge limits. Allowing + surge implies the possibility that the resources consumed + by the daemonset on any given node can double if the + readiness check fails, and so resource intensive daemonsets + should take into account that they may cause evictions + during disruption. This is beta field and enabled/disabled + by DaemonSetUpdateSurge feature gate.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods that + can be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of total number + of DaemonSet pods at the start of the update (ex: 10%). + Absolute number is calculated from percentage by rounding + up. This cannot be 0 if MaxSurge is 0 Default value + is 1. Example: when this is set to 30%, at most 30% + of the total number of nodes that should be running + the daemon pod (i.e. status.desiredNumberScheduled) + can have their pods stopped for an update at any given + time. The update starts by stopping at most 30% of those + DaemonSet pods and then brings up new DaemonSet pods + in their place. Once the new pods are available, it + then proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet pods + are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 568bfe2fe19..8631b7b1907 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -255,6 +255,10 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct contourModel.Spec.LogLevel = gatewayClassParams.Spec.Contour.LogLevel contourModel.Spec.KubernetesLogLevel = gatewayClassParams.Spec.Contour.KubernetesLogLevel + + if gatewayClassParams.Spec.Contour.Strategy != nil { + contourModel.Spec.ContourStrategy = *gatewayClassParams.Spec.Contour.Strategy + } } if gatewayClassParams.Spec.Envoy != nil { @@ -292,6 +296,17 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct Tolerations: nodePlacement.Tolerations, } } + + if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment && + gatewayClassParams.Spec.Envoy.Strategy != nil { + contourModel.Spec.EnvoyStrategy = *gatewayClassParams.Spec.Envoy.Strategy + } + + if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDaemonSet && + gatewayClassParams.Spec.Envoy.UpdateStrategy != nil { + contourModel.Spec.EnvoyUpdateStrategy = *gatewayClassParams.Spec.Envoy.UpdateStrategy + } + } } diff --git a/internal/provisioner/model/model.go b/internal/provisioner/model/model.go index 17d373febdc..74e88471313 100644 --- a/internal/provisioner/model/model.go +++ b/internal/provisioner/model/model.go @@ -15,8 +15,12 @@ package model import ( contourv1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" + opintstr "github.com/projectcontour/contour/internal/provisioner/intstr" + + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/pointer" ) @@ -53,6 +57,25 @@ func Default(namespace, name string) *Contour { }, }, }, + EnvoyUpdateStrategy: appsv1.DaemonSetUpdateStrategy{ + Type: appsv1.RollingUpdateDaemonSetStrategyType, + RollingUpdate: &appsv1.RollingUpdateDaemonSet{ + MaxUnavailable: opintstr.PointerTo(intstr.FromString("10%")), + }, + }, + EnvoyStrategy: appsv1.DeploymentStrategy{ + Type: appsv1.RollingUpdateDeploymentStrategyType, + RollingUpdate: &appsv1.RollingUpdateDeployment{ + MaxSurge: opintstr.PointerTo(intstr.FromString("10%")), + }, + }, + ContourStrategy: appsv1.DeploymentStrategy{ + Type: appsv1.RollingUpdateDeploymentStrategyType, + RollingUpdate: &appsv1.RollingUpdateDeployment{ + MaxSurge: opintstr.PointerTo(intstr.FromString("50%")), + MaxUnavailable: opintstr.PointerTo(intstr.FromString("25%")), + }, + }, }, } } @@ -166,6 +189,19 @@ type ContourSpec struct { // KubernetesLogLevel Enable Kubernetes client debug logging with log level. If unset, // defaults to 0. KubernetesLogLevel uint8 + + // An update strategy to replace existing Envoy DaemonSet pods with new pods. + // when envoy be running as a `Deployment`,it's must be nil + // +optional + EnvoyUpdateStrategy appsv1.DaemonSetUpdateStrategy + + // The deployment strategy to use to replace existing Envoy pods with new ones. + // when envoy be running as a `DaemonSet`,it's must be nil + EnvoyStrategy appsv1.DeploymentStrategy + + // The deployment strategy to use to replace existing Contour pods with new ones. + // when envoy be running as a `DaemonSet`,it's must be nil + ContourStrategy appsv1.DeploymentStrategy } // WorkloadType is the type of Kubernetes workload to use for a component. diff --git a/internal/provisioner/objects/dataplane/dataplane.go b/internal/provisioner/objects/dataplane/dataplane.go index b2ec525f7e7..f04b778c17f 100644 --- a/internal/provisioner/objects/dataplane/dataplane.go +++ b/internal/provisioner/objects/dataplane/dataplane.go @@ -19,7 +19,6 @@ import ( "path/filepath" "github.com/projectcontour/contour/internal/provisioner/equality" - opintstr "github.com/projectcontour/contour/internal/provisioner/intstr" "github.com/projectcontour/contour/internal/provisioner/labels" "github.com/projectcontour/contour/internal/provisioner/model" "github.com/projectcontour/contour/internal/provisioner/objects" @@ -325,13 +324,8 @@ func DesiredDaemonSet(contour *model.Contour, contourImage, envoyImage string) * Spec: appsv1.DaemonSetSpec{ RevisionHistoryLimit: pointer.Int32Ptr(int32(10)), // Ensure the deamonset adopts only its own pods. - Selector: EnvoyPodSelector(contour), - UpdateStrategy: appsv1.DaemonSetUpdateStrategy{ - Type: appsv1.RollingUpdateDaemonSetStrategyType, - RollingUpdate: &appsv1.RollingUpdateDaemonSet{ - MaxUnavailable: opintstr.PointerTo(intstr.FromString("10%")), - }, - }, + Selector: EnvoyPodSelector(contour), + UpdateStrategy: contour.Spec.EnvoyUpdateStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ // TODO [danehans]: Remove the prometheus annotations when Contour is updated to @@ -406,12 +400,7 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) RevisionHistoryLimit: pointer.Int32Ptr(int32(10)), // Ensure the deamonset adopts only its own pods. Selector: EnvoyPodSelector(contour), - Strategy: appsv1.DeploymentStrategy{ - Type: appsv1.RollingUpdateDeploymentStrategyType, - RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxSurge: opintstr.PointerTo(intstr.FromString("10%")), - }, - }, + Strategy: contour.Spec.EnvoyStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ // TODO [danehans]: Remove the prometheus annotations when Contour is updated to diff --git a/internal/provisioner/objects/dataplane/dataplane_test.go b/internal/provisioner/objects/dataplane/dataplane_test.go index 1a540672a1e..5576859037d 100644 --- a/internal/provisioner/objects/dataplane/dataplane_test.go +++ b/internal/provisioner/objects/dataplane/dataplane_test.go @@ -125,6 +125,24 @@ func checkDaemonSetHasNodeSelector(t *testing.T, ds *appsv1.DaemonSet, expected t.Errorf("deployment has unexpected node selector %q", expected) } +func checkDaemonSetHasUpdateStrategy(t *testing.T, ds *appsv1.DaemonSet, expected appsv1.DaemonSetUpdateStrategy) { + t.Helper() + + if apiequality.Semantic.DeepEqual(ds.Spec.UpdateStrategy, expected) { + return + } + t.Errorf("daemonset has unexpected update strategy %q", expected) +} + +func checkDeploymentHasStrategy(t *testing.T, ds *appsv1.Deployment, expected appsv1.DeploymentStrategy) { + t.Helper() + + if apiequality.Semantic.DeepEqual(ds.Spec.Strategy, expected) { + return + } + t.Errorf("deployment has unexpected strategy %q", expected) +} + func checkDaemonSetHasTolerations(t *testing.T, ds *appsv1.DaemonSet, expected []corev1.Toleration) { t.Helper() @@ -174,6 +192,17 @@ func TestDesiredDaemonSet(t *testing.T) { checkDaemonSetHasNodeSelector(t, ds, nil) checkDaemonSetHasTolerations(t, ds, nil) checkDaemonSecurityContext(t, ds) + checkDaemonSetHasUpdateStrategy(t, ds, cntr.Spec.EnvoyUpdateStrategy) +} + +func TestDesiredDeployment(t *testing.T) { + name := "deploy-test" + cntr := model.Default(fmt.Sprintf("%s-ns", name), name) + + testContourImage := "ghcr.io/projectcontour/contour:test" + testEnvoyImage := "docker.io/envoyproxy/envoy:test" + deploy := desiredDeployment(cntr, testContourImage, testEnvoyImage) + checkDeploymentHasStrategy(t, deploy, cntr.Spec.EnvoyStrategy) } func TestNodePlacementDaemonSet(t *testing.T) { diff --git a/internal/provisioner/objects/deployment/deployment.go b/internal/provisioner/objects/deployment/deployment.go index e621708e8f9..ff32e7e0034 100644 --- a/internal/provisioner/objects/deployment/deployment.go +++ b/internal/provisioner/objects/deployment/deployment.go @@ -20,7 +20,6 @@ import ( "github.com/projectcontour/contour/apis/projectcontour/v1alpha1" "github.com/projectcontour/contour/internal/provisioner/equality" - opintstr "github.com/projectcontour/contour/internal/provisioner/intstr" "github.com/projectcontour/contour/internal/provisioner/labels" "github.com/projectcontour/contour/internal/provisioner/model" "github.com/projectcontour/contour/internal/provisioner/objects" @@ -209,13 +208,7 @@ func DesiredDeployment(contour *model.Contour, image string) *appsv1.Deployment RevisionHistoryLimit: pointer.Int32(10), // Ensure the deployment adopts only its own pods. Selector: ContourDeploymentPodSelector(contour), - Strategy: appsv1.DeploymentStrategy{ - Type: appsv1.RollingUpdateDeploymentStrategyType, - RollingUpdate: &appsv1.RollingUpdateDeployment{ - MaxSurge: opintstr.PointerTo(intstr.FromString("50%")), - MaxUnavailable: opintstr.PointerTo(intstr.FromString("25%")), - }, - }, + Strategy: contour.Spec.ContourStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ // TODO [danehans]: Remove the prometheus annotations when Contour is updated to diff --git a/internal/provisioner/objects/deployment/deployment_test.go b/internal/provisioner/objects/deployment/deployment_test.go index 83bb03227c2..13ac1e29555 100644 --- a/internal/provisioner/objects/deployment/deployment_test.go +++ b/internal/provisioner/objects/deployment/deployment_test.go @@ -106,6 +106,15 @@ func checkDeploymentHasTolerations(t *testing.T, deploy *appsv1.Deployment, expe t.Errorf("deployment has unexpected tolerations %v", expected) } +func checkDeploymentHasStrategy(t *testing.T, ds *appsv1.Deployment, expected appsv1.DeploymentStrategy) { + t.Helper() + + if apiequality.Semantic.DeepEqual(ds.Spec.Strategy, expected) { + return + } + t.Errorf("deployment has unexpected strategy %q", expected) +} + func TestDesiredDeployment(t *testing.T) { name := "deploy-test" cntr := model.Default(fmt.Sprintf("%s-ns", name), name) @@ -159,6 +168,7 @@ func TestDesiredDeployment(t *testing.T) { checkDeploymentHasNodeSelector(t, deploy, nil) checkDeploymentHasTolerations(t, deploy, nil) + checkDeploymentHasStrategy(t, deploy, cntr.Spec.ContourStrategy) } func TestNodePlacementDeployment(t *testing.T) { diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index 6fc7c707427..b092f3f8b90 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -4890,6 +4890,21 @@

ContourSettings Allowed values are “info”, “debug”.

+ + +strategy +
+ + +Kubernetes apps/v1.DeploymentStrategy + + + + +(Optional) +

Strategy describes the deployment strategy to use to replace existing pods with new ones.

+ +

DebugConfig @@ -5471,6 +5486,38 @@

EnvoySettings

NodePlacement describes node scheduling configuration of Envoy pods.

+ + +updateStrategy +
+ + +Kubernetes apps/v1.DaemonSetUpdateStrategy + + + + +(Optional) +

An update strategy to replace existing Envoy DaemonSet pods with new pods. +when envoy be running as a Deployment,it’s must be nil

+ + + + +strategy +
+ + +Kubernetes apps/v1.DeploymentStrategy + + + + +(Optional) +

Strategy describes the deployment strategy to use to replace existing Envoy pods with new ones. +when envoy be running as a DaemonSet,it’s must be nil

+ +

EnvoyTLS From 95065dd17f62b2bd7949457de9c48541e1f036e0 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Sun, 11 Sep 2022 17:27:46 +0800 Subject: [PATCH 02/16] add changelog Signed-off-by: Gang Liu --- apis/projectcontour/v1alpha1/contourdeployment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index 4866be541cb..25ec5db8be2 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -97,7 +97,7 @@ type ContourSettings struct { // +optional LogLevel LogLevel `json:"logLevel,omitempty"` - // Strategy describes the deployment strategy to use to replace existing pods with new ones. + // Strategy describes the deployment strategy to use to replace existing Contour pods with new ones. // +optional Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` } From 155f1afa77e661c00ef3164fde9937413ece86ec Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Tue, 13 Sep 2022 11:10:26 +0800 Subject: [PATCH 03/16] add changelog Signed-off-by: Gang Liu --- changelogs/unreleased/4713-izturn-small.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/unreleased/4713-izturn-small.md diff --git a/changelogs/unreleased/4713-izturn-small.md b/changelogs/unreleased/4713-izturn-small.md new file mode 100644 index 00000000000..b0266a8f969 --- /dev/null +++ b/changelogs/unreleased/4713-izturn-small.md @@ -0,0 +1 @@ +Add (update)Strategy configurability to ContourDeployment resource for components. \ No newline at end of file From f9d2a3f923ba0f9dec9312a714baa7429d81cace Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Tue, 13 Sep 2022 11:32:18 +0800 Subject: [PATCH 04/16] update yaml Signed-off-by: Gang Liu --- examples/contour/01-crds.yaml | 2 +- examples/render/contour-deployment.yaml | 2 +- examples/render/contour-gateway-provisioner.yaml | 2 +- examples/render/contour-gateway.yaml | 2 +- examples/render/contour.yaml | 2 +- site/content/docs/main/config/api-reference.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index c2f672c82e8..4892e27863c 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -934,7 +934,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to use - to replace existing pods with new ones. + to replace existing Contour pods with new ones. properties: rollingUpdate: description: 'Rolling update config params. Present only if diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index a88edf85ae6..6a8f84f719f 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1143,7 +1143,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to use - to replace existing pods with new ones. + to replace existing Contour pods with new ones. properties: rollingUpdate: description: 'Rolling update config params. Present only if diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index 34dc7a25a88..971d4708a2a 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -947,7 +947,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to use - to replace existing pods with new ones. + to replace existing Contour pods with new ones. properties: rollingUpdate: description: 'Rolling update config params. Present only if diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index 541f49608cd..0d8aa776bea 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -1148,7 +1148,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to use - to replace existing pods with new ones. + to replace existing Contour pods with new ones. properties: rollingUpdate: description: 'Rolling update config params. Present only if diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 473edbcf90e..fefa9cf0b1a 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1143,7 +1143,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to use - to replace existing pods with new ones. + to replace existing Contour pods with new ones. properties: rollingUpdate: description: 'Rolling update config params. Present only if diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index b092f3f8b90..96da6962163 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -4902,7 +4902,7 @@

ContourSettings (Optional) -

Strategy describes the deployment strategy to use to replace existing pods with new ones.

+

Strategy describes the deployment strategy to use to replace existing Contour pods with new ones.

From 9250a0d9e9c909aa9275d71dc52f86ffed53c3f3 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Mon, 31 Oct 2022 14:27:25 +0800 Subject: [PATCH 05/16] split ContourDeployment & add ut Signed-off-by: Gang Liu --- .../v1alpha1/contourdeployment.go | 36 ++- .../v1alpha1/zz_generated.deepcopy.go | 52 +++- examples/contour/01-crds.yaml | 263 ++++++++++-------- examples/render/contour-deployment.yaml | 263 ++++++++++-------- .../render/contour-gateway-provisioner.yaml | 263 ++++++++++-------- examples/render/contour-gateway.yaml | 263 ++++++++++-------- examples/render/contour.yaml | 263 ++++++++++-------- internal/provisioner/controller/gateway.go | 21 +- .../provisioner/controller/gateway_test.go | 121 ++++++++ .../docs/main/config/api-reference.html | 101 ++++++- 10 files changed, 1012 insertions(+), 634 deletions(-) diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index 12083c9e570..763e9a485dd 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -112,6 +112,25 @@ type ContourSettings struct { Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` } +// DeploymentSettings contains settings for the Deployment. +type DeploymentSettings struct { + // Replicas is the desired number of replicas. + // + // +kubebuilder:validation:Minimum=0 + Replicas int32 `json:"replicas,omitempty"` + + // Strategy describes the deployment strategy to use to replace existing pods with new ones. + // +optional + Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` +} + +// DaemonSetSettings contains settings for the DaemonSet. +type DaemonSetSettings struct { + // Strategy describes the deployment strategy to use to replace existing DaemonSet pods with new pods. + // +optional + UpdateStrategy *appsv1.DaemonSetUpdateStrategy `json:"updateStrategy,omitempty"` +} + // EnvoySettings contains settings for the Envoy part of the installation, // i.e. the xDS client/data plane and associated resources. type EnvoySettings struct { @@ -122,11 +141,16 @@ type EnvoySettings struct { // +optional WorkloadType WorkloadType `json:"workloadType,omitempty"` + // Deprecated: Use `DeploymentSettings.Replicas`` instead. + // // Replicas is the desired number of Envoy replicas. If WorkloadType // is not "Deployment", this field is ignored. Otherwise, if unset, // defaults to 2. // + // if both `DeploymentSettings.Replicas` and this one is setted, use `DeploymentSettings.Replicas`. + // // +kubebuilder:validation:Minimum=0 + // +optional Replicas int32 `json:"replicas,omitempty"` // NetworkPublishing defines how to expose Envoy to a network. @@ -157,15 +181,15 @@ type EnvoySettings struct { // +optional Resources corev1.ResourceRequirements `json:"resources,omitempty"` - // An update strategy to replace existing Envoy DaemonSet pods with new pods. - // when envoy be running as a `Deployment`,it's must be nil + // DaemonSet describes the settings for running envoy as a `DaemonSet`. + // if `WorkloadType` is `Deployment`,it's must be nil // +optional - UpdateStrategy *appsv1.DaemonSetUpdateStrategy `json:"updateStrategy,omitempty"` + DaemonSet *DaemonSetSettings `json:"daemonSet,omitempty"` - // Strategy describes the deployment strategy to use to replace existing Envoy pods with new ones. - // when envoy be running as a `DaemonSet`,it's must be nil + // Deployment describes the settings for running envoy as a `Deployment`. + // if `WorkloadType` is `DaemonSet`,it's must be nil // +optional - Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` + Deployment *DeploymentSettings `json:"deployment,omitempty"` } // WorkloadType is the type of Kubernetes workload to use for a component. diff --git a/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go b/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go index 4e030d9efcf..c784f203d32 100644 --- a/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go +++ b/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go @@ -358,6 +358,26 @@ func (in *ContourSettings) DeepCopy() *ContourSettings { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DaemonSetSettings) DeepCopyInto(out *DaemonSetSettings) { + *out = *in + if in.UpdateStrategy != nil { + in, out := &in.UpdateStrategy, &out.UpdateStrategy + *out = new(appsv1.DaemonSetUpdateStrategy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetSettings. +func (in *DaemonSetSettings) DeepCopy() *DaemonSetSettings { + if in == nil { + return nil + } + out := new(DaemonSetSettings) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DebugConfig) DeepCopyInto(out *DebugConfig) { *out = *in @@ -373,6 +393,26 @@ func (in *DebugConfig) DeepCopy() *DebugConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentSettings) DeepCopyInto(out *DeploymentSettings) { + *out = *in + if in.Strategy != nil { + in, out := &in.Strategy, &out.Strategy + *out = new(appsv1.DeploymentStrategy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentSettings. +func (in *DeploymentSettings) DeepCopy() *DeploymentSettings { + if in == nil { + return nil + } + out := new(DeploymentSettings) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EnvoyConfig) DeepCopyInto(out *EnvoyConfig) { *out = *in @@ -553,14 +593,14 @@ func (in *EnvoySettings) DeepCopyInto(out *EnvoySettings) { } } in.Resources.DeepCopyInto(&out.Resources) - if in.UpdateStrategy != nil { - in, out := &in.UpdateStrategy, &out.UpdateStrategy - *out = new(appsv1.DaemonSetUpdateStrategy) + if in.DaemonSet != nil { + in, out := &in.DaemonSet, &out.DaemonSet + *out = new(DaemonSetSettings) (*in).DeepCopyInto(*out) } - if in.Strategy != nil { - in, out := &in.Strategy, &out.Strategy - *out = new(appsv1.DeploymentStrategy) + if in.Deployment != nil { + in, out := &in.Deployment, &out.Deployment + *out = new(DeploymentSettings) (*in).DeepCopyInto(*out) } } diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 6114a598f10..3918d3d7d8a 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -1018,6 +1018,144 @@ spec: or Deployment), node placement constraints for the pods, and various options for the Envoy service. properties: + daemonSet: + description: DaemonSet describes the settings for running envoy + as a `DaemonSet`. if `WorkloadType` is `Deployment`,it's must + be nil + properties: + updateStrategy: + description: Strategy describes the deployment strategy to + use to replace existing DaemonSet pods with new pods. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if type = "RollingUpdate". --- TODO: Update this to + follow our convention for oneOf, whatever we decide + it to be. Same as Deployment `strategy.rollingUpdate`. + See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an + existing available DaemonSet pod that can have an + updated DaemonSet pod during during an update. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up to a minimum of 1. + Default value is 0. Example: when this is set to + 30%, at most 30% of the total number of nodes that + should be running the daemon pod (i.e. status.desiredNumberScheduled) + can have their a new pod created before the old + pod is marked as deleted. The update starts by launching + new pods on 30% of nodes. Once an updated pod is + available (Ready for at least minReadySeconds) the + old DaemonSet pod on that node is marked deleted. + If the old pod becomes unavailable for any reason + (Ready transitions to false, is evicted, or is drained) + an updated pod is immediatedly created on that node + without considering surge limits. Allowing surge + implies the possibility that the resources consumed + by the daemonset on any given node can double if + the readiness check fails, and so resource intensive + daemonsets should take into account that they may + cause evictions during disruption.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods + that can be unavailable during the update. Value + can be an absolute number (ex: 5) or a percentage + of total number of DaemonSet pods at the start of + the update (ex: 10%). Absolute number is calculated + from percentage by rounding up. This cannot be 0 + if MaxSurge is 0 Default value is 1. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their pods + stopped for an update at any given time. The update + starts by stopping at most 30% of those DaemonSet + pods and then brings up new DaemonSet pods in their + place. Once the new pods are available, it then + proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet + pods are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object + type: object + deployment: + description: Deployment describes the settings for running envoy + as a `Deployment`. if `WorkloadType` is `DaemonSet`,it's must + be nil + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object extraVolumeMounts: description: ExtraVolumeMounts holds the extra volume mounts to add (normally used with extraVolumes). @@ -2712,9 +2850,10 @@ spec: Envoy pods. type: object replicas: - description: Replicas is the desired number of Envoy replicas. - If WorkloadType is not "Deployment", this field is ignored. - Otherwise, if unset, defaults to 2. + description: "Replicas is the desired number of Envoy replicas. + If WorkloadType is not \"Deployment\", this field is ignored. + Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas + instead." format: int32 minimum: 0 type: integer @@ -2745,124 +2884,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Envoy pods with new ones. when envoy be - running as a `DaemonSet`,it's must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object - updateStrategy: - description: An update strategy to replace existing Envoy DaemonSet - pods with new pods. when envoy be running as a `Deployment`,it's - must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - type = "RollingUpdate". --- TODO: Update this to follow - our convention for oneOf, whatever we decide it to be. Same - as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of nodes with an existing - available DaemonSet pod that can have an updated DaemonSet - pod during during an update. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up - to a minimum of 1. Default value is 0. Example: when - this is set to 30%, at most 30% of the total number - of nodes that should be running the daemon pod (i.e. - status.desiredNumberScheduled) can have their a new - pod created before the old pod is marked as deleted. - The update starts by launching new pods on 30% of nodes. - Once an updated pod is available (Ready for at least - minReadySeconds) the old DaemonSet pod on that node - is marked deleted. If the old pod becomes unavailable - for any reason (Ready transitions to false, is evicted, - or is drained) an updated pod is immediatedly created - on that node without considering surge limits. Allowing - surge implies the possibility that the resources consumed - by the daemonset on any given node can double if the - readiness check fails, and so resource intensive daemonsets - should take into account that they may cause evictions - during disruption.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of DaemonSet pods that - can be unavailable during the update. Value can be an - absolute number (ex: 5) or a percentage of total number - of DaemonSet pods at the start of the update (ex: 10%). - Absolute number is calculated from percentage by rounding - up. This cannot be 0 if MaxSurge is 0 Default value - is 1. Example: when this is set to 30%, at most 30% - of the total number of nodes that should be running - the daemon pod (i.e. status.desiredNumberScheduled) - can have their pods stopped for an update at any given - time. The update starts by stopping at most 30% of those - DaemonSet pods and then brings up new DaemonSet pods - in their place. Once the new pods are available, it - then proceeds onto other DaemonSet pods, thus ensuring - that at least 70% of original number of DaemonSet pods - are available at all times during the update.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of daemon set update. Can be "RollingUpdate" - or "OnDelete". Default is RollingUpdate. - type: string - type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index 016d9928db5..21e296f619d 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1227,6 +1227,144 @@ spec: or Deployment), node placement constraints for the pods, and various options for the Envoy service. properties: + daemonSet: + description: DaemonSet describes the settings for running envoy + as a `DaemonSet`. if `WorkloadType` is `Deployment`,it's must + be nil + properties: + updateStrategy: + description: Strategy describes the deployment strategy to + use to replace existing DaemonSet pods with new pods. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if type = "RollingUpdate". --- TODO: Update this to + follow our convention for oneOf, whatever we decide + it to be. Same as Deployment `strategy.rollingUpdate`. + See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an + existing available DaemonSet pod that can have an + updated DaemonSet pod during during an update. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up to a minimum of 1. + Default value is 0. Example: when this is set to + 30%, at most 30% of the total number of nodes that + should be running the daemon pod (i.e. status.desiredNumberScheduled) + can have their a new pod created before the old + pod is marked as deleted. The update starts by launching + new pods on 30% of nodes. Once an updated pod is + available (Ready for at least minReadySeconds) the + old DaemonSet pod on that node is marked deleted. + If the old pod becomes unavailable for any reason + (Ready transitions to false, is evicted, or is drained) + an updated pod is immediatedly created on that node + without considering surge limits. Allowing surge + implies the possibility that the resources consumed + by the daemonset on any given node can double if + the readiness check fails, and so resource intensive + daemonsets should take into account that they may + cause evictions during disruption.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods + that can be unavailable during the update. Value + can be an absolute number (ex: 5) or a percentage + of total number of DaemonSet pods at the start of + the update (ex: 10%). Absolute number is calculated + from percentage by rounding up. This cannot be 0 + if MaxSurge is 0 Default value is 1. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their pods + stopped for an update at any given time. The update + starts by stopping at most 30% of those DaemonSet + pods and then brings up new DaemonSet pods in their + place. Once the new pods are available, it then + proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet + pods are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object + type: object + deployment: + description: Deployment describes the settings for running envoy + as a `Deployment`. if `WorkloadType` is `DaemonSet`,it's must + be nil + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object extraVolumeMounts: description: ExtraVolumeMounts holds the extra volume mounts to add (normally used with extraVolumes). @@ -2921,9 +3059,10 @@ spec: Envoy pods. type: object replicas: - description: Replicas is the desired number of Envoy replicas. - If WorkloadType is not "Deployment", this field is ignored. - Otherwise, if unset, defaults to 2. + description: "Replicas is the desired number of Envoy replicas. + If WorkloadType is not \"Deployment\", this field is ignored. + Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas + instead." format: int32 minimum: 0 type: integer @@ -2954,124 +3093,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Envoy pods with new ones. when envoy be - running as a `DaemonSet`,it's must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object - updateStrategy: - description: An update strategy to replace existing Envoy DaemonSet - pods with new pods. when envoy be running as a `Deployment`,it's - must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - type = "RollingUpdate". --- TODO: Update this to follow - our convention for oneOf, whatever we decide it to be. Same - as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of nodes with an existing - available DaemonSet pod that can have an updated DaemonSet - pod during during an update. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up - to a minimum of 1. Default value is 0. Example: when - this is set to 30%, at most 30% of the total number - of nodes that should be running the daemon pod (i.e. - status.desiredNumberScheduled) can have their a new - pod created before the old pod is marked as deleted. - The update starts by launching new pods on 30% of nodes. - Once an updated pod is available (Ready for at least - minReadySeconds) the old DaemonSet pod on that node - is marked deleted. If the old pod becomes unavailable - for any reason (Ready transitions to false, is evicted, - or is drained) an updated pod is immediatedly created - on that node without considering surge limits. Allowing - surge implies the possibility that the resources consumed - by the daemonset on any given node can double if the - readiness check fails, and so resource intensive daemonsets - should take into account that they may cause evictions - during disruption.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of DaemonSet pods that - can be unavailable during the update. Value can be an - absolute number (ex: 5) or a percentage of total number - of DaemonSet pods at the start of the update (ex: 10%). - Absolute number is calculated from percentage by rounding - up. This cannot be 0 if MaxSurge is 0 Default value - is 1. Example: when this is set to 30%, at most 30% - of the total number of nodes that should be running - the daemon pod (i.e. status.desiredNumberScheduled) - can have their pods stopped for an update at any given - time. The update starts by stopping at most 30% of those - DaemonSet pods and then brings up new DaemonSet pods - in their place. Once the new pods are available, it - then proceeds onto other DaemonSet pods, thus ensuring - that at least 70% of original number of DaemonSet pods - are available at all times during the update.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of daemon set update. Can be "RollingUpdate" - or "OnDelete". Default is RollingUpdate. - type: string - type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index d6f9ecc95d9..77b9927969e 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -1032,6 +1032,144 @@ spec: or Deployment), node placement constraints for the pods, and various options for the Envoy service. properties: + daemonSet: + description: DaemonSet describes the settings for running envoy + as a `DaemonSet`. if `WorkloadType` is `Deployment`,it's must + be nil + properties: + updateStrategy: + description: Strategy describes the deployment strategy to + use to replace existing DaemonSet pods with new pods. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if type = "RollingUpdate". --- TODO: Update this to + follow our convention for oneOf, whatever we decide + it to be. Same as Deployment `strategy.rollingUpdate`. + See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an + existing available DaemonSet pod that can have an + updated DaemonSet pod during during an update. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up to a minimum of 1. + Default value is 0. Example: when this is set to + 30%, at most 30% of the total number of nodes that + should be running the daemon pod (i.e. status.desiredNumberScheduled) + can have their a new pod created before the old + pod is marked as deleted. The update starts by launching + new pods on 30% of nodes. Once an updated pod is + available (Ready for at least minReadySeconds) the + old DaemonSet pod on that node is marked deleted. + If the old pod becomes unavailable for any reason + (Ready transitions to false, is evicted, or is drained) + an updated pod is immediatedly created on that node + without considering surge limits. Allowing surge + implies the possibility that the resources consumed + by the daemonset on any given node can double if + the readiness check fails, and so resource intensive + daemonsets should take into account that they may + cause evictions during disruption.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods + that can be unavailable during the update. Value + can be an absolute number (ex: 5) or a percentage + of total number of DaemonSet pods at the start of + the update (ex: 10%). Absolute number is calculated + from percentage by rounding up. This cannot be 0 + if MaxSurge is 0 Default value is 1. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their pods + stopped for an update at any given time. The update + starts by stopping at most 30% of those DaemonSet + pods and then brings up new DaemonSet pods in their + place. Once the new pods are available, it then + proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet + pods are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object + type: object + deployment: + description: Deployment describes the settings for running envoy + as a `Deployment`. if `WorkloadType` is `DaemonSet`,it's must + be nil + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object extraVolumeMounts: description: ExtraVolumeMounts holds the extra volume mounts to add (normally used with extraVolumes). @@ -2726,9 +2864,10 @@ spec: Envoy pods. type: object replicas: - description: Replicas is the desired number of Envoy replicas. - If WorkloadType is not "Deployment", this field is ignored. - Otherwise, if unset, defaults to 2. + description: "Replicas is the desired number of Envoy replicas. + If WorkloadType is not \"Deployment\", this field is ignored. + Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas + instead." format: int32 minimum: 0 type: integer @@ -2759,124 +2898,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Envoy pods with new ones. when envoy be - running as a `DaemonSet`,it's must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object - updateStrategy: - description: An update strategy to replace existing Envoy DaemonSet - pods with new pods. when envoy be running as a `Deployment`,it's - must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - type = "RollingUpdate". --- TODO: Update this to follow - our convention for oneOf, whatever we decide it to be. Same - as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of nodes with an existing - available DaemonSet pod that can have an updated DaemonSet - pod during during an update. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up - to a minimum of 1. Default value is 0. Example: when - this is set to 30%, at most 30% of the total number - of nodes that should be running the daemon pod (i.e. - status.desiredNumberScheduled) can have their a new - pod created before the old pod is marked as deleted. - The update starts by launching new pods on 30% of nodes. - Once an updated pod is available (Ready for at least - minReadySeconds) the old DaemonSet pod on that node - is marked deleted. If the old pod becomes unavailable - for any reason (Ready transitions to false, is evicted, - or is drained) an updated pod is immediatedly created - on that node without considering surge limits. Allowing - surge implies the possibility that the resources consumed - by the daemonset on any given node can double if the - readiness check fails, and so resource intensive daemonsets - should take into account that they may cause evictions - during disruption.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of DaemonSet pods that - can be unavailable during the update. Value can be an - absolute number (ex: 5) or a percentage of total number - of DaemonSet pods at the start of the update (ex: 10%). - Absolute number is calculated from percentage by rounding - up. This cannot be 0 if MaxSurge is 0 Default value - is 1. Example: when this is set to 30%, at most 30% - of the total number of nodes that should be running - the daemon pod (i.e. status.desiredNumberScheduled) - can have their pods stopped for an update at any given - time. The update starts by stopping at most 30% of those - DaemonSet pods and then brings up new DaemonSet pods - in their place. Once the new pods are available, it - then proceeds onto other DaemonSet pods, thus ensuring - that at least 70% of original number of DaemonSet pods - are available at all times during the update.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of daemon set update. Can be "RollingUpdate" - or "OnDelete". Default is RollingUpdate. - type: string - type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index 41504262924..b931cdd9b23 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -1233,6 +1233,144 @@ spec: or Deployment), node placement constraints for the pods, and various options for the Envoy service. properties: + daemonSet: + description: DaemonSet describes the settings for running envoy + as a `DaemonSet`. if `WorkloadType` is `Deployment`,it's must + be nil + properties: + updateStrategy: + description: Strategy describes the deployment strategy to + use to replace existing DaemonSet pods with new pods. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if type = "RollingUpdate". --- TODO: Update this to + follow our convention for oneOf, whatever we decide + it to be. Same as Deployment `strategy.rollingUpdate`. + See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an + existing available DaemonSet pod that can have an + updated DaemonSet pod during during an update. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up to a minimum of 1. + Default value is 0. Example: when this is set to + 30%, at most 30% of the total number of nodes that + should be running the daemon pod (i.e. status.desiredNumberScheduled) + can have their a new pod created before the old + pod is marked as deleted. The update starts by launching + new pods on 30% of nodes. Once an updated pod is + available (Ready for at least minReadySeconds) the + old DaemonSet pod on that node is marked deleted. + If the old pod becomes unavailable for any reason + (Ready transitions to false, is evicted, or is drained) + an updated pod is immediatedly created on that node + without considering surge limits. Allowing surge + implies the possibility that the resources consumed + by the daemonset on any given node can double if + the readiness check fails, and so resource intensive + daemonsets should take into account that they may + cause evictions during disruption.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods + that can be unavailable during the update. Value + can be an absolute number (ex: 5) or a percentage + of total number of DaemonSet pods at the start of + the update (ex: 10%). Absolute number is calculated + from percentage by rounding up. This cannot be 0 + if MaxSurge is 0 Default value is 1. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their pods + stopped for an update at any given time. The update + starts by stopping at most 30% of those DaemonSet + pods and then brings up new DaemonSet pods in their + place. Once the new pods are available, it then + proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet + pods are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object + type: object + deployment: + description: Deployment describes the settings for running envoy + as a `Deployment`. if `WorkloadType` is `DaemonSet`,it's must + be nil + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object extraVolumeMounts: description: ExtraVolumeMounts holds the extra volume mounts to add (normally used with extraVolumes). @@ -2927,9 +3065,10 @@ spec: Envoy pods. type: object replicas: - description: Replicas is the desired number of Envoy replicas. - If WorkloadType is not "Deployment", this field is ignored. - Otherwise, if unset, defaults to 2. + description: "Replicas is the desired number of Envoy replicas. + If WorkloadType is not \"Deployment\", this field is ignored. + Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas + instead." format: int32 minimum: 0 type: integer @@ -2960,124 +3099,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Envoy pods with new ones. when envoy be - running as a `DaemonSet`,it's must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object - updateStrategy: - description: An update strategy to replace existing Envoy DaemonSet - pods with new pods. when envoy be running as a `Deployment`,it's - must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - type = "RollingUpdate". --- TODO: Update this to follow - our convention for oneOf, whatever we decide it to be. Same - as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of nodes with an existing - available DaemonSet pod that can have an updated DaemonSet - pod during during an update. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up - to a minimum of 1. Default value is 0. Example: when - this is set to 30%, at most 30% of the total number - of nodes that should be running the daemon pod (i.e. - status.desiredNumberScheduled) can have their a new - pod created before the old pod is marked as deleted. - The update starts by launching new pods on 30% of nodes. - Once an updated pod is available (Ready for at least - minReadySeconds) the old DaemonSet pod on that node - is marked deleted. If the old pod becomes unavailable - for any reason (Ready transitions to false, is evicted, - or is drained) an updated pod is immediatedly created - on that node without considering surge limits. Allowing - surge implies the possibility that the resources consumed - by the daemonset on any given node can double if the - readiness check fails, and so resource intensive daemonsets - should take into account that they may cause evictions - during disruption.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of DaemonSet pods that - can be unavailable during the update. Value can be an - absolute number (ex: 5) or a percentage of total number - of DaemonSet pods at the start of the update (ex: 10%). - Absolute number is calculated from percentage by rounding - up. This cannot be 0 if MaxSurge is 0 Default value - is 1. Example: when this is set to 30%, at most 30% - of the total number of nodes that should be running - the daemon pod (i.e. status.desiredNumberScheduled) - can have their pods stopped for an update at any given - time. The update starts by stopping at most 30% of those - DaemonSet pods and then brings up new DaemonSet pods - in their place. Once the new pods are available, it - then proceeds onto other DaemonSet pods, thus ensuring - that at least 70% of original number of DaemonSet pods - are available at all times during the update.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of daemon set update. Can be "RollingUpdate" - or "OnDelete". Default is RollingUpdate. - type: string - type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index e529049ce67..14db27e7511 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1227,6 +1227,144 @@ spec: or Deployment), node placement constraints for the pods, and various options for the Envoy service. properties: + daemonSet: + description: DaemonSet describes the settings for running envoy + as a `DaemonSet`. if `WorkloadType` is `Deployment`,it's must + be nil + properties: + updateStrategy: + description: Strategy describes the deployment strategy to + use to replace existing DaemonSet pods with new pods. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if type = "RollingUpdate". --- TODO: Update this to + follow our convention for oneOf, whatever we decide + it to be. Same as Deployment `strategy.rollingUpdate`. + See https://github.com/kubernetes/kubernetes/issues/35345' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of nodes with an + existing available DaemonSet pod that can have an + updated DaemonSet pod during during an update. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up to a minimum of 1. + Default value is 0. Example: when this is set to + 30%, at most 30% of the total number of nodes that + should be running the daemon pod (i.e. status.desiredNumberScheduled) + can have their a new pod created before the old + pod is marked as deleted. The update starts by launching + new pods on 30% of nodes. Once an updated pod is + available (Ready for at least minReadySeconds) the + old DaemonSet pod on that node is marked deleted. + If the old pod becomes unavailable for any reason + (Ready transitions to false, is evicted, or is drained) + an updated pod is immediatedly created on that node + without considering surge limits. Allowing surge + implies the possibility that the resources consumed + by the daemonset on any given node can double if + the readiness check fails, and so resource intensive + daemonsets should take into account that they may + cause evictions during disruption.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of DaemonSet pods + that can be unavailable during the update. Value + can be an absolute number (ex: 5) or a percentage + of total number of DaemonSet pods at the start of + the update (ex: 10%). Absolute number is calculated + from percentage by rounding up. This cannot be 0 + if MaxSurge is 0 Default value is 1. Example: when + this is set to 30%, at most 30% of the total number + of nodes that should be running the daemon pod (i.e. + status.desiredNumberScheduled) can have their pods + stopped for an update at any given time. The update + starts by stopping at most 30% of those DaemonSet + pods and then brings up new DaemonSet pods in their + place. Once the new pods are available, it then + proceeds onto other DaemonSet pods, thus ensuring + that at least 70% of original number of DaemonSet + pods are available at all times during the update.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of daemon set update. Can be "RollingUpdate" + or "OnDelete". Default is RollingUpdate. + type: string + type: object + type: object + deployment: + description: Deployment describes the settings for running envoy + as a `Deployment`. if `WorkloadType` is `DaemonSet`,it's must + be nil + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object extraVolumeMounts: description: ExtraVolumeMounts holds the extra volume mounts to add (normally used with extraVolumes). @@ -2921,9 +3059,10 @@ spec: Envoy pods. type: object replicas: - description: Replicas is the desired number of Envoy replicas. - If WorkloadType is not "Deployment", this field is ignored. - Otherwise, if unset, defaults to 2. + description: "Replicas is the desired number of Envoy replicas. + If WorkloadType is not \"Deployment\", this field is ignored. + Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas + instead." format: int32 minimum: 0 type: integer @@ -2954,124 +3093,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Envoy pods with new ones. when envoy be - running as a `DaemonSet`,it's must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object - updateStrategy: - description: An update strategy to replace existing Envoy DaemonSet - pods with new pods. when envoy be running as a `Deployment`,it's - must be nil - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - type = "RollingUpdate". --- TODO: Update this to follow - our convention for oneOf, whatever we decide it to be. Same - as Deployment `strategy.rollingUpdate`. See https://github.com/kubernetes/kubernetes/issues/35345' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of nodes with an existing - available DaemonSet pod that can have an updated DaemonSet - pod during during an update. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up - to a minimum of 1. Default value is 0. Example: when - this is set to 30%, at most 30% of the total number - of nodes that should be running the daemon pod (i.e. - status.desiredNumberScheduled) can have their a new - pod created before the old pod is marked as deleted. - The update starts by launching new pods on 30% of nodes. - Once an updated pod is available (Ready for at least - minReadySeconds) the old DaemonSet pod on that node - is marked deleted. If the old pod becomes unavailable - for any reason (Ready transitions to false, is evicted, - or is drained) an updated pod is immediatedly created - on that node without considering surge limits. Allowing - surge implies the possibility that the resources consumed - by the daemonset on any given node can double if the - readiness check fails, and so resource intensive daemonsets - should take into account that they may cause evictions - during disruption.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of DaemonSet pods that - can be unavailable during the update. Value can be an - absolute number (ex: 5) or a percentage of total number - of DaemonSet pods at the start of the update (ex: 10%). - Absolute number is calculated from percentage by rounding - up. This cannot be 0 if MaxSurge is 0 Default value - is 1. Example: when this is set to 30%, at most 30% - of the total number of nodes that should be running - the daemon pod (i.e. status.desiredNumberScheduled) - can have their pods stopped for an update at any given - time. The update starts by stopping at most 30% of those - DaemonSet pods and then brings up new DaemonSet pods - in their place. Once the new pods are available, it - then proceeds onto other DaemonSet pods, thus ensuring - that at least 70% of original number of DaemonSet pods - are available at all times during the update.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of daemon set update. Can be "RollingUpdate" - or "OnDelete". Default is RollingUpdate. - type: string - type: object workloadType: description: WorkloadType is the type of workload to install Envoy as. Choices are DaemonSet and Deployment. If unset, defaults diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 59e6a12b58a..3d4293b319a 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -276,9 +276,14 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } // Deployment replicas - if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment && - gatewayClassParams.Spec.Envoy.Replicas > 0 { - contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas + if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment { + if gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Replicas > 0 { + contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Deployment.Replicas + + } else if gatewayClassParams.Spec.Envoy.Replicas > 0 { + contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas + } + } // Network publishing @@ -315,13 +320,15 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct contourModel.Spec.EnvoyResources = gatewayClassParams.Spec.Envoy.Resources if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment && - gatewayClassParams.Spec.Envoy.Strategy != nil { - contourModel.Spec.EnvoyStrategy = *gatewayClassParams.Spec.Envoy.Strategy + gatewayClassParams.Spec.Envoy.Deployment != nil && + gatewayClassParams.Spec.Envoy.Deployment.Strategy != nil { + contourModel.Spec.EnvoyStrategy = *gatewayClassParams.Spec.Envoy.Deployment.Strategy } if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDaemonSet && - gatewayClassParams.Spec.Envoy.UpdateStrategy != nil { - contourModel.Spec.EnvoyUpdateStrategy = *gatewayClassParams.Spec.Envoy.UpdateStrategy + gatewayClassParams.Spec.Envoy.DaemonSet != nil && + gatewayClassParams.Spec.Envoy.DaemonSet.UpdateStrategy != nil { + contourModel.Spec.EnvoyUpdateStrategy = *gatewayClassParams.Spec.Envoy.DaemonSet.UpdateStrategy } } diff --git a/internal/provisioner/controller/gateway_test.go b/internal/provisioner/controller/gateway_test.go index 825fd147cc0..c69f2de4be6 100644 --- a/internal/provisioner/controller/gateway_test.go +++ b/internal/provisioner/controller/gateway_test.go @@ -1110,6 +1110,68 @@ func TestGatewayReconcile(t *testing.T) { assert.True(t, errors.IsNotFound(err)) }, }, + "If ContourDeployment.Spec.Envoy.WorkloadType is set to Deployment," + + "an Envoy deployment is provisioned with the specified number of replicas && strategy that come from DeployemntSettings": { + gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), + gatewayClassParams: &contourv1alpha1.ContourDeployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "projectcontour", + Name: "gatewayclass-1-params", + }, + Spec: contourv1alpha1.ContourDeploymentSpec{ + Envoy: &contourv1alpha1.EnvoySettings{ + WorkloadType: contourv1alpha1.WorkloadTypeDeployment, + Replicas: 7, + Deployment: &contourv1alpha1.DeploymentSettings{ + Replicas: 6, + Strategy: &appsv1.DeploymentStrategy{ + Type: appsv1.RecreateDeploymentStrategyType, + }, + }, + }, + }, + }, + gateway: &gatewayv1beta1.Gateway{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "gateway-1", + }, + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName("gatewayclass-1"), + }, + }, + assertions: func(t *testing.T, r *gatewayReconciler, gw *gatewayv1beta1.Gateway, reconcileErr error) { + require.NoError(t, reconcileErr) + + // Verify the Gateway has a "Scheduled: true" condition + require.NoError(t, r.client.Get(context.Background(), keyFor(gw), gw)) + require.Len(t, gw.Status.Conditions, 1) + assert.Equal(t, string(gatewayv1beta1.GatewayConditionScheduled), gw.Status.Conditions[0].Type) + assert.Equal(t, metav1.ConditionTrue, gw.Status.Conditions[0].Status) + + // Verify the deployment has been created + deploy := &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "envoy-gateway-1", + }, + } + require.NoError(t, r.client.Get(context.Background(), keyFor(deploy), deploy)) + assert.EqualValues(t, 6, *deploy.Spec.Replicas) + assert.EqualValues(t, appsv1.RecreateDeploymentStrategyType, deploy.Spec.Strategy.Type) + + // Verify that a daemonset has *not* been created + ds := &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "envoy-gateway-1", + }, + } + err := r.client.Get(context.Background(), keyFor(ds), ds) + assert.True(t, errors.IsNotFound(err)) + }, + }, + "If ContourDeployment.Spec.Envoy.PodAnnotations is specified, the Envoy pods' have annotations for prometheus & user-defined": { gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), gatewayClassParams: &contourv1alpha1.ContourDeployment{ @@ -1154,6 +1216,65 @@ func TestGatewayReconcile(t *testing.T) { assert.Contains(t, ds.Spec.Template.ObjectMeta.Annotations, "key") }, }, + + "If ContourDeployment.Spec.Envoy.WorkloadType is set to DaemonSet," + + "an Envoy daemonset is provisioned with the strategy that come from DaemonsetSettings": { + gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), + gatewayClassParams: &contourv1alpha1.ContourDeployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "projectcontour", + Name: "gatewayclass-1-params", + }, + Spec: contourv1alpha1.ContourDeploymentSpec{ + Envoy: &contourv1alpha1.EnvoySettings{ + WorkloadType: contourv1alpha1.WorkloadTypeDaemonSet, + DaemonSet: &contourv1alpha1.DaemonSetSettings{ + UpdateStrategy: &appsv1.DaemonSetUpdateStrategy{ + Type: appsv1.OnDeleteDaemonSetStrategyType, + }, + }, + }, + }, + }, + gateway: &gatewayv1beta1.Gateway{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "gateway-1", + }, + Spec: gatewayv1beta1.GatewaySpec{ + GatewayClassName: gatewayv1beta1.ObjectName("gatewayclass-1"), + }, + }, + assertions: func(t *testing.T, r *gatewayReconciler, gw *gatewayv1beta1.Gateway, reconcileErr error) { + require.NoError(t, reconcileErr) + + // Verify the Gateway has a "Scheduled: true" condition + require.NoError(t, r.client.Get(context.Background(), keyFor(gw), gw)) + require.Len(t, gw.Status.Conditions, 1) + assert.Equal(t, string(gatewayv1beta1.GatewayConditionScheduled), gw.Status.Conditions[0].Type) + assert.Equal(t, metav1.ConditionTrue, gw.Status.Conditions[0].Status) + + // Verify the daemonset has been created + ds := &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "envoy-gateway-1", + }, + } + require.NoError(t, r.client.Get(context.Background(), keyFor(ds), ds)) + assert.EqualValues(t, appsv1.OnDeleteDaemonSetStrategyType, ds.Spec.UpdateStrategy.Type) + + // Verify that a deployment has *not* been created + deployment := &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "gateway-1", + Name: "envoy-gateway-1", + }, + } + err := r.client.Get(context.Background(), keyFor(deployment), deployment) + assert.True(t, errors.IsNotFound(err)) + }, + }, } for name, tc := range tests { diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index 6233c080569..d41a4759887 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -5450,6 +5450,40 @@

ContourSettings +

DaemonSetSettings +

+

+(Appears on: +EnvoySettings) +

+

+

DaemonSetSettings contains settings for the DaemonSet.

+

+ + + + + + + + + + + + + +
FieldDescription
+updateStrategy +
+ + +Kubernetes apps/v1.DaemonSetUpdateStrategy + + +
+(Optional) +

Strategy describes the deployment strategy to use to replace existing DaemonSet pods with new pods.

+

DebugConfig

@@ -5497,6 +5531,52 @@

DebugConfig +

DeploymentSettings +

+

+(Appears on: +EnvoySettings) +

+

+

DeploymentSettings contains settings for the Deployment.

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+replicas +
+ +int32 + +
+

Replicas is the desired number of replicas.

+
+strategy +
+ + +Kubernetes apps/v1.DeploymentStrategy + + +
+(Optional) +

Strategy describes the deployment strategy to use to replace existing pods with new ones.

+

EnvoyConfig

@@ -5998,6 +6078,7 @@

EnvoySettings

Replicas is the desired number of Envoy replicas. If WorkloadType is not “Deployment”, this field is ignored. Otherwise, if unset, defaults to 2.

+

Deprecated: Use DeploymentSettings.Replicas instead.

@@ -6091,34 +6172,34 @@

EnvoySettings -updateStrategy +daemonSet
- -Kubernetes apps/v1.DaemonSetUpdateStrategy + +DaemonSetSettings (Optional) -

An update strategy to replace existing Envoy DaemonSet pods with new pods. -when envoy be running as a Deployment,it’s must be nil

+

DaemonSet describes the settings for running envoy as a DaemonSet. +if WorkloadType is Deployment,it’s must be nil

-strategy +deployment
- -Kubernetes apps/v1.DeploymentStrategy + +DeploymentSettings (Optional) -

Strategy describes the deployment strategy to use to replace existing Envoy pods with new ones. -when envoy be running as a DaemonSet,it’s must be nil

+

Deployment describes the settings for running envoy as a Deployment. +if WorkloadType is DaemonSet,it’s must be nil

From e34c1df4d19b532e9ab53052b6f1edf1e3ff3625 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Mon, 31 Oct 2022 15:08:23 +0800 Subject: [PATCH 06/16] split ContourDeployment & add ut Signed-off-by: Gang Liu --- .../v1alpha1/contourdeployment.go | 11 +- .../v1alpha1/zz_generated.deepcopy.go | 6 +- examples/contour/01-crds.yaml | 129 ++++++++++-------- examples/render/contour-deployment.yaml | 129 ++++++++++-------- .../render/contour-gateway-provisioner.yaml | 129 ++++++++++-------- examples/render/contour-gateway.yaml | 129 ++++++++++-------- examples/render/contour.yaml | 129 ++++++++++-------- internal/provisioner/controller/gateway.go | 11 +- .../provisioner/controller/gateway_test.go | 18 ++- .../docs/main/config/api-reference.html | 18 ++- 10 files changed, 406 insertions(+), 303 deletions(-) diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index 763e9a485dd..ac6491825e0 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -76,10 +76,15 @@ type ContourDeploymentSpec struct { // ContourSettings contains settings for the Contour part of the installation, // i.e. the xDS server/control plane and associated resources. type ContourSettings struct { - // Replicas is the desired number of Contour replicas. If unset, + // Deprecated: Use `DeploymentSettings.Replicas`` instead. + // + // Replicas is the desired number of Contour replicas. If if unset, // defaults to 2. // + // if both `DeploymentSettings.Replicas` and this one is setted, use `DeploymentSettings.Replicas`. + // // +kubebuilder:validation:Minimum=0 + // +optional Replicas int32 `json:"replicas,omitempty"` // NodePlacement describes node scheduling configuration of Contour pods. @@ -107,9 +112,9 @@ type ContourSettings struct { // +optional Resources corev1.ResourceRequirements `json:"resources,omitempty"` - // Strategy describes the deployment strategy to use to replace existing Contour pods with new ones. + // Deployment describes the settings for running contour as a `Deployment`. // +optional - Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` + Deployment *DeploymentSettings `json:"deployment,omitempty"` } // DeploymentSettings contains settings for the Deployment. diff --git a/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go b/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go index c784f203d32..493fc6b6f28 100644 --- a/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go +++ b/apis/projectcontour/v1alpha1/zz_generated.deepcopy.go @@ -341,9 +341,9 @@ func (in *ContourSettings) DeepCopyInto(out *ContourSettings) { (*in).DeepCopyInto(*out) } in.Resources.DeepCopyInto(&out.Resources) - if in.Strategy != nil { - in, out := &in.Strategy, &out.Strategy - *out = new(appsv1.DeploymentStrategy) + if in.Deployment != nil { + in, out := &in.Deployment, &out.Deployment + *out = new(DeploymentSettings) (*in).DeepCopyInto(*out) } } diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 3918d3d7d8a..9b589a7fa5f 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -854,6 +854,69 @@ spec: associated resources, including things like replica count for the Deployment, and node placement constraints for the pods. properties: + deployment: + description: Deployment describes the settings for running contour + as a `Deployment`. + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object kubernetesLogLevel: description: KubernetesLogLevel Enable Kubernetes client debug logging with log level. If unset, defaults to 0. @@ -927,8 +990,10 @@ spec: type: array type: object replicas: - description: Replicas is the desired number of Contour replicas. - If unset, defaults to 2. + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Contour replicas. If if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -959,57 +1024,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Contour pods with new ones. - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -2850,10 +2864,11 @@ spec: Envoy pods. type: object replicas: - description: "Replicas is the desired number of Envoy replicas. - If WorkloadType is not \"Deployment\", this field is ignored. - Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas - instead." + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Envoy replicas. If WorkloadType + is not \"Deployment\", this field is ignored. Otherwise, if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index 21e296f619d..f5e39feae70 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1063,6 +1063,69 @@ spec: associated resources, including things like replica count for the Deployment, and node placement constraints for the pods. properties: + deployment: + description: Deployment describes the settings for running contour + as a `Deployment`. + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object kubernetesLogLevel: description: KubernetesLogLevel Enable Kubernetes client debug logging with log level. If unset, defaults to 0. @@ -1136,8 +1199,10 @@ spec: type: array type: object replicas: - description: Replicas is the desired number of Contour replicas. - If unset, defaults to 2. + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Contour replicas. If if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -1168,57 +1233,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Contour pods with new ones. - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -3059,10 +3073,11 @@ spec: Envoy pods. type: object replicas: - description: "Replicas is the desired number of Envoy replicas. - If WorkloadType is not \"Deployment\", this field is ignored. - Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas - instead." + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Envoy replicas. If WorkloadType + is not \"Deployment\", this field is ignored. Otherwise, if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index 77b9927969e..15a2f15ca2b 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -868,6 +868,69 @@ spec: associated resources, including things like replica count for the Deployment, and node placement constraints for the pods. properties: + deployment: + description: Deployment describes the settings for running contour + as a `Deployment`. + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object kubernetesLogLevel: description: KubernetesLogLevel Enable Kubernetes client debug logging with log level. If unset, defaults to 0. @@ -941,8 +1004,10 @@ spec: type: array type: object replicas: - description: Replicas is the desired number of Contour replicas. - If unset, defaults to 2. + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Contour replicas. If if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -973,57 +1038,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Contour pods with new ones. - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -2864,10 +2878,11 @@ spec: Envoy pods. type: object replicas: - description: "Replicas is the desired number of Envoy replicas. - If WorkloadType is not \"Deployment\", this field is ignored. - Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas - instead." + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Envoy replicas. If WorkloadType + is not \"Deployment\", this field is ignored. Otherwise, if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index b931cdd9b23..a9b93afcc64 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -1069,6 +1069,69 @@ spec: associated resources, including things like replica count for the Deployment, and node placement constraints for the pods. properties: + deployment: + description: Deployment describes the settings for running contour + as a `Deployment`. + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object kubernetesLogLevel: description: KubernetesLogLevel Enable Kubernetes client debug logging with log level. If unset, defaults to 0. @@ -1142,8 +1205,10 @@ spec: type: array type: object replicas: - description: Replicas is the desired number of Contour replicas. - If unset, defaults to 2. + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Contour replicas. If if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -1174,57 +1239,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Contour pods with new ones. - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -3065,10 +3079,11 @@ spec: Envoy pods. type: object replicas: - description: "Replicas is the desired number of Envoy replicas. - If WorkloadType is not \"Deployment\", this field is ignored. - Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas - instead." + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Envoy replicas. If WorkloadType + is not \"Deployment\", this field is ignored. Otherwise, if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 14db27e7511..1e73f92f0b9 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1063,6 +1063,69 @@ spec: associated resources, including things like replica count for the Deployment, and node placement constraints for the pods. properties: + deployment: + description: Deployment describes the settings for running contour + as a `Deployment`. + properties: + replicas: + description: Replicas is the desired number of replicas. + format: int32 + minimum: 0 + type: integer + strategy: + description: Strategy describes the deployment strategy to + use to replace existing pods with new ones. + properties: + rollingUpdate: + description: 'Rolling update config params. Present only + if DeploymentStrategyType = RollingUpdate. --- TODO: + Update this to follow our convention for oneOf, whatever + we decide it to be.' + properties: + maxSurge: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be scheduled above the desired number of pods. Value + can be an absolute number (ex: 5) or a percentage + of desired pods (ex: 10%). This can not be 0 if + MaxUnavailable is 0. Absolute number is calculated + from percentage by rounding up. Defaults to 25%. + Example: when this is set to 30%, the new ReplicaSet + can be scaled up immediately when the rolling update + starts, such that the total number of old and new + pods do not exceed 130% of desired pods. Once old + pods have been killed, new ReplicaSet can be scaled + up further, ensuring that total number of pods running + at any time during the update is at most 130% of + desired pods.' + x-kubernetes-int-or-string: true + maxUnavailable: + anyOf: + - type: integer + - type: string + description: 'The maximum number of pods that can + be unavailable during the update. Value can be an + absolute number (ex: 5) or a percentage of desired + pods (ex: 10%). Absolute number is calculated from + percentage by rounding down. This can not be 0 if + MaxSurge is 0. Defaults to 25%. Example: when this + is set to 30%, the old ReplicaSet can be scaled + down to 70% of desired pods immediately when the + rolling update starts. Once new pods are ready, + old ReplicaSet can be scaled down further, followed + by scaling up the new ReplicaSet, ensuring that + the total number of pods available at all times + during the update is at least 70% of desired pods.' + x-kubernetes-int-or-string: true + type: object + type: + description: Type of deployment. Can be "Recreate" or + "RollingUpdate". Default is RollingUpdate. + type: string + type: object + type: object kubernetesLogLevel: description: KubernetesLogLevel Enable Kubernetes client debug logging with log level. If unset, defaults to 0. @@ -1136,8 +1199,10 @@ spec: type: array type: object replicas: - description: Replicas is the desired number of Contour replicas. - If unset, defaults to 2. + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Contour replicas. If if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -1168,57 +1233,6 @@ spec: to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object - strategy: - description: Strategy describes the deployment strategy to use - to replace existing Contour pods with new ones. - properties: - rollingUpdate: - description: 'Rolling update config params. Present only if - DeploymentStrategyType = RollingUpdate. --- TODO: Update - this to follow our convention for oneOf, whatever we decide - it to be.' - properties: - maxSurge: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be scheduled - above the desired number of pods. Value can be an absolute - number (ex: 5) or a percentage of desired pods (ex: - 10%). This can not be 0 if MaxUnavailable is 0. Absolute - number is calculated from percentage by rounding up. - Defaults to 25%. Example: when this is set to 30%, the - new ReplicaSet can be scaled up immediately when the - rolling update starts, such that the total number of - old and new pods do not exceed 130% of desired pods. - Once old pods have been killed, new ReplicaSet can be - scaled up further, ensuring that total number of pods - running at any time during the update is at most 130% - of desired pods.' - x-kubernetes-int-or-string: true - maxUnavailable: - anyOf: - - type: integer - - type: string - description: 'The maximum number of pods that can be unavailable - during the update. Value can be an absolute number (ex: - 5) or a percentage of desired pods (ex: 10%). Absolute - number is calculated from percentage by rounding down. - This can not be 0 if MaxSurge is 0. Defaults to 25%. - Example: when this is set to 30%, the old ReplicaSet - can be scaled down to 70% of desired pods immediately - when the rolling update starts. Once new pods are ready, - old ReplicaSet can be scaled down further, followed - by scaling up the new ReplicaSet, ensuring that the - total number of pods available at all times during the - update is at least 70% of desired pods.' - x-kubernetes-int-or-string: true - type: object - type: - description: Type of deployment. Can be "Recreate" or "RollingUpdate". - Default is RollingUpdate. - type: string - type: object type: object envoy: description: Envoy specifies deployment-time settings for the Envoy @@ -3059,10 +3073,11 @@ spec: Envoy pods. type: object replicas: - description: "Replicas is the desired number of Envoy replicas. - If WorkloadType is not \"Deployment\", this field is ignored. - Otherwise, if unset, defaults to 2. \n Deprecated: Use DeploymentSettings.Replicas - instead." + description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + \n Replicas is the desired number of Envoy replicas. If WorkloadType + is not \"Deployment\", this field is ignored. Otherwise, if + unset, defaults to 2. \n if both `DeploymentSettings.Replicas` + and this one is setted, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 3d4293b319a..045cadd7df5 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -239,8 +239,12 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } if gatewayClassParams.Spec.Contour != nil { + // Deployment replicas - if gatewayClassParams.Spec.Contour.Replicas > 0 { + if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Replicas > 0 { + contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Deployment.Replicas + + } else if gatewayClassParams.Spec.Contour.Replicas > 0 { contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas } @@ -262,8 +266,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct contourModel.Spec.KubernetesLogLevel = gatewayClassParams.Spec.Contour.KubernetesLogLevel - if gatewayClassParams.Spec.Contour.Strategy != nil { - contourModel.Spec.ContourStrategy = *gatewayClassParams.Spec.Contour.Strategy + if gatewayClassParams.Spec.Contour.Deployment != nil && + gatewayClassParams.Spec.Contour.Deployment.Strategy != nil { + contourModel.Spec.ContourStrategy = *gatewayClassParams.Spec.Contour.Deployment.Strategy } } diff --git a/internal/provisioner/controller/gateway_test.go b/internal/provisioner/controller/gateway_test.go index c69f2de4be6..9e0fe10a5b3 100644 --- a/internal/provisioner/controller/gateway_test.go +++ b/internal/provisioner/controller/gateway_test.go @@ -719,7 +719,7 @@ func TestGatewayReconcile(t *testing.T) { assert.EqualValues(t, 2, *deploy.Spec.Replicas) }, }, - "If ContourDeployment.Spec.Contour.Replicas is specified, the Contour deployment gets that number of replicas": { + "If ContourDeployment.Spec.Contour.Deployment is specified, the Contour deployment gets that settings": { gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), gatewayClassParams: &contourv1alpha1.ContourDeployment{ ObjectMeta: metav1.ObjectMeta{ @@ -729,6 +729,12 @@ func TestGatewayReconcile(t *testing.T) { Spec: contourv1alpha1.ContourDeploymentSpec{ Contour: &contourv1alpha1.ContourSettings{ Replicas: 3, + Deployment: &contourv1alpha1.DeploymentSettings{ + Replicas: 4, + Strategy: &appsv1.DeploymentStrategy{ + Type: appsv1.RecreateDeploymentStrategyType, + }, + }, }, }, }, @@ -760,7 +766,9 @@ func TestGatewayReconcile(t *testing.T) { require.NoError(t, r.client.Get(context.Background(), keyFor(deploy), deploy)) require.NotNil(t, deploy.Spec.Replicas) - assert.EqualValues(t, 3, *deploy.Spec.Replicas) + assert.EqualValues(t, 4, *deploy.Spec.Replicas) + require.NotNil(t, deploy.Spec.Strategy) + assert.EqualValues(t, appsv1.RecreateDeploymentStrategyType, deploy.Spec.Strategy.Type) }, }, "If ContourDeployment.Spec.Contour.NodePlacement is not specified, the Contour deployment has no node selector or tolerations set": { @@ -1111,7 +1119,7 @@ func TestGatewayReconcile(t *testing.T) { }, }, "If ContourDeployment.Spec.Envoy.WorkloadType is set to Deployment," + - "an Envoy deployment is provisioned with the specified number of replicas && strategy that come from DeployemntSettings": { + "an Envoy deployment is provisioned with the settings come from DeployemntSettings": { gatewayClass: reconcilableGatewayClassWithParams("gatewayclass-1", controller), gatewayClassParams: &contourv1alpha1.ContourDeployment{ ObjectMeta: metav1.ObjectMeta{ @@ -1157,7 +1165,11 @@ func TestGatewayReconcile(t *testing.T) { }, } require.NoError(t, r.client.Get(context.Background(), keyFor(deploy), deploy)) + + assert.NotNil(t, deploy.Spec.Replicas) assert.EqualValues(t, 6, *deploy.Spec.Replicas) + + assert.NotNil(t, deploy.Spec.Strategy) assert.EqualValues(t, appsv1.RecreateDeploymentStrategyType, deploy.Spec.Strategy.Type) // Verify that a daemonset has *not* been created diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index d41a4759887..99480f7f740 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -5367,8 +5367,11 @@

ContourSettings -

Replicas is the desired number of Contour replicas. If unset, +(Optional) +

Deprecated: Use DeploymentSettings.Replicas` instead.

+

Replicas is the desired number of Contour replicas. If if unset, defaults to 2.

+

if both DeploymentSettings.Replicas and this one is setted, use DeploymentSettings.Replicas.

@@ -5435,17 +5438,17 @@

ContourSettings -strategy +deployment
- -Kubernetes apps/v1.DeploymentStrategy + +DeploymentSettings (Optional) -

Strategy describes the deployment strategy to use to replace existing Contour pods with new ones.

+

Deployment describes the settings for running contour as a Deployment.

@@ -5535,6 +5538,7 @@

DeploymentSettings

(Appears on: +ContourSettings, EnvoySettings)

@@ -6075,10 +6079,12 @@

EnvoySettings +(Optional) +

Deprecated: Use DeploymentSettings.Replicas` instead.

Replicas is the desired number of Envoy replicas. If WorkloadType is not “Deployment”, this field is ignored. Otherwise, if unset, defaults to 2.

-

Deprecated: Use DeploymentSettings.Replicas instead.

+

if both DeploymentSettings.Replicas and this one is setted, use DeploymentSettings.Replicas.

From efc0f1df5b46776180b9dcf41d9284fe93bb76a1 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Mon, 31 Oct 2022 17:11:35 +0800 Subject: [PATCH 07/16] make golint happy Signed-off-by: Gang Liu --- apis/projectcontour/v1alpha1/contourdeployment.go | 4 ++-- examples/contour/01-crds.yaml | 4 ++-- examples/render/contour-deployment.yaml | 4 ++-- examples/render/contour-gateway-provisioner.yaml | 4 ++-- examples/render/contour-gateway.yaml | 4 ++-- examples/render/contour.yaml | 4 ++-- internal/provisioner/controller/gateway.go | 7 +++++-- site/content/docs/main/config/api-reference.html | 4 ++-- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index ac6491825e0..eaacdcd259e 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -81,7 +81,7 @@ type ContourSettings struct { // Replicas is the desired number of Contour replicas. If if unset, // defaults to 2. // - // if both `DeploymentSettings.Replicas` and this one is setted, use `DeploymentSettings.Replicas`. + // if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`. // // +kubebuilder:validation:Minimum=0 // +optional @@ -152,7 +152,7 @@ type EnvoySettings struct { // is not "Deployment", this field is ignored. Otherwise, if unset, // defaults to 2. // - // if both `DeploymentSettings.Replicas` and this one is setted, use `DeploymentSettings.Replicas`. + // if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`. // // +kubebuilder:validation:Minimum=0 // +optional diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 9b589a7fa5f..af8bf30b56b 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -993,7 +993,7 @@ spec: description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -2868,7 +2868,7 @@ spec: \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index f5e39feae70..1e1f2bf02af 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1202,7 +1202,7 @@ spec: description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -3077,7 +3077,7 @@ spec: \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index 15a2f15ca2b..da569d667e4 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -1007,7 +1007,7 @@ spec: description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -2882,7 +2882,7 @@ spec: \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index a9b93afcc64..e2169f2718c 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -1208,7 +1208,7 @@ spec: description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -3083,7 +3083,7 @@ spec: \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 1e73f92f0b9..45538e0ac03 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1202,7 +1202,7 @@ spec: description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer @@ -3077,7 +3077,7 @@ spec: \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` - and this one is setted, use `DeploymentSettings.Replicas`." + and this one is set, use `DeploymentSettings.Replicas`." format: int32 minimum: 0 type: integer diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 045cadd7df5..e21d079008b 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -244,7 +244,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Replicas > 0 { contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Deployment.Replicas - } else if gatewayClassParams.Spec.Contour.Replicas > 0 { + } else if gatewayClassParams.Spec.Contour.Replicas > 0 { // nolint: staticcheck + + // nolint: staticcheck contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas } @@ -285,7 +287,8 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Replicas > 0 { contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Deployment.Replicas - } else if gatewayClassParams.Spec.Envoy.Replicas > 0 { + } else if gatewayClassParams.Spec.Envoy.Replicas > 0 { //nolint: staticcheck + // nolint: staticcheck contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas } diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index 99480f7f740..8a1af6a766e 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -5371,7 +5371,7 @@

ContourSettings

Deprecated: Use DeploymentSettings.Replicas` instead.

Replicas is the desired number of Contour replicas. If if unset, defaults to 2.

-

if both DeploymentSettings.Replicas and this one is setted, use DeploymentSettings.Replicas.

+

if both DeploymentSettings.Replicas and this one is set, use DeploymentSettings.Replicas.

@@ -6084,7 +6084,7 @@

EnvoySettings

Replicas is the desired number of Envoy replicas. If WorkloadType is not “Deployment”, this field is ignored. Otherwise, if unset, defaults to 2.

-

if both DeploymentSettings.Replicas and this one is setted, use DeploymentSettings.Replicas.

+

if both DeploymentSettings.Replicas and this one is set, use DeploymentSettings.Replicas.

From a620a771767ed05ff4fcc026c66fa5f9f0287f4c Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Thu, 3 Nov 2022 11:28:01 +0800 Subject: [PATCH 08/16] make lint Signed-off-by: Gang Liu --- internal/provisioner/controller/gateway.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 91530db4576..10f61ec5f7c 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -336,7 +336,6 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct contourModel.Spec.EnvoyLogLevel = gatewayClassParams.Spec.Envoy.LogLevel } - if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment && gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Strategy != nil { From 349bcad1ab9f9354b11122040aea4cb289a88a2b Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Fri, 4 Nov 2022 10:14:06 +0800 Subject: [PATCH 09/16] make generate Signed-off-by: Gang Liu --- .../v1alpha1/contourdeployment.go | 2 +- examples/contour/01-crds.yaml | 4 +- examples/render/contour-deployment.yaml | 4 +- .../render/contour-gateway-provisioner.yaml | 4 +- examples/render/contour-gateway.yaml | 92 +------------------ examples/render/contour.yaml | 4 +- .../docs/main/config/api-reference.html | 2 +- 7 files changed, 12 insertions(+), 100 deletions(-) diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index 70df6b6cac8..4e9d21e98bb 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -123,7 +123,7 @@ type DeploymentSettings struct { // +kubebuilder:validation:Minimum=0 Replicas int32 `json:"replicas,omitempty"` - // Strategy describes the deployment strategy to use to replace existing pods with new ones. + // Strategy describes the deployment strategy to use to replace existing pods with new pods. // +optional Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` } diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 80a2a8e685e..9377ad55f09 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -865,7 +865,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only @@ -1118,7 +1118,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index 1b2283fc7e0..9601fbe4fa5 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1074,7 +1074,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only @@ -1327,7 +1327,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index c9c72ad4d4e..9a7a2d1daab 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -879,7 +879,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only @@ -1132,7 +1132,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index 63b5f8f14e2..6389332968e 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -14,7 +14,6 @@ # examples/contour/03-envoy.yaml # examples/gateway/00-crds.yaml # examples/gateway/00-namespace.yaml -# examples/gateway/01-admission_webhook_local.yaml # examples/gateway/01-admission_webhook.yaml # examples/gateway/02-certificate_config.yaml # examples/gateway/03-gatewayclass.yaml @@ -1081,7 +1080,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only @@ -1334,7 +1333,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only @@ -14307,93 +14306,6 @@ kind: Namespace metadata: name: gateway-system -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - name: gateway-api-admission -webhooks: - - name: validate.gateway.networking.k8s.io - matchPolicy: Equivalent - rules: - - operations: [ "CREATE" , "UPDATE" ] - apiGroups: [ "gateway.networking.k8s.io" ] - apiVersions: [ "v1alpha2", "v1beta1" ] - resources: [ "gateways", "gatewayclasses", "httproutes" ] - failurePolicy: Fail - sideEffects: None - admissionReviewVersions: - - v1 - clientConfig: - service: - name: gateway-api-admission-server - namespace: gateway-system - path: "/validate" ---- -apiVersion: v1 -kind: Service -metadata: - labels: - name: gateway-api-webhook-server - name: gateway-api-admission-server - namespace: gateway-system -spec: - type: ClusterIP - ports: - - name: https-webhook - port: 443 - targetPort: 8443 - selector: - name: gateway-api-admission-server ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: gateway-api-admission-server - namespace: gateway-system - labels: - name: gateway-api-admission-server -spec: - replicas: 1 - selector: - matchLabels: - name: gateway-api-admission-server - template: - metadata: - name: gateway-api-admission-server - labels: - name: gateway-api-admission-server - spec: - containers: - - name: webhook - image: release.daocloud.io/skoala/admission-server:v0.5.1 - imagePullPolicy: IfNotPresent - args: - - -logtostderr - - --tlsCertFile=/etc/certs/cert - - --tlsKeyFile=/etc/certs/key - - -v=10 - - 2>&1 - ports: - - containerPort: 8443 - name: webhook - resources: - limits: - memory: 50Mi - cpu: 100m - requests: - memory: 50Mi - cpu: 100m - volumeMounts: - - name: webhook-certs - mountPath: /etc/certs - readOnly: true - securityContext: - readOnlyRootFilesystem: true - volumes: - - name: webhook-certs - secret: - secretName: gateway-api-admission - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 9e4e5229370..2bb7e52378a 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1074,7 +1074,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only @@ -1327,7 +1327,7 @@ spec: type: integer strategy: description: Strategy describes the deployment strategy to - use to replace existing pods with new ones. + use to replace existing pods with new pods. properties: rollingUpdate: description: 'Rolling update config params. Present only diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index d071bef5b17..8faa8737d6f 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -5576,7 +5576,7 @@

DeploymentSettings (Optional) -

Strategy describes the deployment strategy to use to replace existing pods with new ones.

+

Strategy describes the deployment strategy to use to replace existing pods with new pods.

From 6eb880049646146e8a6aa9e7541da581bf97c303 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Mon, 7 Nov 2022 10:06:21 +0800 Subject: [PATCH 10/16] little refactor Signed-off-by: Gang Liu --- .../v1alpha1/contourdeployment.go | 8 +- .../unreleased/4713-izturn-deprecation.md | 5 + examples/contour/01-crds.yaml | 4 +- examples/render/contour-deployment.yaml | 4 +- .../render/contour-gateway-provisioner.yaml | 4 +- examples/render/contour-gateway.yaml | 92 ++++++++++++++++++- examples/render/contour.yaml | 4 +- internal/provisioner/controller/gateway.go | 8 +- internal/provisioner/model/model.go | 12 +-- .../objects/dataplane/dataplane.go | 4 +- .../objects/dataplane/dataplane_test.go | 4 +- .../objects/deployment/deployment.go | 2 +- .../objects/deployment/deployment_test.go | 2 +- .../docs/main/config/api-reference.html | 8 +- 14 files changed, 126 insertions(+), 35 deletions(-) create mode 100644 changelogs/unreleased/4713-izturn-deprecation.md diff --git a/apis/projectcontour/v1alpha1/contourdeployment.go b/apis/projectcontour/v1alpha1/contourdeployment.go index 4e9d21e98bb..cf1f5bea6d5 100644 --- a/apis/projectcontour/v1alpha1/contourdeployment.go +++ b/apis/projectcontour/v1alpha1/contourdeployment.go @@ -75,7 +75,7 @@ type ContourDeploymentSpec struct { // ContourSettings contains settings for the Contour part of the installation, // i.e. the xDS server/control plane and associated resources. type ContourSettings struct { - // Deprecated: Use `DeploymentSettings.Replicas`` instead. + // Deprecated: Use `DeploymentSettings.Replicas` instead. // // Replicas is the desired number of Contour replicas. If if unset, // defaults to 2. @@ -116,7 +116,7 @@ type ContourSettings struct { Deployment *DeploymentSettings `json:"deployment,omitempty"` } -// DeploymentSettings contains settings for the Deployment. +// DeploymentSettings contains settings for Deployment resources. type DeploymentSettings struct { // Replicas is the desired number of replicas. // @@ -128,7 +128,7 @@ type DeploymentSettings struct { Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"` } -// DaemonSetSettings contains settings for the DaemonSet. +// DaemonSetSettings contains settings for DaemonSet resources. type DaemonSetSettings struct { // Strategy describes the deployment strategy to use to replace existing DaemonSet pods with new pods. // +optional @@ -145,7 +145,7 @@ type EnvoySettings struct { // +optional WorkloadType WorkloadType `json:"workloadType,omitempty"` - // Deprecated: Use `DeploymentSettings.Replicas`` instead. + // Deprecated: Use `DeploymentSettings.Replicas` instead. // // Replicas is the desired number of Envoy replicas. If WorkloadType // is not "Deployment", this field is ignored. Otherwise, if unset, diff --git a/changelogs/unreleased/4713-izturn-deprecation.md b/changelogs/unreleased/4713-izturn-deprecation.md new file mode 100644 index 00000000000..0bc69db59bc --- /dev/null +++ b/changelogs/unreleased/4713-izturn-deprecation.md @@ -0,0 +1,5 @@ +# Deprecation & Removal Notices + +- The deprecated `ContourSettings.Replicas` set the contour replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the futrue. + +- The deprecated `EnvoySettings.Replicas` set the envoy replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the futrue. diff --git a/examples/contour/01-crds.yaml b/examples/contour/01-crds.yaml index 9377ad55f09..5c067d5589d 100644 --- a/examples/contour/01-crds.yaml +++ b/examples/contour/01-crds.yaml @@ -990,7 +990,7 @@ spec: type: array type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`." @@ -2874,7 +2874,7 @@ spec: Envoy pods. type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index 9601fbe4fa5..eaa960c9585 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -1199,7 +1199,7 @@ spec: type: array type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`." @@ -3083,7 +3083,7 @@ spec: Envoy pods. type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` diff --git a/examples/render/contour-gateway-provisioner.yaml b/examples/render/contour-gateway-provisioner.yaml index 9a7a2d1daab..58603832e31 100644 --- a/examples/render/contour-gateway-provisioner.yaml +++ b/examples/render/contour-gateway-provisioner.yaml @@ -1004,7 +1004,7 @@ spec: type: array type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`." @@ -2888,7 +2888,7 @@ spec: Envoy pods. type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index 6389332968e..e1f5389746b 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -14,6 +14,7 @@ # examples/contour/03-envoy.yaml # examples/gateway/00-crds.yaml # examples/gateway/00-namespace.yaml +# examples/gateway/01-admission_webhook_local.yaml # examples/gateway/01-admission_webhook.yaml # examples/gateway/02-certificate_config.yaml # examples/gateway/03-gatewayclass.yaml @@ -1205,7 +1206,7 @@ spec: type: array type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`." @@ -3089,7 +3090,7 @@ spec: Envoy pods. type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` @@ -14306,6 +14307,93 @@ kind: Namespace metadata: name: gateway-system +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: gateway-api-admission +webhooks: + - name: validate.gateway.networking.k8s.io + matchPolicy: Equivalent + rules: + - operations: [ "CREATE" , "UPDATE" ] + apiGroups: [ "gateway.networking.k8s.io" ] + apiVersions: [ "v1alpha2", "v1beta1" ] + resources: [ "gateways", "gatewayclasses", "httproutes" ] + failurePolicy: Fail + sideEffects: None + admissionReviewVersions: + - v1 + clientConfig: + service: + name: gateway-api-admission-server + namespace: gateway-system + path: "/validate" +--- +apiVersion: v1 +kind: Service +metadata: + labels: + name: gateway-api-webhook-server + name: gateway-api-admission-server + namespace: gateway-system +spec: + type: ClusterIP + ports: + - name: https-webhook + port: 443 + targetPort: 8443 + selector: + name: gateway-api-admission-server +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gateway-api-admission-server + namespace: gateway-system + labels: + name: gateway-api-admission-server +spec: + replicas: 1 + selector: + matchLabels: + name: gateway-api-admission-server + template: + metadata: + name: gateway-api-admission-server + labels: + name: gateway-api-admission-server + spec: + containers: + - name: webhook + image: release.daocloud.io/skoala/admission-server:v0.5.1 + imagePullPolicy: IfNotPresent + args: + - -logtostderr + - --tlsCertFile=/etc/certs/cert + - --tlsKeyFile=/etc/certs/key + - -v=10 + - 2>&1 + ports: + - containerPort: 8443 + name: webhook + resources: + limits: + memory: 50Mi + cpu: 100m + requests: + memory: 50Mi + cpu: 100m + volumeMounts: + - name: webhook-certs + mountPath: /etc/certs + readOnly: true + securityContext: + readOnlyRootFilesystem: true + volumes: + - name: webhook-certs + secret: + secretName: gateway-api-admission + --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/examples/render/contour.yaml b/examples/render/contour.yaml index 2bb7e52378a..f8629b1a798 100644 --- a/examples/render/contour.yaml +++ b/examples/render/contour.yaml @@ -1199,7 +1199,7 @@ spec: type: array type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Contour replicas. If if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` and this one is set, use `DeploymentSettings.Replicas`." @@ -3083,7 +3083,7 @@ spec: Envoy pods. type: object replicas: - description: "Deprecated: Use `DeploymentSettings.Replicas`` instead. + description: "Deprecated: Use `DeploymentSettings.Replicas` instead. \n Replicas is the desired number of Envoy replicas. If WorkloadType is not \"Deployment\", this field is ignored. Otherwise, if unset, defaults to 2. \n if both `DeploymentSettings.Replicas` diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 10f61ec5f7c..14c0e052eff 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -239,13 +239,11 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } if gatewayClassParams.Spec.Contour != nil { - // Deployment replicas if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Replicas > 0 { contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Deployment.Replicas } else if gatewayClassParams.Spec.Contour.Replicas > 0 { // nolint: staticcheck - // nolint: staticcheck contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas } @@ -270,7 +268,7 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Strategy != nil { - contourModel.Spec.ContourStrategy = *gatewayClassParams.Spec.Contour.Deployment.Strategy + contourModel.Spec.ContourDeploymentStrategy = *gatewayClassParams.Spec.Contour.Deployment.Strategy } } @@ -339,13 +337,13 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment && gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Strategy != nil { - contourModel.Spec.EnvoyStrategy = *gatewayClassParams.Spec.Envoy.Deployment.Strategy + contourModel.Spec.EnvoyDeploymentStrategy = *gatewayClassParams.Spec.Envoy.Deployment.Strategy } if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDaemonSet && gatewayClassParams.Spec.Envoy.DaemonSet != nil && gatewayClassParams.Spec.Envoy.DaemonSet.UpdateStrategy != nil { - contourModel.Spec.EnvoyUpdateStrategy = *gatewayClassParams.Spec.Envoy.DaemonSet.UpdateStrategy + contourModel.Spec.EnvoyDaemonSetUpdateStrategy = *gatewayClassParams.Spec.Envoy.DaemonSet.UpdateStrategy } } diff --git a/internal/provisioner/model/model.go b/internal/provisioner/model/model.go index 64fceedc449..729a03f2317 100644 --- a/internal/provisioner/model/model.go +++ b/internal/provisioner/model/model.go @@ -59,19 +59,19 @@ func Default(namespace, name string) *Contour { }, }, }, - EnvoyUpdateStrategy: appsv1.DaemonSetUpdateStrategy{ + EnvoyDaemonSetUpdateStrategy: appsv1.DaemonSetUpdateStrategy{ Type: appsv1.RollingUpdateDaemonSetStrategyType, RollingUpdate: &appsv1.RollingUpdateDaemonSet{ MaxUnavailable: opintstr.PointerTo(intstr.FromString("10%")), }, }, - EnvoyStrategy: appsv1.DeploymentStrategy{ + EnvoyDeploymentStrategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ MaxSurge: opintstr.PointerTo(intstr.FromString("10%")), }, }, - ContourStrategy: appsv1.DeploymentStrategy{ + ContourDeploymentStrategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, RollingUpdate: &appsv1.RollingUpdateDeployment{ MaxSurge: opintstr.PointerTo(intstr.FromString("50%")), @@ -197,15 +197,15 @@ type ContourSpec struct { // An update strategy to replace existing Envoy DaemonSet pods with new pods. // when envoy be running as a `Deployment`,it's must be nil // +optional - EnvoyUpdateStrategy appsv1.DaemonSetUpdateStrategy + EnvoyDaemonSetUpdateStrategy appsv1.DaemonSetUpdateStrategy // The deployment strategy to use to replace existing Envoy pods with new ones. // when envoy be running as a `DaemonSet`,it's must be nil - EnvoyStrategy appsv1.DeploymentStrategy + EnvoyDeploymentStrategy appsv1.DeploymentStrategy // The deployment strategy to use to replace existing Contour pods with new ones. // when envoy be running as a `DaemonSet`,it's must be nil - ContourStrategy appsv1.DeploymentStrategy + ContourDeploymentStrategy appsv1.DeploymentStrategy // ResourceLabels is a set of labels to add to the provisioned Contour resource(s). ResourceLabels map[string]string diff --git a/internal/provisioner/objects/dataplane/dataplane.go b/internal/provisioner/objects/dataplane/dataplane.go index 9de89795523..4a397f62225 100644 --- a/internal/provisioner/objects/dataplane/dataplane.go +++ b/internal/provisioner/objects/dataplane/dataplane.go @@ -328,7 +328,7 @@ func DesiredDaemonSet(contour *model.Contour, contourImage, envoyImage string) * RevisionHistoryLimit: pointer.Int32Ptr(int32(10)), // Ensure the deamonset adopts only its own pods. Selector: EnvoyPodSelector(contour), - UpdateStrategy: contour.Spec.EnvoyUpdateStrategy, + UpdateStrategy: contour.Spec.EnvoyDaemonSetUpdateStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ // TODO [danehans]: Remove the prometheus annotations when Contour is updated to @@ -401,7 +401,7 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) RevisionHistoryLimit: pointer.Int32Ptr(int32(10)), // Ensure the deamonset adopts only its own pods. Selector: EnvoyPodSelector(contour), - Strategy: contour.Spec.EnvoyStrategy, + Strategy: contour.Spec.EnvoyDeploymentStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ // TODO [danehans]: Remove the prometheus annotations when Contour is updated to diff --git a/internal/provisioner/objects/dataplane/dataplane_test.go b/internal/provisioner/objects/dataplane/dataplane_test.go index 6ece1fb3b46..b2cb9e32a0e 100644 --- a/internal/provisioner/objects/dataplane/dataplane_test.go +++ b/internal/provisioner/objects/dataplane/dataplane_test.go @@ -292,7 +292,7 @@ func TestDesiredDaemonSet(t *testing.T) { checkDaemonSetHasPodAnnotations(t, ds, envoyPodAnnotations(cntr)) checkDaemonSetHasResourceRequirements(t, ds, resQutoa) - checkDaemonSetHasUpdateStrategy(t, ds, cntr.Spec.EnvoyUpdateStrategy) + checkDaemonSetHasUpdateStrategy(t, ds, cntr.Spec.EnvoyDaemonSetUpdateStrategy) } func TestDesiredDeployment(t *testing.T) { @@ -302,7 +302,7 @@ func TestDesiredDeployment(t *testing.T) { testContourImage := "ghcr.io/projectcontour/contour:test" testEnvoyImage := "docker.io/envoyproxy/envoy:test" deploy := desiredDeployment(cntr, testContourImage, testEnvoyImage) - checkDeploymentHasStrategy(t, deploy.(*appsv1.Deployment), cntr.Spec.EnvoyStrategy) + checkDeploymentHasStrategy(t, deploy.(*appsv1.Deployment), cntr.Spec.EnvoyDeploymentStrategy) } diff --git a/internal/provisioner/objects/deployment/deployment.go b/internal/provisioner/objects/deployment/deployment.go index 44e7ec9651f..8ae8b4898df 100644 --- a/internal/provisioner/objects/deployment/deployment.go +++ b/internal/provisioner/objects/deployment/deployment.go @@ -202,7 +202,7 @@ func DesiredDeployment(contour *model.Contour, image string) *appsv1.Deployment RevisionHistoryLimit: pointer.Int32(10), // Ensure the deployment adopts only its own pods. Selector: ContourDeploymentPodSelector(contour), - Strategy: contour.Spec.ContourStrategy, + Strategy: contour.Spec.ContourDeploymentStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ // TODO [danehans]: Remove the prometheus annotations when Contour is updated to diff --git a/internal/provisioner/objects/deployment/deployment_test.go b/internal/provisioner/objects/deployment/deployment_test.go index 4c07a6de1a2..6c76d7cba04 100644 --- a/internal/provisioner/objects/deployment/deployment_test.go +++ b/internal/provisioner/objects/deployment/deployment_test.go @@ -195,7 +195,7 @@ func TestDesiredDeployment(t *testing.T) { checkDeploymentHasNodeSelector(t, deploy, nil) checkDeploymentHasTolerations(t, deploy, nil) checkDeploymentHasResourceRequirements(t, deploy, resQutoa) - checkDeploymentHasStrategy(t, deploy, cntr.Spec.ContourStrategy) + checkDeploymentHasStrategy(t, deploy, cntr.Spec.ContourDeploymentStrategy) } func TestNodePlacementDeployment(t *testing.T) { diff --git a/site/content/docs/main/config/api-reference.html b/site/content/docs/main/config/api-reference.html index 8faa8737d6f..1b385361ec9 100644 --- a/site/content/docs/main/config/api-reference.html +++ b/site/content/docs/main/config/api-reference.html @@ -5368,7 +5368,7 @@

ContourSettings (Optional) -

Deprecated: Use DeploymentSettings.Replicas` instead.

+

Deprecated: Use DeploymentSettings.Replicas instead.

Replicas is the desired number of Contour replicas. If if unset, defaults to 2.

if both DeploymentSettings.Replicas and this one is set, use DeploymentSettings.Replicas.

@@ -5460,7 +5460,7 @@

DaemonSetSettings EnvoySettings)

-

DaemonSetSettings contains settings for the DaemonSet.

+

DaemonSetSettings contains settings for DaemonSet resources.

@@ -5542,7 +5542,7 @@

DeploymentSettings EnvoySettings)

-

DeploymentSettings contains settings for the Deployment.

+

DeploymentSettings contains settings for Deployment resources.

@@ -6080,7 +6080,7 @@

EnvoySettings

(Optional) -

Deprecated: Use DeploymentSettings.Replicas` instead.

+

Deprecated: Use DeploymentSettings.Replicas instead.

Replicas is the desired number of Envoy replicas. If WorkloadType is not “Deployment”, this field is ignored. Otherwise, if unset, defaults to 2.

From caf39bb170f06d359b8481583daa36d62c89c9d7 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Mon, 7 Nov 2022 10:12:32 +0800 Subject: [PATCH 11/16] fix typo Signed-off-by: Gang Liu --- changelogs/unreleased/4713-izturn-deprecation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelogs/unreleased/4713-izturn-deprecation.md b/changelogs/unreleased/4713-izturn-deprecation.md index 0bc69db59bc..7f9e1cb193e 100644 --- a/changelogs/unreleased/4713-izturn-deprecation.md +++ b/changelogs/unreleased/4713-izturn-deprecation.md @@ -1,5 +1,5 @@ # Deprecation & Removal Notices -- The deprecated `ContourSettings.Replicas` set the contour replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the futrue. +- The deprecated `ContourSettings.Replicas` set the contour replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the future. -- The deprecated `EnvoySettings.Replicas` set the envoy replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the futrue. +- The deprecated `EnvoySettings.Replicas` set the envoy replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the future. From 9d5732b1ad0435764084ee08899bd3179c202aa7 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Tue, 8 Nov 2022 09:45:01 +0800 Subject: [PATCH 12/16] fix ut Signed-off-by: Gang Liu --- changelogs/unreleased/4713-izturn-deprecation.md | 6 +++--- internal/provisioner/objects/dataplane/dataplane_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelogs/unreleased/4713-izturn-deprecation.md b/changelogs/unreleased/4713-izturn-deprecation.md index 7f9e1cb193e..e2c96b861f3 100644 --- a/changelogs/unreleased/4713-izturn-deprecation.md +++ b/changelogs/unreleased/4713-izturn-deprecation.md @@ -1,5 +1,5 @@ -# Deprecation & Removal Notices +# ContourDeployment.Spec.Contour.Replicas and ContourDeployment.Spec.Envoy.Replicas are deprecated -- The deprecated `ContourSettings.Replicas` set the contour replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the future. +- `ContourDeployment.Spec.Contour.Replicas` is deprecated and has been replaced by `ContourDeployment.Spec.Contour.Deployment.Replicas`. Users should switch to using the new field. The deprecated field will be removed in a future release. See #4713 for additional details. -- The deprecated `EnvoySettings.Replicas` set the envoy replicas field is replaced by `DeploymentSettings.Replicas`. See #4713 for additional details. it will be remove in the future. +- `ContourDeployment.Spec.Envoy.Replicas` is deprecated and has been replaced by `ContourDeployment.Spec.Envoy.Deployment.Replicas`. Users should switch to using the new field. The deprecated field will be removed in a future release. See #4713 for additional details. diff --git a/internal/provisioner/objects/dataplane/dataplane_test.go b/internal/provisioner/objects/dataplane/dataplane_test.go index b2cb9e32a0e..bc839b924dc 100644 --- a/internal/provisioner/objects/dataplane/dataplane_test.go +++ b/internal/provisioner/objects/dataplane/dataplane_test.go @@ -302,7 +302,7 @@ func TestDesiredDeployment(t *testing.T) { testContourImage := "ghcr.io/projectcontour/contour:test" testEnvoyImage := "docker.io/envoyproxy/envoy:test" deploy := desiredDeployment(cntr, testContourImage, testEnvoyImage) - checkDeploymentHasStrategy(t, deploy.(*appsv1.Deployment), cntr.Spec.EnvoyDeploymentStrategy) + checkDeploymentHasStrategy(t, deploy, cntr.Spec.EnvoyDeploymentStrategy) } From 30b5836ac6c08c6f8597eb7c59bb34e3aa6add3b Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Tue, 8 Nov 2022 09:58:11 +0800 Subject: [PATCH 13/16] make check happy Signed-off-by: Gang Liu --- examples/render/contour-gateway.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index e1f5389746b..480015ddb4e 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -1162,7 +1162,7 @@ spec: pods are not scheduled onto inappropriate nodes. One or more taints are applied to a node; this marks that the node should not accept any pods that do not tolerate the taints. - \n The default is an empty list. \n See https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ + \n The default is an empty list.\n See https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ for additional details." items: description: The pod this Toleration is attached to tolerates From 1890466df2e58b842befac48caa1b72ed5e9fe3f Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Thu, 10 Nov 2022 08:27:23 +0800 Subject: [PATCH 14/16] make generate Signed-off-by: Gang Liu --- examples/render/contour-gateway.yaml | 90 +--------------------------- 1 file changed, 1 insertion(+), 89 deletions(-) diff --git a/examples/render/contour-gateway.yaml b/examples/render/contour-gateway.yaml index 480015ddb4e..1367e12c529 100644 --- a/examples/render/contour-gateway.yaml +++ b/examples/render/contour-gateway.yaml @@ -14,7 +14,6 @@ # examples/contour/03-envoy.yaml # examples/gateway/00-crds.yaml # examples/gateway/00-namespace.yaml -# examples/gateway/01-admission_webhook_local.yaml # examples/gateway/01-admission_webhook.yaml # examples/gateway/02-certificate_config.yaml # examples/gateway/03-gatewayclass.yaml @@ -1162,7 +1161,7 @@ spec: pods are not scheduled onto inappropriate nodes. One or more taints are applied to a node; this marks that the node should not accept any pods that do not tolerate the taints. - \n The default is an empty list.\n See https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ + \n The default is an empty list. \n See https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ for additional details." items: description: The pod this Toleration is attached to tolerates @@ -14307,93 +14306,6 @@ kind: Namespace metadata: name: gateway-system -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - name: gateway-api-admission -webhooks: - - name: validate.gateway.networking.k8s.io - matchPolicy: Equivalent - rules: - - operations: [ "CREATE" , "UPDATE" ] - apiGroups: [ "gateway.networking.k8s.io" ] - apiVersions: [ "v1alpha2", "v1beta1" ] - resources: [ "gateways", "gatewayclasses", "httproutes" ] - failurePolicy: Fail - sideEffects: None - admissionReviewVersions: - - v1 - clientConfig: - service: - name: gateway-api-admission-server - namespace: gateway-system - path: "/validate" ---- -apiVersion: v1 -kind: Service -metadata: - labels: - name: gateway-api-webhook-server - name: gateway-api-admission-server - namespace: gateway-system -spec: - type: ClusterIP - ports: - - name: https-webhook - port: 443 - targetPort: 8443 - selector: - name: gateway-api-admission-server ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: gateway-api-admission-server - namespace: gateway-system - labels: - name: gateway-api-admission-server -spec: - replicas: 1 - selector: - matchLabels: - name: gateway-api-admission-server - template: - metadata: - name: gateway-api-admission-server - labels: - name: gateway-api-admission-server - spec: - containers: - - name: webhook - image: release.daocloud.io/skoala/admission-server:v0.5.1 - imagePullPolicy: IfNotPresent - args: - - -logtostderr - - --tlsCertFile=/etc/certs/cert - - --tlsKeyFile=/etc/certs/key - - -v=10 - - 2>&1 - ports: - - containerPort: 8443 - name: webhook - resources: - limits: - memory: 50Mi - cpu: 100m - requests: - memory: 50Mi - cpu: 100m - volumeMounts: - - name: webhook-certs - mountPath: /etc/certs - readOnly: true - securityContext: - readOnlyRootFilesystem: true - volumes: - - name: webhook-certs - secret: - secretName: gateway-api-admission - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration From 5b91fb9f00e881b48fd5d0cc540a609149053084 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Wed, 16 Nov 2022 09:54:20 +0800 Subject: [PATCH 15/16] little refactor Signed-off-by: Gang Liu --- internal/provisioner/controller/gateway.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index 14c0e052eff..a536b58e322 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -239,13 +239,11 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } if gatewayClassParams.Spec.Contour != nil { + contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas // nolint:staticcheck + // Deployment replicas if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Replicas > 0 { contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Deployment.Replicas - - } else if gatewayClassParams.Spec.Contour.Replicas > 0 { // nolint: staticcheck - // nolint: staticcheck - contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas } // Node placement @@ -282,14 +280,11 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct // Deployment replicas if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment { + contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas // nolint:staticcheck + if gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Replicas > 0 { contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Deployment.Replicas - - } else if gatewayClassParams.Spec.Envoy.Replicas > 0 { //nolint: staticcheck - // nolint: staticcheck - contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas } - } // Network publishing From e0b0c12d6a1dda2d6c280b848297316693f92742 Mon Sep 17 00:00:00 2001 From: Gang Liu Date: Sun, 20 Nov 2022 09:59:24 +0800 Subject: [PATCH 16/16] check replicas before use it Signed-off-by: Gang Liu --- internal/provisioner/controller/gateway.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/provisioner/controller/gateway.go b/internal/provisioner/controller/gateway.go index a536b58e322..7c99e6716bf 100644 --- a/internal/provisioner/controller/gateway.go +++ b/internal/provisioner/controller/gateway.go @@ -239,7 +239,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } if gatewayClassParams.Spec.Contour != nil { - contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas // nolint:staticcheck + if gatewayClassParams.Spec.Contour.Replicas > 0 { // nolint:staticcheck + contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas // nolint:staticcheck + } // Deployment replicas if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Replicas > 0 { @@ -280,7 +282,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct // Deployment replicas if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment { - contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas // nolint:staticcheck + if gatewayClassParams.Spec.Envoy.Replicas > 0 { // nolint:staticcheck + contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas // nolint:staticcheck + } if gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Replicas > 0 { contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Deployment.Replicas