Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Adding app stanza labels to kubernetes resources #969

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions builtin/k8s/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (p *Platform) Deploy(
img *docker.Image,
deployConfig *component.DeploymentConfig,
ui terminal.UI,
labels *component.LabelSet,
) (*Deployment, error) {
// Create our deployment and set an initial ID
var result Deployment
Expand Down Expand Up @@ -167,6 +168,18 @@ func (p *Platform) Deploy(
// Set our ID on the label. We use this ID so that we can have a key
// to route to multiple versions during release management.
deployment.Spec.Template.Labels[labelId] = result.Id
//Set app label
deployment.ObjectMeta.Labels = make(map[string]string)
deployment.ObjectMeta.Labels["app"] = src.App
deployment.Spec.Template.Labels["app"] = src.App
// Adding labels to the pod and deployment labels
// exclude name from the pod spec as that is set in newDeployment
for k, v := range labels.Labels {
deployment.ObjectMeta.Labels[k] = v
if k != "name" {
deployment.Spec.Template.Labels[k] = v
}
}

// If the user is using the latest tag, then don't specify an overriding pull policy.
// This by default means kubernetes will always pull so that latest is useful.
Expand Down
6 changes: 6 additions & 0 deletions builtin/k8s/releaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (r *Releaser) Release(
src *component.Source,
ui terminal.UI,
target *Deployment,
labels *component.LabelSet,
) (*Release, error) {
var result Release
result.ServiceName = src.App
Expand Down Expand Up @@ -91,6 +92,11 @@ func (r *Releaser) Release(
labelId: target.Id,
}

//Add labels to the k8s service from the app stanza
for k, v := range labels.Labels {
service.ObjectMeta.Labels[k] = v
}

var checkLB bool

if r.config.LoadBalancer {
Expand Down