diff --git a/apis/mattermost/v1beta1/mattermost_types.go b/apis/mattermost/v1beta1/mattermost_types.go index 7fe3c7a26..b7bbfe084 100644 --- a/apis/mattermost/v1beta1/mattermost_types.go +++ b/apis/mattermost/v1beta1/mattermost_types.go @@ -120,6 +120,10 @@ type MattermostSpec struct { // +optional PodTemplate *PodTemplate `json:"podTemplate,omitempty"` + // DeploymentTemplate defines configuration for the template for Mattermost deployment. + // +optional + DeploymentTemplate *DeploymentTemplate `json:"deploymentTemplate,omitempty"` + // UpdateJob defines configuration for the template for the update job. // +optional UpdateJob *UpdateJob `json:"updateJob,omitempty"` @@ -259,6 +263,13 @@ type PodTemplate struct { ExtraLabels map[string]string `json:"extraLabels,omitempty"` } +// DeploymentTemplate defines configuration for the template for Mattermost deployment. +type DeploymentTemplate struct { + // Defines the revision history limit for the mattermost deployment. + // +optional + RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty"` +} + // UpdateJob defines configuration for the template for the update job pod. type UpdateJob struct { // Determines whether to disable the Operator's creation of the update job. diff --git a/apis/mattermost/v1beta1/zz_generated.deepcopy.go b/apis/mattermost/v1beta1/zz_generated.deepcopy.go index 9c61b4e40..ceecadc7d 100644 --- a/apis/mattermost/v1beta1/zz_generated.deepcopy.go +++ b/apis/mattermost/v1beta1/zz_generated.deepcopy.go @@ -65,6 +65,26 @@ func (in *Database) DeepCopy() *Database { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentTemplate) DeepCopyInto(out *DeploymentTemplate) { + *out = *in + if in.RevisionHistoryLimit != nil { + in, out := &in.RevisionHistoryLimit, &out.RevisionHistoryLimit + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentTemplate. +func (in *DeploymentTemplate) DeepCopy() *DeploymentTemplate { + if in == nil { + return nil + } + out := new(DeploymentTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ElasticSearch) DeepCopyInto(out *ElasticSearch) { *out = *in @@ -361,6 +381,11 @@ func (in *MattermostSpec) DeepCopyInto(out *MattermostSpec) { *out = new(PodTemplate) (*in).DeepCopyInto(*out) } + if in.DeploymentTemplate != nil { + in, out := &in.DeploymentTemplate, &out.DeploymentTemplate + *out = new(DeploymentTemplate) + (*in).DeepCopyInto(*out) + } if in.UpdateJob != nil { in, out := &in.UpdateJob, &out.UpdateJob *out = new(UpdateJob) diff --git a/apis/mattermost/v1beta1/zz_generated.openapi.go b/apis/mattermost/v1beta1/zz_generated.openapi.go index d89452ded..492caf113 100644 --- a/apis/mattermost/v1beta1/zz_generated.openapi.go +++ b/apis/mattermost/v1beta1/zz_generated.openapi.go @@ -304,6 +304,12 @@ func schema_mattermost_operator_apis_mattermost_v1beta1_MattermostSpec(ref commo Ref: ref("github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.PodTemplate"), }, }, + "deploymentTemplate": { + SchemaProps: spec.SchemaProps{ + Description: "DeploymentTemplate defines configuration for the template for Mattermost deployment.", + Ref: ref("github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.DeploymentTemplate"), + }, + }, "updateJob": { SchemaProps: spec.SchemaProps{ Description: "UpdateJob defines configuration for the template for the update job.", @@ -327,6 +333,6 @@ func schema_mattermost_operator_apis_mattermost_v1beta1_MattermostSpec(ref commo }, }, Dependencies: []string{ - "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.AWSLoadBalancerController", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Database", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.ElasticSearch", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.FileStore", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Ingress", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.PodExtensions", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.PodTemplate", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Probes", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.ResourcePatch", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Scheduling", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.UpdateJob", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodDNSConfig", "k8s.io/api/core/v1.Volume", "k8s.io/api/core/v1.VolumeMount"}, + "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.AWSLoadBalancerController", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Database", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.DeploymentTemplate", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.ElasticSearch", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.FileStore", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Ingress", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.PodExtensions", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.PodTemplate", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Probes", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.ResourcePatch", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.Scheduling", "github.com/mattermost/mattermost-operator/apis/mattermost/v1beta1.UpdateJob", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodDNSConfig", "k8s.io/api/core/v1.Volume", "k8s.io/api/core/v1.VolumeMount"}, } } diff --git a/config/crd/bases/installation.mattermost.com_mattermosts.yaml b/config/crd/bases/installation.mattermost.com_mattermosts.yaml index 6202f601d..c66c72a5b 100644 --- a/config/crd/bases/installation.mattermost.com_mattermosts.yaml +++ b/config/crd/bases/installation.mattermost.com_mattermosts.yaml @@ -183,6 +183,16 @@ spec: type: string type: object type: object + deploymentTemplate: + description: DeploymentTemplate defines configuration for the template + for Mattermost deployment. + properties: + revisionHistoryLimit: + description: Defines the revision history limit for the mattermost + deployment. + format: int32 + type: integer + type: object dnsConfig: description: Custom DNS configuration to use for the Mattermost Installation pods. diff --git a/pkg/mattermost/mattermost_v1beta.go b/pkg/mattermost/mattermost_v1beta.go index 1dd6f8023..29edd0e93 100644 --- a/pkg/mattermost/mattermost_v1beta.go +++ b/pkg/mattermost/mattermost_v1beta.go @@ -347,6 +347,12 @@ func GenerateDeploymentV1Beta(mattermost *mmv1beta.Mattermost, db DatabaseConfig podSecurityContext = mattermost.Spec.PodTemplate.SecurityContext } + // Deployment template + revisionHistoryLimit := pkgUtils.NewInt32(defaultRevHistoryLimit) + if mattermost.Spec.DeploymentTemplate != nil && mattermost.Spec.DeploymentTemplate.RevisionHistoryLimit != nil { + revisionHistoryLimit = mattermost.Spec.DeploymentTemplate.RevisionHistoryLimit + } + return &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: deploymentName, @@ -362,7 +368,7 @@ func GenerateDeploymentV1Beta(mattermost *mmv1beta.Mattermost, db DatabaseConfig MaxSurge: &maxSurge, }, }, - RevisionHistoryLimit: pkgUtils.NewInt32(defaultRevHistoryLimit), + RevisionHistoryLimit: revisionHistoryLimit, Replicas: mattermost.Spec.Replicas, Selector: &metav1.LabelSelector{ MatchLabels: mmv1beta.MattermostSelectorLabels(deploymentName),