From 41bfc1855c318e0eccd3d34b9ee6623d8a991120 Mon Sep 17 00:00:00 2001 From: "Erik St. Martin" Date: Tue, 5 Dec 2017 12:54:06 -0600 Subject: [PATCH] providers/azure - Ensure IP Address is set to public if containers expose ports --- providers/azure/aci.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/providers/azure/aci.go b/providers/azure/aci.go index 3c94e3aa0..a6a098bd5 100644 --- a/providers/azure/aci.go +++ b/providers/azure/aci.go @@ -121,6 +121,28 @@ func (p *ACIProvider) CreatePod(pod *v1.Pod) error { containerGroup.ContainerGroupProperties.Volumes = volumes containerGroup.ContainerGroupProperties.ImageRegistryCredentials = creds + // create ipaddress if containerPort is used + count := 0 + for _, container := range containers { + count = count + len(container.Ports) + } + ports := make([]aci.Port, 0, count) + for _, container := range containers { + for _, containerPort := range container.Ports { + + ports = append(ports, aci.Port{ + Port: containerPort.Port, + Protocol: aci.ContainerGroupNetworkProtocol("TCP"), + }) + } + } + if len(ports) > 0 { + containerGroup.ContainerGroupProperties.IPAddress = &aci.IPAddress{ + Ports: ports, + Type: "Public", + } + } + podUID := string(pod.UID) podCreationTimestamp := pod.CreationTimestamp.String() containerGroup.Tags = map[string]string{