mirror of https://github.com/k3s-io/k3s
Merge pull request #379 from brendandburns/host
Add support for host up binding to the API (and kubelet)pull/6/head
commit
95fb7bc1ae
|
@ -74,6 +74,8 @@ type Port struct {
|
|||
ContainerPort int `yaml:"containerPort" json:"containerPort"`
|
||||
// Optional: Defaults to "TCP".
|
||||
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
|
||||
// Optional: What host IP to bind the external port to.
|
||||
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
|
||||
}
|
||||
|
||||
// VolumeMount describes a mounting of a Volume within a container
|
||||
|
|
|
@ -332,6 +332,7 @@ func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, m
|
|||
portBindings[dockerPort] = []docker.PortBinding{
|
||||
{
|
||||
HostPort: strconv.Itoa(exteriorPort),
|
||||
HostIp: port.HostIP,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -529,6 +529,7 @@ func TestMakePortsAndBindings(t *testing.T) {
|
|||
{
|
||||
ContainerPort: 80,
|
||||
HostPort: 8080,
|
||||
HostIP: "127.0.0.1",
|
||||
},
|
||||
{
|
||||
ContainerPort: 443,
|
||||
|
@ -558,18 +559,30 @@ func TestMakePortsAndBindings(t *testing.T) {
|
|||
if !reflect.DeepEqual(docker.Port("80/tcp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIp != "127.0.0.1" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIp)
|
||||
}
|
||||
case "443":
|
||||
if !reflect.DeepEqual(docker.Port("443/tcp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIp != "" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIp)
|
||||
}
|
||||
case "444":
|
||||
if !reflect.DeepEqual(docker.Port("444/udp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIp != "" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIp)
|
||||
}
|
||||
case "445":
|
||||
if !reflect.DeepEqual(docker.Port("445/tcp"), key) {
|
||||
t.Errorf("Unexpected docker port: %#v", key)
|
||||
}
|
||||
if value[0].HostIp != "" {
|
||||
t.Errorf("Unexpected host IP: %s", value[0].HostIp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue