mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
Rename Service.ContainerPort to TargetPort in v1b3
Fix all callers and examples. Part of multi-port service cleanup.
This commit is contained in:
@@ -89,9 +89,9 @@ func init() {
|
||||
}
|
||||
},
|
||||
func(obj *ServiceSpec) {
|
||||
if obj.ContainerPort.Kind == util.IntstrInt && obj.ContainerPort.IntVal == 0 ||
|
||||
obj.ContainerPort.Kind == util.IntstrString && obj.ContainerPort.StrVal == "" {
|
||||
obj.ContainerPort = util.NewIntOrStringFromInt(obj.Port)
|
||||
if obj.TargetPort.Kind == util.IntstrInt && obj.TargetPort.IntVal == 0 ||
|
||||
obj.TargetPort.Kind == util.IntstrString && obj.TargetPort.StrVal == "" {
|
||||
obj.TargetPort = util.NewIntOrStringFromInt(obj.Port)
|
||||
}
|
||||
},
|
||||
func(obj *NamespaceStatus) {
|
||||
|
@@ -72,19 +72,19 @@ func TestSetDefaulEndpointsProtocol(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaulServiceDestinationPort(t *testing.T) {
|
||||
func TestSetDefaulServiceTargetPort(t *testing.T) {
|
||||
in := ¤t.Service{Spec: current.ServiceSpec{Port: 1234}}
|
||||
obj := roundTrip(t, runtime.Object(in))
|
||||
out := obj.(*current.Service)
|
||||
if out.Spec.ContainerPort.Kind != util.IntstrInt || out.Spec.ContainerPort.IntVal != 1234 {
|
||||
t.Errorf("Expected ContainerPort to be defaulted, got %s", out.Spec.ContainerPort)
|
||||
if out.Spec.TargetPort.Kind != util.IntstrInt || out.Spec.TargetPort.IntVal != 1234 {
|
||||
t.Errorf("Expected TargetPort to be defaulted, got %s", out.Spec.TargetPort)
|
||||
}
|
||||
|
||||
in = ¤t.Service{Spec: current.ServiceSpec{Port: 1234, ContainerPort: util.NewIntOrStringFromInt(5678)}}
|
||||
in = ¤t.Service{Spec: current.ServiceSpec{Port: 1234, TargetPort: util.NewIntOrStringFromInt(5678)}}
|
||||
obj = roundTrip(t, runtime.Object(in))
|
||||
out = obj.(*current.Service)
|
||||
if out.Spec.ContainerPort.Kind != util.IntstrInt || out.Spec.ContainerPort.IntVal != 5678 {
|
||||
t.Errorf("Expected ContainerPort to be unchanged, got %s", out.Spec.ContainerPort)
|
||||
if out.Spec.TargetPort.Kind != util.IntstrInt || out.Spec.TargetPort.IntVal != 5678 {
|
||||
t.Errorf("Expected TargetPort to be unchanged, got %s", out.Spec.TargetPort)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -751,10 +751,10 @@ type ServiceSpec struct {
|
||||
// users to handle external traffic that arrives at a node.
|
||||
PublicIPs []string `json:"publicIPs,omitempty" description:"externally visible IPs (e.g. load balancers) that should be proxied to this service"`
|
||||
|
||||
// ContainerPort is the name or number of the port on the container to direct traffic to.
|
||||
// TargetPort is the name or number of the port on the container to direct traffic to.
|
||||
// This is useful if the containers the service points to have multiple open ports.
|
||||
// Optional: If unspecified, the service port is used (an identity map).
|
||||
ContainerPort util.IntOrString `json:"containerPort,omitempty" description:"number or name of the port to access on the containers belonging to pods targeted by the service; defaults to the container's first open port"`
|
||||
TargetPort util.IntOrString `json:"targetPort,omitempty" description:"number or name of the port to access on the containers belonging to pods targeted by the service; defaults to the container's first open port"`
|
||||
|
||||
// Optional: Supports "ClientIP" and "None". Used to maintain session affinity.
|
||||
SessionAffinity AffinityType `json:"sessionAffinity,omitempty" description:"enable client IP based session affinity; must be ClientIP or None; defaults to None"`
|
||||
|
Reference in New Issue
Block a user