From ab1a5b53ab969223c5e89b35749d6844f771eb2f Mon Sep 17 00:00:00 2001 From: Paulo Pires Date: Wed, 1 Feb 2017 11:41:54 +0000 Subject: [PATCH] kubeadm: set maxUnavailable and maxSurge for self-hosted component deployments. Refs https://github.com/kubernetes/kubeadm/issues/127 --- cmd/kubeadm/app/master/selfhosted.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cmd/kubeadm/app/master/selfhosted.go b/cmd/kubeadm/app/master/selfhosted.go index f07dd09bd4753..df8c8703b079e 100644 --- a/cmd/kubeadm/app/master/selfhosted.go +++ b/cmd/kubeadm/app/master/selfhosted.go @@ -24,6 +24,7 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/wait" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" "k8s.io/kubernetes/cmd/kubeadm/app/images" @@ -32,6 +33,12 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" ) +var ( + // maximum unavailable and surge instances per self-hosted component deployment + maxUnavailable = intstr.FromInt(0) + maxSurge = intstr.FromInt(1) +) + func CreateSelfHostedControlPlane(cfg *kubeadmapi.MasterConfiguration, client *clientset.Clientset) error { volumes := []v1.Volume{k8sVolume(cfg)} volumeMounts := []v1.VolumeMount{k8sVolumeMount()} @@ -234,6 +241,13 @@ func getControllerManagerDeployment(cfg *kubeadmapi.MasterConfiguration, volumes }, Spec: ext.DeploymentSpec{ // TODO bootkube uses 2 replicas + Strategy: ext.DeploymentStrategy{ + Type: ext.RollingUpdateDeploymentStrategyType, + RollingUpdate: &ext.RollingUpdateDeployment{ + MaxUnavailable: &maxUnavailable, + MaxSurge: &maxSurge, + }, + }, Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ @@ -281,6 +295,13 @@ func getSchedulerDeployment(cfg *kubeadmapi.MasterConfiguration) ext.Deployment }, Spec: ext.DeploymentSpec{ // TODO bootkube uses 2 replicas + Strategy: ext.DeploymentStrategy{ + Type: ext.RollingUpdateDeploymentStrategyType, + RollingUpdate: &ext.RollingUpdateDeployment{ + MaxUnavailable: &maxUnavailable, + MaxSurge: &maxSurge, + }, + }, Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{