Skip to content

Commit 216c592

Browse files
committed
Add WAL failover custom path support for helm chart migration
1 parent b60abd0 commit 216c592

File tree

16 files changed

+1448
-85
lines changed

16 files changed

+1448
-85
lines changed

build/templates/cockroachdb-parent/charts/cockroachdb/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ cockroachdb:
265265
#
266266
# walFailoverSpec captures the configuration for WAL Failover.
267267
walFailoverSpec: {}
268+
# name determines the prefix of the pvc name that we want to provide
269+
# for the wal failover. This field was introduced during the migration process
270+
# from the statefulset to the operator.
271+
# name: failover-dir
272+
#
268273
# status determines the possible values to WAL Failover configuration.
269274
# It has 3 possible values: "", "enable" and "disable".
270275
# status: ""
@@ -276,6 +281,14 @@ cockroachdb:
276281
# If not set, the default provisioner will be chosen (gp2 on AWS, standard on GKE).
277282
# storageClassName: ""
278283
#
284+
# path is the absolute mount path inside the CockroachDB container to use for WAL failover side disk.
285+
# Examples:
286+
# - /cockroach/cockroach-failover
287+
# - /cockroach/custom/path
288+
# IMPORTANT: Set it only for fresh deployments. Changing it on upgrades might cause issues with the deployment.
289+
#
290+
# path: "/cockroach/cockroach-failover"
291+
#
279292
# podLabels captures additional labels to apply to CockroachDB pods.
280293
podLabels:
281294
app.kubernetes.io/component: cockroachdb

build/templates/cockroachdb-parent/charts/operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ image:
99
# pullPolicy specifies the image pull policy.
1010
pullPolicy: IfNotPresent
1111
# tag is the image tag.
12-
tag: "6f62639e9fee99d99b0387a9dccda84daa1a489b592b008f2f354ec57eae09ac"
12+
tag: "24cc995b44f2ff4a2c30b8290d229602c8b5ad90c74d0843c246f701e30db872"
1313
# certificate defines the certificate settings for the Operator.
1414
certificate:
1515
# validForDays specifies the number of days the certificate is valid for.

cockroachdb-parent/charts/cockroachdb/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ cockroachdb:
266266
#
267267
# walFailoverSpec captures the configuration for WAL Failover.
268268
walFailoverSpec: {}
269+
# name determines the prefix of the pvc name that we want to provide
270+
# for the wal failover. This field was introduced during the migration process
271+
# from the statefulset to the operator.
272+
# name: failover-dir
273+
#
269274
# status determines the possible values to WAL Failover configuration.
270275
# It has 3 possible values: "", "enable" and "disable".
271276
# status: ""
@@ -277,6 +282,14 @@ cockroachdb:
277282
# If not set, the default provisioner will be chosen (gp2 on AWS, standard on GKE).
278283
# storageClassName: ""
279284
#
285+
# path is the absolute mount path inside the CockroachDB container to use for WAL failover side disk.
286+
# Examples:
287+
# - /cockroach/cockroach-failover
288+
# - /cockroach/custom/path
289+
# IMPORTANT: Set it only for fresh deployments. Changing it on upgrades might cause issues with the deployment.
290+
#
291+
# path: "/cockroach/cockroach-failover"
292+
#
280293
# podLabels captures additional labels to apply to CockroachDB pods.
281294
podLabels:
282295
app.kubernetes.io/component: cockroachdb

cockroachdb-parent/charts/operator/templates/operator.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ rules:
254254
- admissionregistration.k8s.io
255255
resources:
256256
- validatingwebhookconfigurations
257+
- mutatingwebhookconfigurations
257258
verbs:
258259
- create
259260
- apiGroups:
@@ -265,6 +266,15 @@ rules:
265266
verbs:
266267
- get
267268
- patch
269+
- apiGroups:
270+
- admissionregistration.k8s.io
271+
resources:
272+
- mutatingwebhookconfigurations
273+
resourceNames:
274+
- cockroach-mutating-webhook-config
275+
verbs:
276+
- get
277+
- patch
268278
# The "create" verb cannot be qualified with resourceNames, so grant the
269279
# unqualified permission so that the operator can create new CRDs. But only
270280
# allow the operator to get and patch its own CRDs.

cockroachdb-parent/charts/operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ image:
1010
# pullPolicy specifies the image pull policy.
1111
pullPolicy: IfNotPresent
1212
# tag is the image tag.
13-
tag: "6f62639e9fee99d99b0387a9dccda84daa1a489b592b008f2f354ec57eae09ac"
13+
tag: "24cc995b44f2ff4a2c30b8290d229602c8b5ad90c74d0843c246f701e30db872"
1414
# certificate defines the certificate settings for the Operator.
1515
certificate:
1616
# validForDays specifies the number of days the certificate is valid for.

pkg/migrate/build-manifests.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ func (m *Manifest) FromHelmChart() error {
172172
}
173173

174174
input.pcrSpec = detectPCRFromInitJob(m.clientset, sts.Name, m.namespace)
175+
176+
// Cluster level WalSpec
177+
var clusterWalSpec *v1alpha1.CrdbWalFailoverSpec
175178
for nodeIdx := int32(0); nodeIdx < *sts.Spec.Replicas; nodeIdx++ {
176179
podName := fmt.Sprintf("%s-%d", sts.Name, nodeIdx)
177180
pod, err := m.clientset.CoreV1().Pods(m.namespace).Get(ctx, podName, metav1.GetOptions{})
@@ -183,6 +186,11 @@ func (m *Manifest) FromHelmChart() error {
183186
return errors.Newf("pod %s isn't scheduled to a node", podName)
184187
}
185188

189+
// Build the walFailoverSpec if applicable
190+
buildWalFailoverSpec(ctx, m.clientset, sts, pod.Spec.NodeName, nodeIdx, &input)
191+
if input.walFailoverSpec != nil && clusterWalSpec == nil {
192+
clusterWalSpec = input.walFailoverSpec
193+
}
186194
nodeSpec := buildNodeSpecFromHelm(sts, pod.Spec.NodeName, input)
187195
crdbNode := v1alpha1.CrdbNode{
188196
TypeMeta: metav1.TypeMeta{

0 commit comments

Comments
 (0)