From 63c228203c81b6c02b4be91cce15e75329f1fe25 Mon Sep 17 00:00:00 2001 From: rajashree Date: Thu, 26 Mar 2020 14:07:03 -0700 Subject: [PATCH] Copy k8s updateStrategy structs --- apis/management.cattle.io/v3/rke_types.go | 11 +++--- apis/management.cattle.io/v3/schema/schema.go | 4 +- .../v3/update_strategy_types.go | 38 +++++++++++++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 apis/management.cattle.io/v3/update_strategy_types.go diff --git a/apis/management.cattle.io/v3/rke_types.go b/apis/management.cattle.io/v3/rke_types.go index 98ae1457..7eab0294 100644 --- a/apis/management.cattle.io/v3/rke_types.go +++ b/apis/management.cattle.io/v3/rke_types.go @@ -2,7 +2,6 @@ package v3 import ( "github.com/rancher/norman/types" - appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apiserverv1alpha1 "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1" @@ -384,7 +383,7 @@ type NetworkConfig struct { // NodeSelector key pair NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"` // Network plugin daemonset upgrade strategy - UpdateStrategy *appsv1.DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` + UpdateStrategy *DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` } type AuthWebhookConfig struct { @@ -428,7 +427,7 @@ type IngressConfig struct { // Extra volume mounts ExtraVolumeMounts []ExtraVolumeMount `yaml:"extra_volume_mounts" json:"extraVolumeMounts,omitempty" norman:"type=array[json]"` // nginx daemonset upgrade strategy - UpdateStrategy *appsv1.DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` + UpdateStrategy *DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` } type ExtraEnv struct { @@ -816,7 +815,7 @@ type MonitoringConfig struct { // NodeSelector key pair NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"` // Update strategy - UpdateStrategy *appsv1.DeploymentStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` + UpdateStrategy *DeploymentStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` // Number of monitoring addon pods Replicas *int32 `yaml:"replicas" json:"replicas,omitempty" norman:"default=1"` } @@ -846,7 +845,7 @@ type DNSConfig struct { // Nodelocal DNS Nodelocal *Nodelocal `yaml:"nodelocal" json:"nodelocal,omitempy"` // Update strategy - UpdateStrategy *appsv1.DeploymentStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` + UpdateStrategy *DeploymentStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` // Autoscaler fields to determine number of dns replicas LinearAutoscalerParams *LinearAutoscalerParams `yaml:"linear_autoscaler_params" json:"linearAutoscalerParams,omitempty"` } @@ -855,7 +854,7 @@ type Nodelocal struct { // link-local IP for nodelocal DNS IPAddress string `yaml:"ip_address" json:"ipAddress,omitempy"` // Nodelocal DNS daemonset upgrade strategy - UpdateStrategy *appsv1.DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` + UpdateStrategy *DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"` // NodeSelector key pair NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"` } diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index e6903433..d2756964 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -72,7 +72,9 @@ func rkeTypes(schemas *types.Schemas) *types.Schemas { MustImport(&Version, v3.ExtraEnv{}). MustImport(&Version, v3.ExtraVolume{}). MustImport(&Version, v3.ExtraVolumeMount{}). - MustImport(&Version, v3.LinearAutoscalerParams{}) + MustImport(&Version, v3.LinearAutoscalerParams{}). + MustImport(&Version, v3.DeploymentStrategy{}). + MustImport(&Version, v3.DaemonSetUpdateStrategy{}) } func schemaTypes(schemas *types.Schemas) *types.Schemas { diff --git a/apis/management.cattle.io/v3/update_strategy_types.go b/apis/management.cattle.io/v3/update_strategy_types.go new file mode 100644 index 00000000..0f019b70 --- /dev/null +++ b/apis/management.cattle.io/v3/update_strategy_types.go @@ -0,0 +1,38 @@ +package v3 + +import ( + appsv1 "k8s.io/api/apps/v1" +) + +/* All fields in this file are copied over from apps/v1. Referencing k8s fields caused problems because of the "Type" field in +DeploymentStrategy and DaemonSetUpdateStrategy*/ + +// DeploymentStrategy describes how to replace existing pods with new ones. +type DeploymentStrategy struct { + // Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate. + // +optional + Strategy appsv1.DeploymentStrategyType `json:"strategy,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"` + + // Rolling update config params. Present only if DeploymentStrategyType = + // RollingUpdate. + //--- + // TODO: Update this to follow our convention for oneOf, whatever we decide it + // to be. + // +optional + RollingUpdate *appsv1.RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"` +} + +// DaemonSetUpdateStrategy is a struct used to control the update strategy for a DaemonSet. +type DaemonSetUpdateStrategy struct { + // Type of daemon set update. Can be "RollingUpdate" or "OnDelete". Default is RollingUpdate. + // +optional + Strategy appsv1.DaemonSetUpdateStrategyType `json:"strategy,omitempty" protobuf:"bytes,1,opt,name=type"` + + // 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 + // +optional + RollingUpdate *appsv1.RollingUpdateDaemonSet `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"` +}