Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better docs about using custom name for Cockroachdb #66

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 5 additions & 10 deletions cockroachdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,10 @@ reduces infrastructure costs and maintenance overhead.

While the preference is to have a single CockroachDB cluster per namespace, in some cases this isn't ideal.

An example of this is in the Energy team where they have recently split into three squads but currently still share use of the `energy-platform` namespace.

In order to deploy multiple CockroachDB clusters within a single namespace whilst avoiding naming conflicts we can make use of the `namePrefix` and/or `nameSuffix` ability of Kustomize.
This will automagically update the names of resources within a Kustomization as well as the selectors and labels.

One part of this that Kustomize is not able to help with is with the CockroachDB specific commands that are used to create and join nodes to the cluster.
For this two environment variables have been added `COCKROACH_INIT_HOST` and `COCKROACH_JOIN_STRING`.

- `COCKROACH_INIT_HOST` is used by the `init-job.yaml` manifest to initialise the first node in the cluster
- `COCKROACH_JOIN_STRING` is in the `statefulset.yaml` manifest to define which nodes will be joining the cluster.
This will automatically update the names of resources within a Kustomization as well as the selectors and labels.

There are sensible defaults for these environment variables to ensure that a single cluster within a namespace can be brought up without overriding any environment variables.
In addition to that, you must manually patch:
- Any Cockroach URLs - like env `COCKROACH_JOIN_STRING`, dnsNames or COCKROACH_INIT_HOST - because service name (and thus, URL) will be updated;
- Certificate issuerRef- as Issuer name will be changed;
- serviceAccountName - as service name will be changed;
5 changes: 3 additions & 2 deletions cockroachdb/example/cert-manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# In case there is more than one cockroach in the namespace,
# we need to add prefix in order to avoid naming conflict while creating resources
# In case prefix is added
# (for example, to avoid naming conflict while creating multiple Cockroach clusters in single ns)
# other resources must be updated- see `#single namespace - multiple Cockroach clusters` section in README.
#namePrefix: shared-

resources:
Expand Down