mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Defaulting deployment selector and label
This commit is contained in:
parent
6f61326cdb
commit
0829bcc8fc
@ -44,6 +44,19 @@ func addDefaultingFuncs() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
func(obj *Deployment) {
|
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.
|
// Set DeploymentSpec.Replicas to 1 if it is not set.
|
||||||
if obj.Spec.Replicas == nil {
|
if obj.Spec.Replicas == nil {
|
||||||
obj.Spec.Replicas = new(int)
|
obj.Spec.Replicas = new(int)
|
||||||
|
Loading…
Reference in New Issue
Block a user