|
| 1 | +--- |
| 2 | +title: Override Deployment Templates with the CockroachDB Operator |
| 3 | +summary: Use advanced configuration operations to manually override pod templates and cockroach start flags with the CockcroachDB operator. |
| 4 | +toc: true |
| 5 | +docs_area: deploy |
| 6 | +--- |
| 7 | + |
| 8 | +The {{ site.data.products.cockroachdb-operator }} provides abstractions that simplify cluster deployment and node initialization: |
| 9 | + |
| 10 | +- A default pod specification is used for the CockroachDB Kubernetes pod. |
| 11 | +- The `values.yaml` configuration maps to a subset of `cockroach start` flags when CockroachDB is initialized. |
| 12 | + |
| 13 | +This page describes configuration options that allow advanced users to manually override the pod template and `cockroach start` flags as needed for deployment. |
| 14 | + |
| 15 | +{{site.data.alerts.callout_info}} |
| 16 | +The {{ site.data.products.cockroachdb-operator }} is in [Preview]({% link {{ page.version.version }}/cockroachdb-feature-availability.md %}). |
| 17 | +{{site.data.alerts.end}} |
| 18 | + |
| 19 | +{{site.data.alerts.callout_danger}} |
| 20 | +This page describes advanced configurations that override the supported default templates used by the {{ site.data.products.cockroachdb-operator }}. Cockroach Labs strongly recommends testing these configurations in a non-production environment first. |
| 21 | +{{site.data.alerts.end}} |
| 22 | + |
| 23 | +## Override the default pod |
| 24 | + |
| 25 | +The `cockroachdb.crdbCluster.podTemplate` field allows you to override the default pod metadata and specification configured by the {{ site.data.products.cockroachdb-operator }}. The values in this field are merged with the default pod specification, where settings in `podTemplate` override any values in the default. |
| 26 | + |
| 27 | +~~~ yaml |
| 28 | +cockroachdb: |
| 29 | + crdbCluster: |
| 30 | + podTemplate: |
| 31 | + # metadata captures the pod metadata for CockroachDB pods. |
| 32 | + metadata: {} |
| 33 | + # spec captures the pod specification for CockroachDB pods. |
| 34 | + spec: |
| 35 | + # initContainers captures the list of init containers for CockroachDB pods. |
| 36 | + initContainers: |
| 37 | + - name : cockroachdb-init |
| 38 | + image: us-docker.pkg.dev/cockroach-cloud-images/data-plane/init-container@sha256:c3e4ba851802a429c7f76c639a64b9152d206cebb31162c1760f05e98f7c4254 |
| 39 | + # containers captures the list of containers for CockroachDB pods. |
| 40 | + containers: |
| 41 | + - name: cockroachdb |
| 42 | + image: cockroachdb/cockroach:v25.2.2 |
| 43 | + - name: cert-reloader |
| 44 | + image: us-docker.pkg.dev/cockroach-cloud-images/data-plane/inotifywait:87edf086db32734c7fa083a62d1055d664900840 |
| 45 | + # imagePullSecrets captures the secrets for fetching images from private registries. |
| 46 | + imagePullSecrets: [] |
| 47 | +~~~ |
| 48 | + |
| 49 | +At least one value for `containers` must be specified if any part of `podTemplate` is being modified. For example, the following `podTemplate` configuration overrides pod anti-affinity behavior and specifies a default `cockroachdb/cockroach:v25.2.2` container image: |
| 50 | + |
| 51 | +~~~ yaml |
| 52 | +cockroachdb: |
| 53 | + crdbCluster: |
| 54 | + podTemplate: |
| 55 | + spec: |
| 56 | + affinity: |
| 57 | + podAntiAffinity: |
| 58 | + preferredDuringSchedulingIgnoredDuringExecution: |
| 59 | + - weight: 100 |
| 60 | + podAffinityTerm: |
| 61 | + labelSelector: |
| 62 | + matchExpressions: |
| 63 | + - key: app.kubernetes.io/component |
| 64 | + operator: In |
| 65 | + values: |
| 66 | + - cockroachdb |
| 67 | + topologyKey: kubernetes.io/hostname |
| 68 | + containers: |
| 69 | + - name: cockroachdb |
| 70 | + image: cockroachdb/cockroach:v25.2.2 |
| 71 | +~~~ |
| 72 | + |
| 73 | +## Override the default `cockroach start` flags |
| 74 | + |
| 75 | +The `cockroachdb.crdbCluster.startFlags` field allows you to customize the [`cockroach start` flags]({% link {{ page.version.version }}/cockroach-start.md %}#flags) used when initializing the CockroachDB cluster. |
| 76 | + |
| 77 | +Within this field, you can specify flags to upsert and flags to omit: |
| 78 | + |
| 79 | +- Upserted flags are added to the `cockroach start` command, their values overriding any matching flags in the command. |
| 80 | +- Omitted flags are removed from the `cockroach start` command if they were present. |
| 81 | + |
| 82 | +~~~ yaml |
| 83 | +cockroachdb: |
| 84 | + crdbCluster: |
| 85 | + startFlags: {} |
| 86 | + # upsert captures a set of flags that are given higher precedence in the start command. |
| 87 | + upsert: |
| 88 | + - "--cache=30%" |
| 89 | + - "--max-sql-memory=35%" |
| 90 | + # omit defines a set of flags which will be omitted from the start command. |
| 91 | + omit: |
| 92 | + - "" |
| 93 | +~~~ |
0 commit comments