Defaulting deployment selector and label

This commit is contained in:
nikhiljindal 2015-10-08 14:03:32 -07:00
parent 6f61326cdb
commit 0829bcc8fc

View File

@ -44,6 +44,19 @@ func addDefaultingFuncs() {
}
},
func(obj *Deployment) {
// Default labels and selector to labels from pod template spec.
var labels map[string]string
if obj.Spec.Template != nil {
labels = obj.Spec.Template.Labels
}
if labels != nil {
if len(obj.Spec.Selector) == 0 {
obj.Spec.Selector = labels
}
if len(obj.Labels) == 0 {
obj.Labels = labels
}
}
// Set DeploymentSpec.Replicas to 1 if it is not set.
if obj.Spec.Replicas == nil {
obj.Spec.Replicas = new(int)