Set explicit labels/selector for apps/v1 Deployment/RS.

pull/8/head
Anthony Yeh 2018-05-11 11:09:56 -07:00
parent 680bc4b4b5
commit 436db71751
No known key found for this signature in database
GPG Key ID: 339F46A383E6ED08
5 changed files with 15 additions and 4 deletions

View File

@ -195,6 +195,7 @@ func (dc *DeploymentController) getNewReplicaSet(d *apps.Deployment, rsList, old
Name: d.Name + "-" + rand.SafeEncodeString(podTemplateSpecHash), Name: d.Name + "-" + rand.SafeEncodeString(podTemplateSpecHash),
Namespace: d.Namespace, Namespace: d.Namespace,
OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(d, controllerKind)}, OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(d, controllerKind)},
Labels: newRSTemplate.Labels,
}, },
Spec: apps.ReplicaSetSpec{ Spec: apps.ReplicaSetSpec{
Replicas: new(int32), Replicas: new(int32),

View File

@ -173,10 +173,14 @@ func TestSampleAPIServer(f *framework.Framework, image string) {
} }
d := &apps.Deployment{ d := &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: deploymentName, Name: deploymentName,
Labels: podLabels,
}, },
Spec: apps.DeploymentSpec{ Spec: apps.DeploymentSpec{
Replicas: &replicas, Replicas: &replicas,
Selector: &metav1.LabelSelector{
MatchLabels: podLabels,
},
Strategy: apps.DeploymentStrategy{ Strategy: apps.DeploymentStrategy{
Type: apps.RollingUpdateDeploymentStrategyType, Type: apps.RollingUpdateDeploymentStrategyType,
}, },

View File

@ -265,10 +265,14 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
} }
d := &apps.Deployment{ d := &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: deploymentName, Name: deploymentName,
Labels: podLabels,
}, },
Spec: apps.DeploymentSpec{ Spec: apps.DeploymentSpec{
Replicas: &replicas, Replicas: &replicas,
Selector: &metav1.LabelSelector{
MatchLabels: podLabels,
},
Strategy: apps.DeploymentStrategy{ Strategy: apps.DeploymentStrategy{
Type: apps.RollingUpdateDeploymentStrategyType, Type: apps.RollingUpdateDeploymentStrategyType,
}, },

View File

@ -40,7 +40,8 @@ func newRS(rsName string, replicas int32, rsPodLabels map[string]string, imageNa
zero := int64(0) zero := int64(0)
return &apps.ReplicaSet{ return &apps.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: rsName, Name: rsName,
Labels: rsPodLabels,
}, },
Spec: apps.ReplicaSetSpec{ Spec: apps.ReplicaSetSpec{
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{

View File

@ -87,7 +87,8 @@ func NewDeployment(deploymentName string, replicas int32, podLabels map[string]s
zero := int64(0) zero := int64(0)
return &apps.Deployment{ return &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: deploymentName, Name: deploymentName,
Labels: podLabels,
}, },
Spec: apps.DeploymentSpec{ Spec: apps.DeploymentSpec{
Replicas: &replicas, Replicas: &replicas,