diff --git a/internal/kubernetes/core/v1/pod/container/port/expand.go b/internal/kubernetes/core/v1/pod/container/port/expand.go index 78f5e06b..6241cb18 100644 --- a/internal/kubernetes/core/v1/pod/container/port/expand.go +++ b/internal/kubernetes/core/v1/pod/container/port/expand.go @@ -20,6 +20,10 @@ func Expand(in []interface{}) ([]corev1.ContainerPort, error) { if port, ok := value[FieldContainerPort]; ok { ports[key].ContainerPort = int32(port.(int)) } + + if port, ok := value[FieldHostPort]; ok { + ports[key].HostPort = int32(port.(int)) + } } return ports, nil diff --git a/internal/kubernetes/core/v1/pod/container/port/fields.go b/internal/kubernetes/core/v1/pod/container/port/fields.go index d44baf89..fb4460ec 100644 --- a/internal/kubernetes/core/v1/pod/container/port/fields.go +++ b/internal/kubernetes/core/v1/pod/container/port/fields.go @@ -9,6 +9,8 @@ const ( FieldName = "name" // FieldContainerPort used to identify the port which is being exposed from the container. FieldContainerPort = "container" + // FieldHostPort used to identify the port which is being exposed from the host. + FieldHostPort = "host" ) // Fields returns the fields for this package. @@ -29,6 +31,11 @@ func Fields() *schema.Schema { Type: schema.TypeInt, Optional: true, }, + FieldHostPort: { + Description: "Port to receive requests from the host", + Type: schema.TypeInt, + Optional: true, + }, }, }, } diff --git a/internal/kubernetes/core/v1/pod/container/port/flatten.go b/internal/kubernetes/core/v1/pod/container/port/flatten.go index 4c1fe0db..679b4152 100644 --- a/internal/kubernetes/core/v1/pod/container/port/flatten.go +++ b/internal/kubernetes/core/v1/pod/container/port/flatten.go @@ -17,6 +17,10 @@ func Flatten(in []corev1.ContainerPort) []interface{} { row[FieldContainerPort] = value.ContainerPort } + if value.HostPort > 0 { + row[FieldHostPort] = value.HostPort + } + flattened[key] = row }