Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #118 from nais/nytt_election_label_name
Browse files Browse the repository at this point in the history
Støtter nå flere instanser
  • Loading branch information
Kyrremann authored Jun 26, 2018
2 parents 1b47354 + 3cd7137 commit 9ecc55f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/resourcecreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ func createPodSpec(deploymentRequest naisrequest.Deploy, manifest NaisManifest,
}

if manifest.LeaderElection {
podSpec.Containers = append(podSpec.Containers, createLeaderElectionContainer(deploymentRequest.Application))
electionName := deploymentRequest.Application + "-" + deploymentRequest.Namespace
podSpec.Containers = append(podSpec.Containers, createLeaderElectionContainer(electionName))

mainContainer := &podSpec.Containers[0]
electorPathEnv := k8score.EnvVar{
Expand All @@ -216,7 +217,7 @@ func createPodSpec(deploymentRequest naisrequest.Deploy, manifest NaisManifest,
return podSpec, nil
}

func createLeaderElectionContainer(appName string) k8score.Container {
func createLeaderElectionContainer(electionName string) k8score.Container {
return k8score.Container{
Name: "elector",
Image: "gcr.io/google_containers/leader-elector:0.5",
Expand All @@ -229,7 +230,7 @@ func createLeaderElectionContainer(appName string) k8score.Container {
Ports: []k8score.ContainerPort{
{ContainerPort: 4040, Protocol: k8score.ProtocolTCP},
},
Args: []string{"--election=" + appName, "--http=localhost:4040", "--election-namespace=election"},
Args: []string{"--election=" + electionName, "--http=localhost:4040", "--election-namespace=election"},
}
}

Expand Down

0 comments on commit 9ecc55f

Please sign in to comment.