Skip to content

Commit

Permalink
[MM-49782] Allow configurable deployment revision history limit (#335)
Browse files Browse the repository at this point in the history
* Added deploymenttemplate spec

* manifests

* check deployment as well

* Documentation typos

Co-authored-by: Mir Shahriar Sabuj <mir.shahriar@mattermost.com>

* regenerate openapi manifest

* update manifests

---------

Co-authored-by: Mir Shahriar Sabuj <mir.shahriar@mattermost.com>
  • Loading branch information
fmartingr and mirshahriar authored Feb 1, 2023
1 parent fc440cf commit 262f04a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
11 changes: 11 additions & 0 deletions apis/mattermost/v1beta1/mattermost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions apis/mattermost/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion apis/mattermost/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions config/crd/bases/installation.mattermost.com_mattermosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion pkg/mattermost/mattermost_v1beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 262f04a

Please sign in to comment.