Browse Source

strategy can be changed now, default recreate

tags/0.0.6
Vladimir Smagin 5 months ago
parent
commit
bc0aa56cb9
2 changed files with 13 additions and 5 deletions
  1. +5
    -3
      pkg/apis/blindage/v1alpha1/wordpress_types.go
  2. +8
    -2
      pkg/controller/wordpress/manifests.go

+ 5
- 3
pkg/apis/blindage/v1alpha1/wordpress_types.go View File

@@ -1,6 +1,7 @@
package v1alpha1

import (
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -35,9 +36,10 @@ type ImportBackup struct {
}

type WordpressSpec struct {
Image string `json:"image,omitempty"` // default wordpress:latest
PullPolicy *v1.PullPolicy `json:"pullPolicy,omitempty"` // default "if not exists"
Replicas int32 `json:"replicas"` // default 1`
Image string `json:"image,omitempty"` // default wordpress:latest
PullPolicy *v1.PullPolicy `json:"pullPolicy,omitempty"` // default "if not exists"
Replicas int32 `json:"replicas"` // default 1`
WordpressUpdateStrategy *appsv1.DeploymentStrategy `json:"wordpressUpdateStrategy,omitempty"` // default recreate

// create init container with backup restore
ImportBackup *ImportBackup `json:"importBackup,omitempty"`


+ 8
- 2
pkg/controller/wordpress/manifests.go View File

@@ -1,6 +1,7 @@
package wordpress

import (
"fmt"
"time"

blindagev1alpha1 "git.blindage.org/21h/wordpress-operator/pkg/apis/blindage/v1alpha1"
@@ -58,7 +59,7 @@ func generateWordpressDeployment(cr *blindagev1alpha1.Wordpress, recreateWordpre

// some time ago configmap with ENVs was changed, wp pods must be restarted
if recreateWordpressPods {
podAnnotations["forceUpdate"] = string(time.Now().Unix())
podAnnotations["forceUpdate"] = fmt.Sprintf("%v", time.Now().Unix())
}

// check affinity rules
@@ -95,6 +96,11 @@ func generateWordpressDeployment(cr *blindagev1alpha1.Wordpress, recreateWordpre
pullPolicy = *cr.Spec.PullPolicy
}

updateStrategy := v1.DeploymentStrategy{Type: v1.RecreateDeploymentStrategyType}
if cr.Spec.WordpressUpdateStrategy != nil {
updateStrategy = *cr.Spec.WordpressUpdateStrategy
}

deployment := v1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name,
@@ -107,7 +113,7 @@ func generateWordpressDeployment(cr *blindagev1alpha1.Wordpress, recreateWordpre
MatchLabels: baseLabels(cr),
},
Replicas: &cr.Spec.Replicas,
Strategy: v1.DeploymentStrategy{Type: v1.RollingUpdateDeploymentStrategyType, RollingUpdate: nil},
Strategy: updateStrategy,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: mergeLabels(baseLabels(cr),


Loading…
Cancel
Save