Commit f5e74c8e authored by Vineet Reddy Rajula's avatar Vineet Reddy Rajula
Browse files

Merge branch 'deployment-annotations' into 'master'

Enforce pod priority class and s2i rollouts

See merge request !141
parents 9f9d0c8f 8fed717a
Pipeline #3351442 passed with stages
in 4 minutes and 7 seconds
...@@ -1037,20 +1037,8 @@ func deploymentForDrupalSite(currentobject *appsv1.Deployment, databaseSecret st ...@@ -1037,20 +1037,8 @@ func deploymentForDrupalSite(currentobject *appsv1.Deployment, databaseSecret st
// Settings only on creation (not enforced) // Settings only on creation (not enforced)
if currentobject.CreationTimestamp.IsZero() { if currentobject.CreationTimestamp.IsZero() {
currentobject.Spec.Template.ObjectMeta.Annotations = map[string]string{} currentobject.Spec.Template.ObjectMeta.Annotations = map[string]string{}
if d.Spec.QoSClass == webservicesv1a1.QoSCritical {
// TODO: move this to the `DeploymentConfig`
// openshift-user-critical is part of the default OKD4 Priority classes
// https://github.com/openshift/cluster-config-operator/blob/168704868381c88551627239d132a3900eedc14f/manifests/0000_50_config-operator_09_user-priority-class.yaml
currentobject.Spec.Template.Spec.PriorityClassName = "openshift-user-critical"
}
currentobject.Spec.Template.Spec.Containers = []corev1.Container{{Name: "nginx"}, {Name: "php-fpm"}, {Name: "php-fpm-exporter"}, {Name: "webdav"}} currentobject.Spec.Template.Spec.Containers = []corev1.Container{{Name: "nginx"}, {Name: "php-fpm"}, {Name: "php-fpm-exporter"}, {Name: "webdav"}}
if len(d.Spec.Configuration.ExtraConfigurationRepo) > 0 {
// This annotation is required to trigger new rollout, when the imagestream gets updated with a new image for the given tag. Without this, deployments might start running with
// a wrong image built from a different build, that is left out on the node
currentobject.Annotations["image.openshift.io/triggers"] = "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"sitebuilder-s2i-" + d.Name + ":" + releaseID + "\",\"namespace\":\"" + d.Namespace + "\"},\"fieldPath\":\"spec.template.spec.containers[?(@.name==\\\"nginx\\\")].image\",\"pause\":\"false\"},{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"sitebuilder-s2i-" + d.Name + ":" + releaseID + "\",\"namespace\":\"" + d.Namespace + "\"},\"fieldPath\":\"spec.template.spec.containers[?(@.name==\\\"php-fpm\\\")].image\",\"pause\":\"false\"}]"
}
currentobject.Spec.Selector = &metav1.LabelSelector{ currentobject.Spec.Selector = &metav1.LabelSelector{
MatchLabels: ls, MatchLabels: ls,
} }
...@@ -1339,10 +1327,16 @@ func deploymentForDrupalSite(currentobject *appsv1.Deployment, databaseSecret st ...@@ -1339,10 +1327,16 @@ func deploymentForDrupalSite(currentobject *appsv1.Deployment, databaseSecret st
// Ref: https://gitlab.cern.ch/drupal/paas/drupalsite-operator/-/issues/71 // Ref: https://gitlab.cern.ch/drupal/paas/drupalsite-operator/-/issues/71
currentobject.Spec.Template.ObjectMeta.Annotations["pre.hook.backup.velero.io/timeout"] = "90m" currentobject.Spec.Template.ObjectMeta.Annotations["pre.hook.backup.velero.io/timeout"] = "90m"
currentobject.Spec.Template.ObjectMeta.Annotations["backup.velero.io/backup-volumes"] = "drupal-directory-" + d.Name currentobject.Spec.Template.ObjectMeta.Annotations["backup.velero.io/backup-volumes"] = "drupal-directory-" + d.Name
if d.Spec.QoSClass == webservicesv1a1.QoSCritical {
currentobject.Annotations["critical-site"] = "true"
// TODO: move this to the `DeploymentConfig` function
// openshift-user-critical is part of the default OKD4 Priority classes
// https://github.com/openshift/cluster-config-operator/blob/168704868381c88551627239d132a3900eedc14f/manifests/0000_50_config-operator_09_user-priority-class.yaml
currentobject.Spec.Template.Spec.PriorityClassName = "openshift-user-critical"
}
// Ensure availability zones for critical sites if enabled // Ensure availability zones for critical sites if enabled
if d.Spec.QoSClass == webservicesv1a1.QoSCritical && EnableTopologySpread { if d.Spec.QoSClass == webservicesv1a1.QoSCritical && EnableTopologySpread {
currentobject.Annotations["critical-site"] = "true"
currentobject.Spec.Template.Spec.TopologySpreadConstraints = []v1.TopologySpreadConstraint{ currentobject.Spec.Template.Spec.TopologySpreadConstraints = []v1.TopologySpreadConstraint{
{ {
LabelSelector: &metav1.LabelSelector{ LabelSelector: &metav1.LabelSelector{
...@@ -1359,6 +1353,14 @@ func deploymentForDrupalSite(currentobject *appsv1.Deployment, databaseSecret st ...@@ -1359,6 +1353,14 @@ func deploymentForDrupalSite(currentobject *appsv1.Deployment, databaseSecret st
currentobject.Spec.Template.Spec.TopologySpreadConstraints = []v1.TopologySpreadConstraint{} currentobject.Spec.Template.Spec.TopologySpreadConstraints = []v1.TopologySpreadConstraint{}
} }
// Ensure S2I rollouts on image change
if len(d.Spec.Configuration.ExtraConfigurationRepo) > 0 {
// This annotation is required to trigger new rollout, when the imagestream gets updated with a new image for the given tag. Without this, deployments might start running with
// a wrong image built from a different build, that is left out on the node
currentobject.Annotations["image.openshift.io/triggers"] =
"[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"sitebuilder-s2i-" + d.Name + ":" + releaseID + "\",\"namespace\":\"" + d.Namespace + "\"},\"fieldPath\":\"spec.template.spec.containers[?(@.name==\\\"nginx\\\")].image\",\"pause\":\"false\"},{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"sitebuilder-s2i-" + d.Name + ":" + releaseID + "\",\"namespace\":\"" + d.Namespace + "\"},\"fieldPath\":\"spec.template.spec.containers[?(@.name==\\\"php-fpm\\\")].image\",\"pause\":\"false\"}]"
}
return nil return nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment