Added protocol in port configuration (#2993)

Closes  #2727
This commit is contained in:
Thomas Anderson
2024-01-13 01:57:24 +03:00
committed by GitHub
parent 9bbc446009
commit 0611fa9b32
12 changed files with 166 additions and 14 deletions

View File

@@ -134,6 +134,7 @@ func podContainer(step *types.Step, podName, goos string) (v1.Container, error)
}
container.Env = mapToEnvVars(step.Environment)
container.Ports = containerPorts(step.Ports)
container.SecurityContext = containerSecurityContext(step.BackendOptions.Kubernetes.SecurityContext, step.Privileged)
container.Resources, err = resourceRequirements(step.BackendOptions.Kubernetes.Resources)
@@ -198,6 +199,21 @@ func volumeMount(name, path string) v1.VolumeMount {
}
}
func containerPorts(ports []types.Port) []v1.ContainerPort {
containerPorts := make([]v1.ContainerPort, len(ports))
for i, port := range ports {
containerPorts[i] = containerPort(port)
}
return containerPorts
}
func containerPort(port types.Port) v1.ContainerPort {
return v1.ContainerPort{
ContainerPort: int32(port.Number),
Protocol: v1.Protocol(strings.ToUpper(port.Protocol)),
}
}
// Here is the service IPs (placed in /etc/hosts in the Pod)
func hostAliases(extraHosts []types.HostAlias) []v1.HostAlias {
hostAliases := []v1.HostAlias{}