diff --git a/bindata/v3.11.0/kube-controller-manager/pod.yaml b/bindata/v3.11.0/kube-controller-manager/pod.yaml index 55a9bbd0e..f1e198d37 100644 --- a/bindata/v3.11.0/kube-controller-manager/pod.yaml +++ b/bindata/v3.11.0/kube-controller-manager/pod.yaml @@ -8,6 +8,18 @@ metadata: kube-controller-manager: "true" revision: "REVISION" spec: + initContainers: + - name: wait-for-host-port + image: ${IMAGE} + imagePullPolicy: IfNotPresent + command: ['/usr/bin/timeout', '100', "/bin/bash", "-c"] # 60 sec for graceful termination, 35 for minimum-termination-duration + args: + - | + echo -n "Waiting for port :10257 to be released." + while [ -n "$(lsof -ni :10257)" ]; do + echo -n "." + sleep 1 + done containers: - name: kube-controller-manager-REVISION image: ${IMAGE} diff --git a/pkg/operator/targetconfigcontroller/targetconfigcontroller.go b/pkg/operator/targetconfigcontroller/targetconfigcontroller.go index c8d32e594..3333ce370 100644 --- a/pkg/operator/targetconfigcontroller/targetconfigcontroller.go +++ b/pkg/operator/targetconfigcontroller/targetconfigcontroller.go @@ -202,21 +202,27 @@ func manageKubeControllerManagerConfig(client corev1client.ConfigMapsGetter, rec func managePod(client corev1client.ConfigMapsGetter, recorder events.Recorder, operatorConfig *operatorv1.KubeControllerManager, imagePullSpec string) (*corev1.ConfigMap, bool, error) { required := resourceread.ReadPodV1OrDie(v311_00_assets.MustAsset("v3.11.0/kube-controller-manager/pod.yaml")) + // TODO: If the image pull spec is not specified, the "${IMAGE}" will be used as value and the pod will fail to start. if len(imagePullSpec) > 0 { required.Spec.Containers[0].Image = imagePullSpec + if len(required.Spec.InitContainers) > 0 { + required.Spec.InitContainers[0].Image = imagePullSpec + } } + var v int switch operatorConfig.Spec.LogLevel { case operatorv1.Normal: - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("-v=%d", 2)) + v = 2 case operatorv1.Debug: - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("-v=%d", 4)) + v = 4 case operatorv1.Trace: - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("-v=%d", 6)) + v = 6 case operatorv1.TraceAll: - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("-v=%d", 8)) + v = 8 default: - required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("-v=%d", 2)) + v = 2 } + required.Spec.Containers[0].Args = append(required.Spec.Containers[0].Args, fmt.Sprintf("-v=%d", v)) configMap := resourceread.ReadConfigMapV1OrDie(v311_00_assets.MustAsset("v3.11.0/kube-controller-manager/pod-cm.yaml")) configMap.Data["pod.yaml"] = resourceread.WritePodV1OrDie(required) diff --git a/pkg/operator/v311_00_assets/bindata.go b/pkg/operator/v311_00_assets/bindata.go index d20d59eff..246427d11 100644 --- a/pkg/operator/v311_00_assets/bindata.go +++ b/pkg/operator/v311_00_assets/bindata.go @@ -303,6 +303,18 @@ metadata: kube-controller-manager: "true" revision: "REVISION" spec: + initContainers: + - name: wait-for-host-port + image: ${IMAGE} + imagePullPolicy: IfNotPresent + command: ['/usr/bin/timeout', '100', "/bin/bash", "-c"] # 60 sec for graceful termination, 35 for minimum-termination-duration + args: + - | + echo -n "Waiting for port :10257 to be released." + while [ -n "$(lsof -ni :10257)" ]; do + echo -n "." + sleep 1 + done containers: - name: kube-controller-manager-REVISION image: ${IMAGE}