Set label operator.cdi.kubevirt.io to deployment spec of cdi-operator

This commit is contained in:
annastopel 2019-05-28 10:05:19 +03:00
parent 3f663890c9
commit c72e1d5a18

View File

@ -144,16 +144,15 @@ func CreateRole(name string) *rbacv1.Role {
//CreateOperatorDeploymentSpec creates deployment //CreateOperatorDeploymentSpec creates deployment
func CreateOperatorDeploymentSpec(name, namespace, matchKey, matchValue, serviceAccount string, numReplicas int32) *appsv1.DeploymentSpec { func CreateOperatorDeploymentSpec(name, namespace, matchKey, matchValue, serviceAccount string, numReplicas int32) *appsv1.DeploymentSpec {
matchMap := map[string]string{matchKey: matchValue}
spec := &appsv1.DeploymentSpec{ spec := &appsv1.DeploymentSpec{
Replicas: &numReplicas, Replicas: &numReplicas,
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{ MatchLabels: WithOperatorLabels(matchMap),
"name": "cdi-operator",
},
}, },
Template: corev1.PodTemplateSpec{ Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"name": "cdi-operator"}, Labels: WithOperatorLabels(matchMap),
}, },
}, },
} }
@ -167,16 +166,12 @@ func CreateOperatorDeploymentSpec(name, namespace, matchKey, matchValue, service
//CreateOperatorDeployment creates deployment //CreateOperatorDeployment creates deployment
func CreateOperatorDeployment(name, namespace, matchKey, matchValue, serviceAccount string, numReplicas int32) *appsv1.Deployment { func CreateOperatorDeployment(name, namespace, matchKey, matchValue, serviceAccount string, numReplicas int32) *appsv1.Deployment {
//matchMap := map[string]string{matchKey: matchValue}
deployment := &appsv1.Deployment{ deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"operator.cdi.kubevirt.io": "",
},
Name: name, Name: name,
Namespace: namespace, Namespace: namespace,
}, },