Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apis/mattermost/v1alpha1/clusterinstallation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ type ClusterInstallationSpec struct {
// Specify deployment pull policy.
// +optional
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
// PublishNotReadyAddresses controls whether pod endpoints are published before pods are ready.
// When false (recommended), only ready pods receive traffic. When true, pods receive traffic immediately upon creation.
// Defaults to false if not specified.
// +optional
PublishNotReadyAddresses *bool `json:"publishNotReadyAddresses,omitempty"`
// PodTerminationGracePeriodSeconds defines how long to wait before forcefully terminating the pod during shutdown.
// This gives time for the pod to finish processing in-flight requests.
// If not specified, Kubernetes default of 30 seconds is used.
// +optional
PodTerminationGracePeriodSeconds *int64 `json:"podTerminationGracePeriodSeconds,omitempty"`

// Migrate specifies that the ClusterInstallation CR should be migrated to the Mattermost CR.
// CAUTION: Some features like BlueGreen or Canary are not supported with a new Custom Resource
Expand Down
10 changes: 10 additions & 0 deletions apis/mattermost/v1alpha1/zz_generated.deepcopy.go

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

14 changes: 14 additions & 0 deletions apis/mattermost/v1alpha1/zz_generated.openapi.go

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

13 changes: 13 additions & 0 deletions config/crd/bases/mattermost.com_clusterinstallations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,19 @@ spec:
Selector which must match a node's labels for the pod to be scheduled on that node.
More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
type: object
podTerminationGracePeriodSeconds:
description: |-
PodTerminationGracePeriodSeconds defines how long to wait before forcefully terminating the pod during shutdown.
This gives time for the pod to finish processing in-flight requests.
If not specified, Kubernetes default of 30 seconds is used.
format: int64
type: integer
publishNotReadyAddresses:
description: |-
PublishNotReadyAddresses controls whether pod endpoints are published before pods are ready.
When false (recommended), only ready pods receive traffic. When true, pods receive traffic immediately upon creation.
Defaults to false if not specified.
type: boolean
readinessProbe:
description: Defines the probe to check if the application is ready
to accept traffic.
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ spec:
password: "" # Password to log into Elasticsearch.
nodeSelector: {} # See https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector.
affinity: {} # See https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity.
publishNotReadyAddresses: false # Set to false (default) to only route traffic to ready pods. Prevents connection errors during rolling updates and maintenance.
podTerminationGracePeriodSeconds: 60 # How long (in seconds) to wait before forcefully terminating pods during shutdown. Increase this (e.g., 60-90) to allow in-flight requests to complete during rolling updates. Default is 30 seconds if not specified.
13 changes: 10 additions & 3 deletions pkg/mattermost/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ func GenerateDeployment(mattermost *mattermostv1alpha1.ClusterInstallation, dbIn
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
ServiceAccountName: serviceAccountName,
InitContainers: initContainers,
ServiceAccountName: serviceAccountName,
TerminationGracePeriodSeconds: mattermost.Spec.PodTerminationGracePeriodSeconds,
InitContainers: initContainers,
Containers: []corev1.Container{
{
Name: mattermostv1alpha1.MattermostAppContainerName,
Expand Down Expand Up @@ -486,6 +487,12 @@ func ClusterInstallationOwnerReference(mattermost *mattermostv1alpha1.ClusterIns
// newService returns semi-finished service with common parts filled.
// Returned service is expected to be completed by the caller.
func newService(mattermost *mattermostv1alpha1.ClusterInstallation, serviceName, selectorName string, annotations map[string]string) *corev1.Service {
// Default to false if not specified
publishNotReady := false
if mattermost.Spec.PublishNotReadyAddresses != nil {
publishNotReady = *mattermost.Spec.PublishNotReadyAddresses
}

return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Labels: mattermost.ClusterInstallationLabels(serviceName),
Expand All @@ -502,7 +509,7 @@ func newService(mattermost *mattermostv1alpha1.ClusterInstallation, serviceName,
},
Spec: corev1.ServiceSpec{
Selector: mattermostv1alpha1.ClusterInstallationSelectorLabels(selectorName),
PublishNotReadyAddresses: true,
PublishNotReadyAddresses: publishNotReady,
},
}
}
3 changes: 2 additions & 1 deletion pkg/mattermost/mattermost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func TestGenerateService(t *testing.T) {
expectPort(t, service, 8067)
}

assert.True(t, service.Spec.PublishNotReadyAddresses)
// Default behavior is now false unless explicitly set
assert.False(t, service.Spec.PublishNotReadyAddresses)
})
}
}
Expand Down
Loading