Skip to content
Snippets Groups Projects
Commit 54b8da3a authored by Lorenz Brun's avatar Lorenz Brun Committed by Lars Seipel
Browse files

Add service resolution support to K8s executor

parent 14e479f8
No related branches found
No related tags found
No related merge requests found
Pipeline #5231 failed
...@@ -432,9 +432,17 @@ func (s *executor) setupCredentials() error { ...@@ -432,9 +432,17 @@ func (s *executor) setupCredentials() error {
func (s *executor) setupBuildPod() error { func (s *executor) setupBuildPod() error {
services := make([]api.Container, len(s.options.Services)) services := make([]api.Container, len(s.options.Services))
var serviceAliases api.HostAlias
serviceAliases.Hostnames = make([]string, len(s.options.Services))
serviceAliases.IP = "127.0.0.1"
for i, service := range s.options.Services { for i, service := range s.options.Services {
resolvedImage := s.Build.GetAllVariables().ExpandValue(service.Name) resolvedImage := s.Build.GetAllVariables().ExpandValue(service.Name)
services[i] = s.buildContainer(fmt.Sprintf("svc-%d", i), resolvedImage, service, s.serviceRequests, s.serviceLimits) services[i] = s.buildContainer(fmt.Sprintf("svc-%d", i), resolvedImage, service, s.serviceRequests, s.serviceLimits)
if service.Alias != "" {
serviceAliases.Hostnames[i] = service.Alias
} else {
serviceAliases.Hostnames[i] = service.Name
}
} }
labels := make(map[string]string) labels := make(map[string]string)
...@@ -471,6 +479,7 @@ func (s *executor) setupBuildPod() error { ...@@ -471,6 +479,7 @@ func (s *executor) setupBuildPod() error {
ServiceAccountName: s.configurationOverwrites.serviceAccount, ServiceAccountName: s.configurationOverwrites.serviceAccount,
RestartPolicy: api.RestartPolicyNever, RestartPolicy: api.RestartPolicyNever,
NodeSelector: s.Config.Kubernetes.NodeSelector, NodeSelector: s.Config.Kubernetes.NodeSelector,
HostAliases: []api.HostAlias{serviceAliases},
Containers: append([]api.Container{ Containers: append([]api.Container{
// TODO use the build and helper template here // TODO use the build and helper template here
s.buildContainer("build", buildImage, s.options.Image, s.buildRequests, s.buildLimits, s.BuildShell.DockerCommand...), s.buildContainer("build", buildImage, s.options.Image, s.buildRequests, s.buildLimits, s.BuildShell.DockerCommand...),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment