Skip to content

Commit

Permalink
Enforce system labels over default labels
Browse files Browse the repository at this point in the history
  • Loading branch information
joyrex2001 committed Oct 23, 2023
1 parent 8cfcd7c commit 9bdbe07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions internal/backend/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ func (in *instance) getLabels(labels map[string]string, tainr *types.Container)
}
labels[kk] = kv
}
for k, v := range config.SystemLabels {
labels[k] = v
}
labels["kubedock.containerid"] = tainr.ShortID
return labels
}
Expand Down
12 changes: 8 additions & 4 deletions internal/config/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import (
"github.com/joyrex2001/kubedock/internal/util/stringid"
)

// DefaultLabels are the labels that are added to every kubedock
// managed k8s resource.
var DefaultLabels = map[string]string{
// SystemLabels are the labels that are added to every kubedock
// managed k8s resource and which should not be altered.
var SystemLabels = map[string]string{
"kubedock": "true",
"kubedock.id": "",
}

// DefaultLabels are the labels that are added to every kubedock
// managed k8s resource.
var DefaultLabels = map[string]string{}

// DefaultAnnotations are the annotations that are added to every
// kubedock managed k8s resource.
var DefaultAnnotations = map[string]string{}
Expand All @@ -29,7 +33,7 @@ var InstanceID = ""
// this speciffic instance of kubedock.
func init() {
InstanceID = stringid.TruncateID(stringid.GenerateRandomID())
DefaultLabels["kubedock.id"] = InstanceID
SystemLabels["kubedock.id"] = InstanceID
}

// AddDefaultLabel will add a label that will be added to all containers
Expand Down

0 comments on commit 9bdbe07

Please sign in to comment.