fix(synapse): define deployment strategy
All checks were successful
/ publish (push) Successful in 13s

Avoid surges with more than 1 container and conflict running upgrade.
This commit is contained in:
Hugo Renard 2024-10-09 17:36:13 +02:00
parent f0dbc1e45b
commit 1475c5ed19
Signed by: hougo
GPG key ID: 3A285FD470209C59

View file

@ -23,6 +23,7 @@ import (
appsv1 "k8s.io/api/apps/v1" appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
matrixv1alpha1 "libre.sh/api/matrix/v1alpha1" matrixv1alpha1 "libre.sh/api/matrix/v1alpha1"
@ -56,6 +57,14 @@ func (r *SynapseReconciler) reconcileDeployment(ctx context.Context, synapse *ma
} }
deployment.Spec.Replicas = &replicas deployment.Spec.Replicas = &replicas
deployment.Spec.Strategy.Type = appsv1.RollingUpdateDeploymentStrategyType
maxSurge := intstr.FromInt(1)
maxUnavailable := intstr.FromInt(0)
deployment.Spec.Strategy.RollingUpdate = &appsv1.RollingUpdateDeployment{
MaxSurge: &maxSurge,
MaxUnavailable: &maxUnavailable,
}
r.mutatePodTemplateSpec(ctx, synapse, resources, &deployment.Spec.Template) r.mutatePodTemplateSpec(ctx, synapse, resources, &deployment.Spec.Template)
deployment.Spec.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{ deployment.Spec.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{