Merge pull request #15267 from nikhiljindal/deploymentRCSelector

Deployment: Fixing the selector for new RC created by deployment
This commit is contained in:
Dawn Chen
2015-10-12 14:40:30 -07:00
3 changed files with 37 additions and 10 deletions

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)