Skip to content

Commit

Permalink
Raise replica to two and add anti-affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
Artyom Lukianov committed Aug 4, 2019
1 parent 3838005 commit e423e28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/operator/components/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ func newPodTemplateSpec(data *DeploymentData) *corev1.PodTemplateSpec {
},
},
Spec: corev1.PodSpec{
Affinity: &corev1.Affinity{
PodAntiAffinity: &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
LabelSelector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: mrv1.SchemeGroupVersion.Group,
Operator: metav1.LabelSelectorOpIn,
Values: []string{data.Name},
},
},
},
TopologyKey: "kubernetes.io/hostname",
},
},
},
},
Containers: containers,
NodeSelector: map[string]string{"node-role.kubernetes.io/master": ""},
SecurityContext: &corev1.PodSecurityContext{
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"

mrv1 "kubevirt.io/machine-remediation-operator/pkg/apis/machineremediation/v1alpha1"
"kubevirt.io/machine-remediation-operator/pkg/operator/components"
Expand All @@ -33,6 +34,7 @@ func (r *ReconcileMachineRemediationOperator) getDeployment(name string, namespa

func (r *ReconcileMachineRemediationOperator) createOrUpdateDeployment(data *components.DeploymentData) error {
newDeploy := components.NewDeployment(data)
newDeploy.Spec.Replicas = pointer.Int32Ptr(2)

oldDeploy, err := r.getDeployment(data.Name, data.Namespace)
if errors.IsNotFound(err) {
Expand Down

0 comments on commit e423e28

Please sign in to comment.