mirror of https://github.com/k3s-io/k3s
switch kubectl portfoward to external types
parent
23111ad414
commit
8620b736cd
|
@ -59,7 +59,6 @@ go_library(
|
|||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/certificates:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/v1:go_default_library",
|
||||
"//pkg/client/clientset_generated/internalclientset:go_default_library",
|
||||
"//pkg/client/clientset_generated/internalclientset/typed/batch/internalversion:go_default_library",
|
||||
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_library",
|
||||
|
@ -125,6 +124,7 @@ go_library(
|
|||
"//staging/src/k8s.io/client-go/discovery:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/dynamic:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
||||
|
|
|
@ -28,13 +28,13 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/portforward"
|
||||
"k8s.io/client-go/transport/spdy"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
apiv1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
||||
coreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
@ -143,7 +143,7 @@ func (f *defaultPortForwarder) ForwardPorts(method string, url *url.URL, opts Po
|
|||
// It rewrites ports as needed if the Service port declares targetPort.
|
||||
// It returns an error when a named targetPort can't find a match in the pod, or the Service did not declare
|
||||
// the port.
|
||||
func translateServicePortToTargetPort(ports []string, svc api.Service, pod api.Pod) ([]string, error) {
|
||||
func translateServicePortToTargetPort(ports []string, svc v1.Service, pod v1.Pod) ([]string, error) {
|
||||
var translated []string
|
||||
for _, port := range ports {
|
||||
// port is in the form of [LOCAL PORT]:REMOTE PORT
|
||||
|
@ -184,7 +184,7 @@ func (o *PortForwardOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
|||
}
|
||||
|
||||
builder := f.NewBuilder().
|
||||
WithScheme(legacyscheme.Scheme).
|
||||
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
||||
ContinueOnError().
|
||||
NamespaceParam(o.Namespace).DefaultNamespace()
|
||||
|
||||
|
@ -210,14 +210,8 @@ func (o *PortForwardOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
|||
|
||||
// handle service port mapping to target port if needed
|
||||
switch t := obj.(type) {
|
||||
case *api.Service:
|
||||
// TODO(juanvallejo): remove this once we convert this command to work with externals
|
||||
internalPod := &api.Pod{}
|
||||
if err := apiv1.Convert_v1_Pod_To_core_Pod(forwardablePod, internalPod, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.Ports, err = translateServicePortToTargetPort(args[1:], *t, *internalPod)
|
||||
case *v1.Service:
|
||||
o.Ports, err = translateServicePortToTargetPort(args[1:], *t, *forwardablePod)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/client-go/rest/fake"
|
||||
|
@ -145,17 +146,17 @@ func TestPortForward(t *testing.T) {
|
|||
func TestTranslateServicePortToTargetPort(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
svc api.Service
|
||||
pod api.Pod
|
||||
svc v1.Service
|
||||
pod v1.Pod
|
||||
ports []string
|
||||
translated []string
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
name: "test success 1 (int port)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(8080),
|
||||
|
@ -163,11 +164,11 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(8080)},
|
||||
|
@ -182,10 +183,10 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test success 2 (clusterIP: None)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
ClusterIP: "None",
|
||||
Ports: []api.ServicePort{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(8080),
|
||||
|
@ -193,11 +194,11 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(8080)},
|
||||
|
@ -212,9 +213,9 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test success 3 (named port)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -226,11 +227,11 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(8080)},
|
||||
|
@ -248,20 +249,20 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test success (targetPort omitted)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(80)},
|
||||
|
@ -276,9 +277,9 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test failure 1 (named port lookup failure)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -286,11 +287,11 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "https",
|
||||
ContainerPort: int32(443)},
|
||||
|
@ -305,9 +306,9 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test failure 2 (service port not declared)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -315,11 +316,11 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "https",
|
||||
ContainerPort: int32(443)},
|
||||
|
|
|
@ -15,7 +15,7 @@ go_library(
|
|||
importpath = "k8s.io/kubernetes/pkg/kubectl/util",
|
||||
visibility = ["//build/visible_to:pkg_kubectl_util_CONSUMERS"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
|
||||
|
@ -83,7 +83,7 @@ go_test(
|
|||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -19,12 +19,12 @@ package util
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
// Lookup containerPort number by its named port name
|
||||
func LookupContainerPortNumberByName(pod api.Pod, name string) (int32, error) {
|
||||
func lookupContainerPortNumberByName(pod v1.Pod, name string) (int32, error) {
|
||||
for _, ctr := range pod.Spec.Containers {
|
||||
for _, ctrportspec := range ctr.Ports {
|
||||
if ctrportspec.Name == name {
|
||||
|
@ -40,12 +40,12 @@ func LookupContainerPortNumberByName(pod api.Pod, name string) (int32, error) {
|
|||
// It implements the handling of resolving container named port, as well as ignoring targetPort when clusterIP=None
|
||||
// It returns an error when a named port can't find a match (with -1 returned), or when the service does not
|
||||
// declare such port (with the input port number returned).
|
||||
func LookupContainerPortNumberByServicePort(svc api.Service, pod api.Pod, port int32) (int32, error) {
|
||||
func LookupContainerPortNumberByServicePort(svc v1.Service, pod v1.Pod, port int32) (int32, error) {
|
||||
for _, svcportspec := range svc.Spec.Ports {
|
||||
if svcportspec.Port != port {
|
||||
continue
|
||||
}
|
||||
if svc.Spec.ClusterIP == api.ClusterIPNone {
|
||||
if svc.Spec.ClusterIP == v1.ClusterIPNone {
|
||||
return port, nil
|
||||
}
|
||||
if svcportspec.TargetPort.Type == intstr.Int {
|
||||
|
@ -56,7 +56,7 @@ func LookupContainerPortNumberByServicePort(svc api.Service, pod api.Pod, port i
|
|||
return int32(svcportspec.TargetPort.IntValue()), nil
|
||||
}
|
||||
} else {
|
||||
return LookupContainerPortNumberByName(pod, svcportspec.TargetPort.String())
|
||||
return lookupContainerPortNumberByName(pod, svcportspec.TargetPort.String())
|
||||
}
|
||||
}
|
||||
return port, fmt.Errorf("Service %s does not have a service port %d", svc.Name, port)
|
||||
|
|
|
@ -19,25 +19,25 @@ package util
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
func TestLookupContainerPortNumberByName(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pod api.Pod
|
||||
pod v1.Pod
|
||||
portname string
|
||||
portnum int32
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
name: "test success 1",
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "https",
|
||||
ContainerPort: int32(443)},
|
||||
|
@ -55,11 +55,11 @@ func TestLookupContainerPortNumberByName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test faulure 1",
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "https",
|
||||
ContainerPort: int32(443)},
|
||||
|
@ -76,7 +76,7 @@ func TestLookupContainerPortNumberByName(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
portnum, err := LookupContainerPortNumberByName(tt.pod, tt.portname)
|
||||
portnum, err := lookupContainerPortNumberByName(tt.pod, tt.portname)
|
||||
if err != nil {
|
||||
if tt.err {
|
||||
return
|
||||
|
@ -101,17 +101,17 @@ func TestLookupContainerPortNumberByName(t *testing.T) {
|
|||
func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
svc api.Service
|
||||
pod api.Pod
|
||||
svc v1.Service
|
||||
pod v1.Pod
|
||||
port int32
|
||||
containerPort int32
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
name: "test success 1 (int port)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(8080),
|
||||
|
@ -119,11 +119,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(8080)},
|
||||
|
@ -138,10 +138,10 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test success 2 (clusterIP: None)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
ClusterIP: api.ClusterIPNone,
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
ClusterIP: v1.ClusterIPNone,
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(8080),
|
||||
|
@ -149,11 +149,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(8080)},
|
||||
|
@ -168,9 +168,9 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test success 3 (named port)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -178,11 +178,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(8080)},
|
||||
|
@ -197,20 +197,20 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test success (targetPort omitted)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(80)},
|
||||
|
@ -225,9 +225,9 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test failure 1 (cannot find a matching named port)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -235,11 +235,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "https",
|
||||
ContainerPort: int32(443)},
|
||||
|
@ -254,9 +254,9 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test failure 2 (cannot find a matching service port)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -264,11 +264,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "https",
|
||||
ContainerPort: int32(443)},
|
||||
|
@ -283,10 +283,10 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "test failure 2 (cannot find a matching service port, but ClusterIP: None)",
|
||||
svc: api.Service{
|
||||
Spec: api.ServiceSpec{
|
||||
ClusterIP: api.ClusterIPNone,
|
||||
Ports: []api.ServicePort{
|
||||
svc: v1.Service{
|
||||
Spec: v1.ServiceSpec{
|
||||
ClusterIP: v1.ClusterIPNone,
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromString("http"),
|
||||
|
@ -294,11 +294,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
pod: api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
pod: v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Ports: []api.ContainerPort{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "http",
|
||||
ContainerPort: int32(80)},
|
||||
|
|
Loading…
Reference in New Issue