diff --git a/cmd/kubeadm/app/phases/controlplane/manifests.go b/cmd/kubeadm/app/phases/controlplane/manifests.go index 1c57110171f..42725d8dab8 100644 --- a/cmd/kubeadm/app/phases/controlplane/manifests.go +++ b/cmd/kubeadm/app/phases/controlplane/manifests.go @@ -63,9 +63,9 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap ImagePullPolicy: v1.PullIfNotPresent, Command: getAPIServerCommand(cfg, endpoint), VolumeMounts: staticpodutil.VolumeMountMapToSlice(mounts.GetVolumeMounts(kubeadmconstants.KubeAPIServer)), - LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", int(endpoint.BindPort), v1.URISchemeHTTPS), - ReadinessProbe: staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", int(endpoint.BindPort), v1.URISchemeHTTPS), - StartupProbe: staticpodutil.StartupProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", int(endpoint.BindPort), v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane), + LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", endpoint.BindPort, v1.URISchemeHTTPS), + ReadinessProbe: staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", endpoint.BindPort, v1.URISchemeHTTPS), + StartupProbe: staticpodutil.StartupProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", endpoint.BindPort, v1.URISchemeHTTPS, cfg.APIServer.TimeoutForControlPlane), Resources: staticpodutil.ComponentResources("250m"), Env: kubeadmutil.MergeEnv(proxyEnvs, cfg.APIServer.ExtraEnvs), }, mounts.GetVolumes(kubeadmconstants.KubeAPIServer), diff --git a/cmd/kubeadm/app/util/staticpod/utils.go b/cmd/kubeadm/app/util/staticpod/utils.go index 4f74e7e84ed..cab4feb16bf 100644 --- a/cmd/kubeadm/app/util/staticpod/utils.go +++ b/cmd/kubeadm/app/util/staticpod/utils.go @@ -242,20 +242,20 @@ func ReadStaticPodFromDisk(manifestPath string) (*v1.Pod, error) { } // LivenessProbe creates a Probe object with a HTTPGet handler -func LivenessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe { +func LivenessProbe(host, path string, port int32, scheme v1.URIScheme) *v1.Probe { // sets initialDelaySeconds same as periodSeconds to skip one period before running a check return createHTTPProbe(host, path, port, scheme, 10, 15, 8, 10) } // ReadinessProbe creates a Probe object with a HTTPGet handler -func ReadinessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe { +func ReadinessProbe(host, path string, port int32, scheme v1.URIScheme) *v1.Probe { // sets initialDelaySeconds as '0' because we don't want to delay user infrastructure checks // looking for "ready" status on kubeadm static Pods return createHTTPProbe(host, path, port, scheme, 0, 15, 3, 1) } // StartupProbe creates a Probe object with a HTTPGet handler -func StartupProbe(host, path string, port int, scheme v1.URIScheme, timeoutForControlPlane *metav1.Duration) *v1.Probe { +func StartupProbe(host, path string, port int32, scheme v1.URIScheme, timeoutForControlPlane *metav1.Duration) *v1.Probe { periodSeconds, timeoutForControlPlaneSeconds := int32(10), kubeadmconstants.DefaultControlPlaneTimeout.Seconds() if timeoutForControlPlane != nil { timeoutForControlPlaneSeconds = timeoutForControlPlane.Seconds() @@ -267,13 +267,13 @@ func StartupProbe(host, path string, port int, scheme v1.URIScheme, timeoutForCo return createHTTPProbe(host, path, port, scheme, periodSeconds, 15, failureThreshold, periodSeconds) } -func createHTTPProbe(host, path string, port int, scheme v1.URIScheme, initialDelaySeconds, timeoutSeconds, failureThreshold, periodSeconds int32) *v1.Probe { +func createHTTPProbe(host, path string, port int32, scheme v1.URIScheme, initialDelaySeconds, timeoutSeconds, failureThreshold, periodSeconds int32) *v1.Probe { return &v1.Probe{ ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Host: host, Path: path, - Port: intstr.FromInt(port), + Port: intstr.FromInt32(port), Scheme: scheme, }, }, @@ -312,7 +312,7 @@ func GetSchedulerProbeAddress(cfg *kubeadmapi.ClusterConfiguration) string { // GetEtcdProbeEndpoint takes a kubeadm Etcd configuration object and attempts to parse // the first URL in the listen-metrics-urls argument, returning an etcd probe hostname, // port and scheme -func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int, v1.URIScheme) { +func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int32, v1.URIScheme) { localhost := "127.0.0.1" if isIPv6 { localhost = "::1" @@ -346,7 +346,7 @@ func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int, v1.UR port = p } } - return hostname, port, scheme + return hostname, int32(port), scheme } return localhost, kubeadmconstants.EtcdMetricsPort, v1.URISchemeHTTP } diff --git a/cmd/kubeadm/app/util/staticpod/utils_test.go b/cmd/kubeadm/app/util/staticpod/utils_test.go index 8f7b2461cdc..bcea14876d1 100644 --- a/cmd/kubeadm/app/util/staticpod/utils_test.go +++ b/cmd/kubeadm/app/util/staticpod/utils_test.go @@ -244,7 +244,7 @@ func TestGetEtcdProbeEndpoint(t *testing.T) { cfg *kubeadmapi.Etcd isIPv6 bool expectedHostname string - expectedPort int + expectedPort int32 expectedScheme v1.URIScheme }{ { diff --git a/pkg/apis/apps/v1/defaults_test.go b/pkg/apis/apps/v1/defaults_test.go index 9028a3bef54..d5683252b2c 100644 --- a/pkg/apis/apps/v1/defaults_test.go +++ b/pkg/apis/apps/v1/defaults_test.go @@ -176,7 +176,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { } func getMaxUnavailable(maxUnavailable int) *intstr.IntOrString { - maxUnavailableIntOrStr := intstr.FromInt(maxUnavailable) + maxUnavailableIntOrStr := intstr.FromInt32(int32(maxUnavailable)) return &maxUnavailableIntOrStr } diff --git a/pkg/apis/apps/v1beta1/defaults_test.go b/pkg/apis/apps/v1beta1/defaults_test.go index 6c6e24369ac..086b652174c 100644 --- a/pkg/apis/apps/v1beta1/defaults_test.go +++ b/pkg/apis/apps/v1beta1/defaults_test.go @@ -532,6 +532,6 @@ func getPartition(partition int32) *int32 { } func getMaxUnavailable(maxUnavailable int) *intstr.IntOrString { - maxUnavailableIntOrStr := intstr.FromInt(maxUnavailable) + maxUnavailableIntOrStr := intstr.FromInt32(int32(maxUnavailable)) return &maxUnavailableIntOrStr } diff --git a/pkg/apis/apps/v1beta2/defaults_test.go b/pkg/apis/apps/v1beta2/defaults_test.go index 11a24389c07..acf05c15466 100644 --- a/pkg/apis/apps/v1beta2/defaults_test.go +++ b/pkg/apis/apps/v1beta2/defaults_test.go @@ -176,7 +176,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) { } func getMaxUnavailable(maxUnavailable int) *intstr.IntOrString { - maxUnavailableIntOrStr := intstr.FromInt(maxUnavailable) + maxUnavailableIntOrStr := intstr.FromInt32(int32(maxUnavailable)) return &maxUnavailableIntOrStr } diff --git a/pkg/apis/core/validation/validation_test.go b/pkg/apis/core/validation/validation_test.go index b19ac05f14b..b40e8ad54df 100644 --- a/pkg/apis/core/validation/validation_test.go +++ b/pkg/apis/core/validation/validation_test.go @@ -8197,7 +8197,7 @@ func TestValidateInitContainers(t *testing.T) { StartupProbe: &core.Probe{ ProbeHandler: core.ProbeHandler{ TCPSocket: &core.TCPSocketAction{ - Port: intstr.FromInt(80), + Port: intstr.FromInt32(80), }, }, SuccessThreshold: 1, @@ -8413,7 +8413,7 @@ func TestValidateInitContainers(t *testing.T) { RestartPolicy: &containerRestartPolicyAlways, StartupProbe: &core.Probe{ ProbeHandler: core.ProbeHandler{ - TCPSocket: &core.TCPSocketAction{Port: intstr.FromInt(80)}, + TCPSocket: &core.TCPSocketAction{Port: intstr.FromInt32(80)}, }, SuccessThreshold: 2, }, diff --git a/pkg/controller/daemon/update_test.go b/pkg/controller/daemon/update_test.go index 74c74fe9b14..86f9ae7fb5c 100644 --- a/pkg/controller/daemon/update_test.go +++ b/pkg/controller/daemon/update_test.go @@ -48,7 +48,7 @@ func TestDaemonSetUpdatesPods(t *testing.T) { ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2" ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType - intStr := intstr.FromInt(maxUnavailable) + intStr := intstr.FromInt32(int32(maxUnavailable)) ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr} manager.dsStore.Update(ds) @@ -90,7 +90,7 @@ func TestDaemonSetUpdatesPodsWithMaxSurge(t *testing.T) { // surge is thhe controlling amount maxSurge := 2 ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2" - ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt(maxSurge)) + ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt32(int32(maxSurge))) manager.dsStore.Update(ds) clearExpectations(t, manager, ds, podControl) @@ -135,7 +135,7 @@ func TestDaemonSetUpdatesWhenNewPosIsNotReady(t *testing.T) { ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2" ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType - intStr := intstr.FromInt(maxUnavailable) + intStr := intstr.FromInt32(int32(maxUnavailable)) ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr} err = manager.dsStore.Update(ds) if err != nil { @@ -171,7 +171,7 @@ func TestDaemonSetUpdatesAllOldPodsNotReady(t *testing.T) { ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2" ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType - intStr := intstr.FromInt(maxUnavailable) + intStr := intstr.FromInt32(int32(maxUnavailable)) ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr} err = manager.dsStore.Update(ds) if err != nil { @@ -203,7 +203,7 @@ func TestDaemonSetUpdatesAllOldPodsNotReadyMaxSurge(t *testing.T) { maxSurge := 3 ds.Spec.Template.Spec.Containers[0].Image = "foo2/bar2" - ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt(maxSurge)) + ds.Spec.UpdateStrategy = newUpdateSurge(intstr.FromInt32(int32(maxSurge))) manager.dsStore.Update(ds) // all old pods are unavailable so should be surged @@ -347,7 +347,7 @@ func TestDaemonSetUpdatesNoTemplateChanged(t *testing.T) { expectSyncDaemonSets(t, manager, ds, podControl, 5, 0, 0) ds.Spec.UpdateStrategy.Type = apps.RollingUpdateDaemonSetStrategyType - intStr := intstr.FromInt(maxUnavailable) + intStr := intstr.FromInt32(int32(maxUnavailable)) ds.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateDaemonSet{MaxUnavailable: &intStr} manager.dsStore.Update(ds) diff --git a/pkg/controller/deployment/sync_test.go b/pkg/controller/deployment/sync_test.go index f5f2f899d3f..b7605257bd9 100644 --- a/pkg/controller/deployment/sync_test.go +++ b/pkg/controller/deployment/sync_test.go @@ -35,7 +35,7 @@ import ( ) func intOrStrP(val int) *intstr.IntOrString { - intOrStr := intstr.FromInt(val) + intOrStr := intstr.FromInt32(int32(val)) return &intOrStr } diff --git a/pkg/controller/deployment/util/deployment_util_test.go b/pkg/controller/deployment/util/deployment_util_test.go index 42c7bbf4377..c0f2f33a96e 100644 --- a/pkg/controller/deployment/util/deployment_util_test.go +++ b/pkg/controller/deployment/util/deployment_util_test.go @@ -516,11 +516,11 @@ func TestNewRSNewReplicas(t *testing.T) { newDeployment.Spec.Strategy = apps.DeploymentStrategy{Type: test.strategyType} newDeployment.Spec.Strategy.RollingUpdate = &apps.RollingUpdateDeployment{ MaxUnavailable: func(i int) *intstr.IntOrString { - x := intstr.FromInt(i) + x := intstr.FromInt32(int32(i)) return &x }(1), MaxSurge: func(i int) *intstr.IntOrString { - x := intstr.FromInt(i) + x := intstr.FromInt32(int32(i)) return &x }(test.maxSurge), } @@ -705,8 +705,8 @@ func TestDeploymentComplete(t *testing.T) { Replicas: &desired, Strategy: apps.DeploymentStrategy{ RollingUpdate: &apps.RollingUpdateDeployment{ - MaxUnavailable: func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(maxUnavailable)), - MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(maxSurge)), + MaxUnavailable: func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(maxUnavailable)), + MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(maxSurge)), }, Type: apps.RollingUpdateDeploymentStrategyType, }, @@ -960,7 +960,7 @@ func TestMaxUnavailable(t *testing.T) { Replicas: func(i int32) *int32 { return &i }(replicas), Strategy: apps.DeploymentStrategy{ RollingUpdate: &apps.RollingUpdateDeployment{ - MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(1)), + MaxSurge: func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(1)), MaxUnavailable: &maxUnavailable, }, Type: apps.RollingUpdateDeploymentStrategyType, @@ -1255,7 +1255,7 @@ func TestGetDeploymentsForReplicaSet(t *testing.T) { } func TestMinAvailable(t *testing.T) { - maxSurge := func(i int) *intstr.IntOrString { x := intstr.FromInt(i); return &x }(int(1)) + maxSurge := func(i int) *intstr.IntOrString { x := intstr.FromInt32(int32(i)); return &x }(int(1)) deployment := func(replicas int32, maxUnavailable intstr.IntOrString) *apps.Deployment { return &apps.Deployment{ Spec: apps.DeploymentSpec{ diff --git a/pkg/controlplane/controller/kubernetesservice/controller.go b/pkg/controlplane/controller/kubernetesservice/controller.go index bfee9fa8555..4966eb9738b 100644 --- a/pkg/controlplane/controller/kubernetesservice/controller.go +++ b/pkg/controlplane/controller/kubernetesservice/controller.go @@ -184,7 +184,7 @@ func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort i Protocol: corev1.ProtocolTCP, Port: int32(servicePort), Name: servicePortName, - TargetPort: intstr.FromInt(targetServicePort), + TargetPort: intstr.FromInt32(int32(targetServicePort)), }} serviceType := corev1.ServiceTypeClusterIP if nodePort > 0 { diff --git a/pkg/kubelet/lifecycle/handlers_test.go b/pkg/kubelet/lifecycle/handlers_test.go index 0e6bc0459be..a6d095add38 100644 --- a/pkg/kubelet/lifecycle/handlers_test.go +++ b/pkg/kubelet/lifecycle/handlers_test.go @@ -45,7 +45,7 @@ import ( func TestResolvePortInt(t *testing.T) { expected := 80 - port, err := resolvePort(intstr.FromInt(expected), &v1.Container{}) + port, err := resolvePort(intstr.FromInt32(int32(expected)), &v1.Container{}) if port != expected { t.Errorf("expected: %d, saw: %d", expected, port) } diff --git a/pkg/kubelet/prober/scale_test.go b/pkg/kubelet/prober/scale_test.go index 6de9687e183..0b8b003d6f3 100644 --- a/pkg/kubelet/prober/scale_test.go +++ b/pkg/kubelet/prober/scale_test.go @@ -257,14 +257,14 @@ func (f *fakePod) probeHandler() v1.ProbeHandler { handler = v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Host: "127.0.0.1", - Port: intstr.FromInt(port), + Port: intstr.FromInt32(int32(port)), }, } } else { handler = v1.ProbeHandler{ TCPSocket: &v1.TCPSocketAction{ Host: "127.0.0.1", - Port: intstr.FromInt(port), + Port: intstr.FromInt32(int32(port)), }, } } diff --git a/pkg/proxy/iptables/number_generated_rules_test.go b/pkg/proxy/iptables/number_generated_rules_test.go index b4cc25ce597..4d75bdee878 100644 --- a/pkg/proxy/iptables/number_generated_rules_test.go +++ b/pkg/proxy/iptables/number_generated_rules_test.go @@ -414,7 +414,7 @@ func generateServiceEndpoints(nServices, nEndpoints int, epsFunc func(eps *disco Name: fmt.Sprintf("%d", epPort), Protocol: v1.ProtocolTCP, Port: int32(basePort + i), - TargetPort: intstr.FromInt(epPort), + TargetPort: intstr.FromInt32(int32(epPort)), }, } diff --git a/pkg/proxy/iptables/proxier_test.go b/pkg/proxy/iptables/proxier_test.go index 831fb1b6a30..7da8ac5af0f 100644 --- a/pkg/proxy/iptables/proxier_test.go +++ b/pkg/proxy/iptables/proxier_test.go @@ -2623,7 +2623,7 @@ func TestExternalIPsReject(t *testing.T) { Name: svcPortName.Port, Port: int32(svcPort), Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(svcPort), + TargetPort: intstr.FromInt32(int32(svcPort)), }} }), ) @@ -2698,7 +2698,7 @@ func TestOnlyLocalExternalIPs(t *testing.T) { Name: svcPortName.Port, Port: int32(svcPort), Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(svcPort), + TargetPort: intstr.FromInt32(int32(svcPort)), }} }), ) @@ -2810,7 +2810,7 @@ func TestNonLocalExternalIPs(t *testing.T) { Name: svcPortName.Port, Port: int32(svcPort), Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(svcPort), + TargetPort: intstr.FromInt32(int32(svcPort)), }} }), ) @@ -3932,7 +3932,7 @@ func addTestPort(array []v1.ServicePort, name string, protocol v1.Protocol, port Protocol: protocol, Port: port, NodePort: nodeport, - TargetPort: intstr.FromInt(targetPort), + TargetPort: intstr.FromInt32(int32(targetPort)), } return append(array, svcPort) } diff --git a/pkg/proxy/ipvs/proxier_test.go b/pkg/proxy/ipvs/proxier_test.go index 22a1b84e638..5fa41441885 100644 --- a/pkg/proxy/ipvs/proxier_test.go +++ b/pkg/proxy/ipvs/proxier_test.go @@ -1743,7 +1743,7 @@ func TestExternalIPsNoEndpoint(t *testing.T) { Name: svcPortName.Port, Port: int32(svcPort), Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(svcPort), + TargetPort: intstr.FromInt32(int32(svcPort)), }} }), ) @@ -1795,7 +1795,7 @@ func TestExternalIPs(t *testing.T) { Name: svcPortName.Port, Port: int32(svcPort), Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(svcPort), + TargetPort: intstr.FromInt32(int32(svcPort)), }} }), ) @@ -1866,7 +1866,7 @@ func TestOnlyLocalExternalIPs(t *testing.T) { Name: svcPortName.Port, Port: int32(svcPort), Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(svcPort), + TargetPort: intstr.FromInt32(int32(svcPort)), }} svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyLocal }), @@ -2476,7 +2476,7 @@ func addTestPort(array []v1.ServicePort, name string, protocol v1.Protocol, port Protocol: protocol, Port: port, NodePort: nodeport, - TargetPort: intstr.FromInt(targetPort), + TargetPort: intstr.FromInt32(int32(targetPort)), } return append(array, svcPort) } diff --git a/pkg/proxy/service_test.go b/pkg/proxy/service_test.go index a54d2d0876b..32c5541d501 100644 --- a/pkg/proxy/service_test.go +++ b/pkg/proxy/service_test.go @@ -67,7 +67,7 @@ func addTestPort(array []v1.ServicePort, name string, protocol v1.Protocol, port Protocol: protocol, Port: port, NodePort: nodeport, - TargetPort: intstr.FromInt(targetPort), + TargetPort: intstr.FromInt32(int32(targetPort)), } return append(array, svcPort) } diff --git a/pkg/registry/apps/statefulset/strategy_test.go b/pkg/registry/apps/statefulset/strategy_test.go index e46cb62fb6e..fabd90fa896 100644 --- a/pkg/registry/apps/statefulset/strategy_test.go +++ b/pkg/registry/apps/statefulset/strategy_test.go @@ -308,7 +308,7 @@ func generateStatefulSetWithMinReadySeconds(minReadySeconds int32) *apps.Statefu func makeStatefulSetWithMaxUnavailable(maxUnavailable *int) *apps.StatefulSet { rollingUpdate := apps.RollingUpdateStatefulSetStrategy{} if maxUnavailable != nil { - maxUnavailableIntStr := intstr.FromInt(*maxUnavailable) + maxUnavailableIntStr := intstr.FromInt32(int32(*maxUnavailable)) rollingUpdate = apps.RollingUpdateStatefulSetStrategy{ MaxUnavailable: &maxUnavailableIntStr, } diff --git a/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go b/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go index 0ea88156bef..f358c794d10 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go @@ -72,14 +72,14 @@ func FromString(val string) IntOrString { return IntOrString{Type: String, StrVal: val} } -// Parse the given string and try to convert it to an integer before +// Parse the given string and try to convert it to an int32 integer before // setting it as a string value. func Parse(val string) IntOrString { - i, err := strconv.Atoi(val) + i, err := strconv.ParseInt(val, 10, 32) if err != nil { return FromString(val) } - return FromInt(i) + return FromInt32(int32(i)) } // UnmarshalJSON implements the json.Unmarshaller interface. diff --git a/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go b/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go index b37b023ab99..62909f88230 100644 --- a/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go +++ b/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go @@ -100,7 +100,7 @@ func tweakAddLBIngress(ip string) serviceTweak { func makeServicePort(protocol v1.Protocol, targetPort int) []v1.ServicePort { sp := v1.ServicePort{Port: 80, Protocol: protocol} if targetPort > 0 { - sp.TargetPort = intstr.FromInt(targetPort) + sp.TargetPort = intstr.FromInt32(int32(targetPort)) } return []v1.ServicePort{sp} } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go index f8b20067651..e624d5c1466 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go @@ -1709,13 +1709,13 @@ func TestGenerateService(t *testing.T) { Name: "port-1-tcp", Port: 53, Protocol: corev1.ProtocolTCP, - TargetPort: intstr.FromInt(53), + TargetPort: intstr.FromInt32(53), }, { Name: "port-1-udp", Port: 53, Protocol: corev1.ProtocolUDP, - TargetPort: intstr.FromInt(53), + TargetPort: intstr.FromInt32(53), }, }, ClusterIP: corev1.ClusterIPNone, diff --git a/staging/src/k8s.io/kubectl/pkg/generate/versioned/service.go b/staging/src/k8s.io/kubectl/pkg/generate/versioned/service.go index 0c1beeaab8b..68b6557a641 100644 --- a/staging/src/k8s.io/kubectl/pkg/generate/versioned/service.go +++ b/staging/src/k8s.io/kubectl/pkg/generate/versioned/service.go @@ -196,7 +196,7 @@ func generateService(genericParams map[string]interface{}) (runtime.Object, erro if portNum, err := strconv.Atoi(targetPortString); err != nil { targetPort = intstr.FromString(targetPortString) } else { - targetPort = intstr.FromInt(portNum) + targetPort = intstr.FromInt32(int32(portNum)) } // Use the same target-port for every port for i := range service.Spec.Ports { diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external_test.go b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external_test.go index 7ab6513e869..8b5c6a48350 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external_test.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/gce_loadbalancer_external_test.go @@ -934,13 +934,13 @@ func TestFirewallNeedsUpdate(t *testing.T) { require.NoError(t, err) svc := fakeLoadbalancerService("") svc.Spec.Ports = []v1.ServicePort{ - {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)}, - {Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt(81)}, - {Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt(82)}, - {Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt(84)}, - {Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt(85)}, - {Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt(86)}, - {Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt(87)}, + {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)}, + {Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt32(81)}, + {Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt32(82)}, + {Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt32(84)}, + {Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt32(85)}, + {Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt32(86)}, + {Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt32(87)}, } status, err := createExternalLoadBalancer(gce, svc, []string{"test-node-1"}, vals.ClusterName, vals.ClusterID, vals.ZoneName) @@ -1643,7 +1643,7 @@ func TestFirewallObject(t *testing.T) { desc: "empty source ranges", sourceRanges: utilnet.IPNetSet{}, svcPorts: []v1.ServicePort{ - {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)}, + {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)}, }, expectedFirewall: func(fw compute.Firewall) compute.Firewall { return fw @@ -1653,7 +1653,7 @@ func TestFirewallObject(t *testing.T) { desc: "has source ranges", sourceRanges: sourceRanges, svcPorts: []v1.ServicePort{ - {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)}, + {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)}, }, expectedFirewall: func(fw compute.Firewall) compute.Firewall { fw.SourceRanges = srcRanges @@ -1665,7 +1665,7 @@ func TestFirewallObject(t *testing.T) { sourceRanges: utilnet.IPNetSet{}, destinationIP: dstIP, svcPorts: []v1.ServicePort{ - {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)}, + {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)}, }, expectedFirewall: func(fw compute.Firewall) compute.Firewall { fw.DestinationRanges = []string{dstIP} @@ -1676,9 +1676,9 @@ func TestFirewallObject(t *testing.T) { desc: "has multiple ports", sourceRanges: sourceRanges, svcPorts: []v1.ServicePort{ - {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)}, - {Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt(82)}, - {Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt(84)}, + {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)}, + {Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt32(82)}, + {Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt32(84)}, }, expectedFirewall: func(fw compute.Firewall) compute.Firewall { fw.Allowed = []*compute.FirewallAllowed{ @@ -1695,13 +1695,13 @@ func TestFirewallObject(t *testing.T) { desc: "has multiple ports", sourceRanges: sourceRanges, svcPorts: []v1.ServicePort{ - {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt(80)}, - {Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt(81)}, - {Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt(82)}, - {Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt(84)}, - {Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt(85)}, - {Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt(86)}, - {Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt(87)}, + {Name: "port1", Protocol: v1.ProtocolTCP, Port: int32(80), TargetPort: intstr.FromInt32(80)}, + {Name: "port2", Protocol: v1.ProtocolTCP, Port: int32(81), TargetPort: intstr.FromInt32(81)}, + {Name: "port3", Protocol: v1.ProtocolTCP, Port: int32(82), TargetPort: intstr.FromInt32(82)}, + {Name: "port4", Protocol: v1.ProtocolTCP, Port: int32(84), TargetPort: intstr.FromInt32(84)}, + {Name: "port5", Protocol: v1.ProtocolTCP, Port: int32(85), TargetPort: intstr.FromInt32(85)}, + {Name: "port6", Protocol: v1.ProtocolTCP, Port: int32(86), TargetPort: intstr.FromInt32(86)}, + {Name: "port7", Protocol: v1.ProtocolTCP, Port: int32(88), TargetPort: intstr.FromInt32(87)}, }, expectedFirewall: func(fw compute.Firewall) compute.Firewall { fw.Allowed = []*compute.FirewallAllowed{ diff --git a/test/e2e/apps/deployment.go b/test/e2e/apps/deployment.go index 9e9603271e4..1dc86de1673 100644 --- a/test/e2e/apps/deployment.go +++ b/test/e2e/apps/deployment.go @@ -671,7 +671,7 @@ func failureTrap(ctx context.Context, c clientset.Interface, ns string) { } func intOrStrP(num int) *intstr.IntOrString { - intstr := intstr.FromInt(num) + intstr := intstr.FromInt32(int32(num)) return &intstr } diff --git a/test/e2e/autoscaling/cluster_size_autoscaling.go b/test/e2e/autoscaling/cluster_size_autoscaling.go index b1fe0db5cd2..9dc971956fe 100644 --- a/test/e2e/autoscaling/cluster_size_autoscaling.go +++ b/test/e2e/autoscaling/cluster_size_autoscaling.go @@ -1035,7 +1035,7 @@ func runDrainTest(ctx context.Context, f *framework.Framework, migSizes map[stri ginkgo.DeferCleanup(e2erc.DeleteRCAndWaitForGC, f.ClientSet, namespace, "reschedulable-pods") ginkgo.By("Create a PodDisruptionBudget") - minAvailable := intstr.FromInt(numPods - pdbSize) + minAvailable := intstr.FromInt32(int32(numPods - pdbSize)) pdb := &policyv1.PodDisruptionBudget{ ObjectMeta: metav1.ObjectMeta{ Name: "test_pdb", @@ -1915,7 +1915,7 @@ func addKubeSystemPdbs(ctx context.Context, f *framework.Framework) error { ginkgo.By(fmt.Sprintf("Create PodDisruptionBudget for %v", pdbData.label)) labelMap := map[string]string{"k8s-app": pdbData.label} pdbName := fmt.Sprintf("test-pdb-for-%v", pdbData.label) - minAvailable := intstr.FromInt(pdbData.minAvailable) + minAvailable := intstr.FromInt32(int32(pdbData.minAvailable)) pdb := &policyv1.PodDisruptionBudget{ ObjectMeta: metav1.ObjectMeta{ Name: pdbName, diff --git a/test/e2e/common/node/container_probe.go b/test/e2e/common/node/container_probe.go index c250ee06a9e..4434078841a 100644 --- a/test/e2e/common/node/container_probe.go +++ b/test/e2e/common/node/container_probe.go @@ -1196,7 +1196,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain ProbeHandler: v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: "/healthz", - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), }, }, InitialDelaySeconds: 10, @@ -1660,7 +1660,7 @@ func httpGetHandler(path string, port int) v1.ProbeHandler { return v1.ProbeHandler{ HTTPGet: &v1.HTTPGetAction{ Path: path, - Port: intstr.FromInt(port), + Port: intstr.FromInt32(int32(port)), }, } } @@ -1668,7 +1668,7 @@ func httpGetHandler(path string, port int) v1.ProbeHandler { func tcpSocketHandler(port int) v1.ProbeHandler { return v1.ProbeHandler{ TCPSocket: &v1.TCPSocketAction{ - Port: intstr.FromInt(port), + Port: intstr.FromInt32(int32(port)), }, } } diff --git a/test/e2e/common/node/lifecycle_hook.go b/test/e2e/common/node/lifecycle_hook.go index a562a3a00a0..eec1b977e2f 100644 --- a/test/e2e/common/node/lifecycle_hook.go +++ b/test/e2e/common/node/lifecycle_hook.go @@ -404,7 +404,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain HTTPGet: &v1.HTTPGetAction{ Path: "/echo?msg=poststart", Host: targetIP, - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), }, }, } @@ -432,7 +432,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain Scheme: v1.URISchemeHTTPS, Path: "/echo?msg=poststart", Host: targetIP, - Port: intstr.FromInt(9090), + Port: intstr.FromInt32(9090), }, }, } @@ -459,7 +459,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain HTTPGet: &v1.HTTPGetAction{ Path: "/echo?msg=prestop", Host: targetIP, - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), }, }, } @@ -487,7 +487,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain Scheme: v1.URISchemeHTTPS, Path: "/echo?msg=prestop", Host: targetIP, - Port: intstr.FromInt(9090), + Port: intstr.FromInt32(9090), }, }, } diff --git a/test/e2e/common/util.go b/test/e2e/common/util.go index e135275d479..1dfeda466b8 100644 --- a/test/e2e/common/util.go +++ b/test/e2e/common/util.go @@ -132,7 +132,7 @@ func svcByName(name string, port int) *v1.Service { }, Ports: []v1.ServicePort{{ Port: int32(port), - TargetPort: intstr.FromInt(port), + TargetPort: intstr.FromInt32(int32(port)), }}, }, } diff --git a/test/e2e/framework/autoscaling/autoscaling_utils.go b/test/e2e/framework/autoscaling/autoscaling_utils.go index 632c61cf7a5..d52ce3bb07e 100644 --- a/test/e2e/framework/autoscaling/autoscaling_utils.go +++ b/test/e2e/framework/autoscaling/autoscaling_utils.go @@ -585,7 +585,7 @@ func createService(ctx context.Context, c clientset.Interface, name, ns string, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{{ Port: port, - TargetPort: intstr.FromInt(targetPort), + TargetPort: intstr.FromInt32(int32(targetPort)), }}, Selector: selectors, }, diff --git a/test/e2e/framework/network/utils.go b/test/e2e/framework/network/utils.go index e4f733a57e6..914218f9ef2 100644 --- a/test/e2e/framework/network/utils.go +++ b/test/e2e/framework/network/utils.go @@ -688,8 +688,8 @@ func (config *NetworkingTestConfig) createNodePortServiceSpec(svcName string, se Spec: v1.ServiceSpec{ Type: v1.ServiceTypeNodePort, Ports: []v1.ServicePort{ - {Port: ClusterHTTPPort, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(EndpointHTTPPort)}, - {Port: ClusterUDPPort, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(EndpointUDPPort)}, + {Port: ClusterHTTPPort, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(EndpointHTTPPort)}, + {Port: ClusterUDPPort, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(EndpointUDPPort)}, }, Selector: selector, SessionAffinity: sessionAffinity, @@ -697,7 +697,7 @@ func (config *NetworkingTestConfig) createNodePortServiceSpec(svcName string, se } if config.SCTPEnabled { - res.Spec.Ports = append(res.Spec.Ports, v1.ServicePort{Port: ClusterSCTPPort, Name: "sctp", Protocol: v1.ProtocolSCTP, TargetPort: intstr.FromInt(EndpointSCTPPort)}) + res.Spec.Ports = append(res.Spec.Ports, v1.ServicePort{Port: ClusterSCTPPort, Name: "sctp", Protocol: v1.ProtocolSCTP, TargetPort: intstr.FromInt32(EndpointSCTPPort)}) } if config.DualStackEnabled { requireDual := v1.IPFamilyPolicyRequireDualStack diff --git a/test/e2e/framework/service/resource.go b/test/e2e/framework/service/resource.go index 88b9c9e9904..663fe8c11d4 100644 --- a/test/e2e/framework/service/resource.go +++ b/test/e2e/framework/service/resource.go @@ -148,7 +148,7 @@ func CreateServiceForSimpleApp(ctx context.Context, c clientset.Interface, contP return []v1.ServicePort{{ Protocol: v1.ProtocolTCP, Port: int32(svcPort), - TargetPort: intstr.FromInt(contPort), + TargetPort: intstr.FromInt32(int32(contPort)), }} } framework.Logf("Creating a service-for-%v for selecting app=%v-pod", appName, appName) diff --git a/test/e2e/network/dns_common.go b/test/e2e/network/dns_common.go index a2060594964..cd3b1443995 100644 --- a/test/e2e/network/dns_common.go +++ b/test/e2e/network/dns_common.go @@ -222,7 +222,7 @@ func (t *dnsTestCommon) createUtilPodLabel(ctx context.Context, baseName string) { Protocol: v1.ProtocolTCP, Port: servicePort, - TargetPort: intstr.FromInt(servicePort), + TargetPort: intstr.FromInt32(servicePort), }, }, }, diff --git a/test/e2e/network/util.go b/test/e2e/network/util.go index 11c1bbe028f..6a4e3c391b5 100644 --- a/test/e2e/network/util.go +++ b/test/e2e/network/util.go @@ -194,7 +194,7 @@ func createSecondNodePortService(ctx context.Context, f *framework.Framework, co Port: e2enetwork.ClusterHTTPPort, Name: "http", Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(e2enetwork.EndpointHTTPPort), + TargetPort: intstr.FromInt32(e2enetwork.EndpointHTTPPort), }, }, Selector: config.NodePortService.Spec.Selector, diff --git a/test/integration/deployment/util.go b/test/integration/deployment/util.go index bc9d74a7ea0..248923781fd 100644 --- a/test/integration/deployment/util.go +++ b/test/integration/deployment/util.go @@ -187,7 +187,7 @@ func markPodReady(c clientset.Interface, ns string, pod *v1.Pod) error { } func intOrStrP(num int) *intstr.IntOrString { - intstr := intstr.FromInt(num) + intstr := intstr.FromInt32(int32(num)) return &intstr } diff --git a/test/integration/scheduler/preemption/preemption_test.go b/test/integration/scheduler/preemption/preemption_test.go index d859a6152cd..c57d83247ac 100644 --- a/test/integration/scheduler/preemption/preemption_test.go +++ b/test/integration/scheduler/preemption/preemption_test.go @@ -1231,7 +1231,7 @@ func TestNominatedNodeCleanUp(t *testing.T) { } func mkMinAvailablePDB(name, namespace string, uid types.UID, minAvailable int, matchLabels map[string]string) *policy.PodDisruptionBudget { - intMinAvailable := intstr.FromInt(minAvailable) + intMinAvailable := intstr.FromInt32(int32(minAvailable)) return &policy.PodDisruptionBudget{ ObjectMeta: metav1.ObjectMeta{ Name: name,