Skip to content

Commit f68a938

Browse files
udnayNishanthNalluri
authored andcommitted
Added Operator charts, modified cockroachdb charts to support cc-operator
1 parent d7a9566 commit f68a938

22 files changed

+1087
-20
lines changed

build/templates/values.yaml

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,135 @@ iap:
716716
godebug:
717717
disablethp: "1"
718718

719-
# Use the CockroachDB Operator to manage the CockroachDB clusters.
719+
# Use the CRDB Operator to manage the CRDB clusters
720720
operator:
721-
enabled: false
721+
enabled: true
722+
# Default values for the cluster chart.
723+
image:
724+
repository: cockroachdb/cockroach
725+
pullPolicy: IfNotPresent
726+
# Overrides the image tag whose default is the cluster chart's appVersion.
727+
tag: ""
728+
729+
nameOverride: ""
730+
fullnameOverride: ""
731+
732+
# A map of CRDB cluster settings.
733+
# See https://www.cockroachlabs.com/docs/stable/cluster-settings.html
734+
clusterSettings: ~
735+
736+
# Regions controls the number of CRDB nodes that are deployed per region.
737+
# regions: ~
738+
# - code: us-central1
739+
# nodes: 3
740+
741+
# loggingConf is the logging configuration used by cockroach.
742+
# More details: https://www.cockroachlabs.com/docs/stable/logging-overview.html
743+
loggingConf: ~
744+
# sinks:
745+
# stderr:
746+
# channels: [health, dev]
747+
# filter: INFO
748+
749+
# We usually recommend not to specify default resources and to leave this as a conscious
750+
# choice for the user. This also increases chances charts run on environments with little
751+
# resources, such as K3D. If you do want to specify resources, uncomment the following
752+
# lines, adjust them as necessary, and remove the tilde after 'resources:'.
753+
resources: ~
754+
# limits:
755+
# cpu: 100m
756+
# memory: 128Mi
757+
# requests:
758+
# cpu: 100m
759+
# memory: 128Mi
760+
761+
# dataStore specifies the disk configuration for the CRDB Node.
762+
dataStore:
763+
volumeClaimTemplate:
764+
metadata: {}
765+
spec:
766+
accessModes:
767+
- ReadWriteOnce
768+
resources:
769+
requests:
770+
storage: 10Gi
771+
volumeMode: Filesystem
772+
773+
certificates:
774+
# Any extra alt names that should be added to the node certs.
775+
extraNodeAltNames: []
776+
# - somevalue
777+
# - somevalue.default
778+
# - somevalue.default.svc.local
779+
# the number of days generated certs are valid for
780+
# validForDays: 3650
781+
782+
# External certificates for the CRDB cluster.
783+
externalCertificates:
784+
clientCaConfigMapName: ""
785+
nodeCaConfigMapName: ""
786+
httpSecretName: ""
787+
nodeClientSecretName: ""
788+
nodeSecretName: ""
789+
rootSqlClientSecretName: ""
790+
791+
# RBAC settings for CRDB nodes
792+
rbac:
793+
# By default the service account will be the resource name. It will
794+
# be created during the installation along with a namespaced role and
795+
# a cluster role with the policy rules below.
796+
#
797+
# Uncomment the line below to use a custom SA. If a custom SA is used,
798+
# no roles or bindings will be created.
799+
# serviceAccountName: my-custom-sa
800+
801+
# Rules for the namespaced role bound to the service account.
802+
#
803+
# E.g.
804+
# permissions:
805+
# - apiGroup: [""]
806+
# resources: ["secrets"]
807+
# verbs: ["create", "get"]
808+
rules: []
809+
810+
# Rules for the cluster role bound to the service account.
811+
clusterRules:
812+
# Get nodes allows the locality container to work as expected. It pulls the
813+
# failure-domain.beta.kubernetes.io/zone label to determine node locality.
814+
- apiGroups: [""]
815+
resources: ["nodes"]
816+
verbs: ["get"]
817+
serviceAccountName: ~
818+
819+
regions:
820+
- code: us-east-1
821+
nodes: 3
822+
cloudProvider: k3d
823+
namespace: default
824+
825+
# PodLabels are the labels that should be applied to the underlying CRDB pod
826+
podLabels:
827+
app.kubernetes.io/component: cockroachdb
828+
829+
# Flags passed to the cockroachdb container.
830+
flags:
831+
# Disable backup/restore to local disk by default.
832+
--external-io-dir: disabled
833+
834+
# Environment variables set on cockroachdb pods.
835+
env: []
836+
837+
# Delay between cockroachdb pod restarts. Wait 3m by default to avoid
838+
# unavailability during restarts.
839+
rollingRestartDelay: 3m0s
840+
841+
# Topology spread constraints set on cockroachdb pods. Spread cockroachdb
842+
# pods across zones by default.
843+
topologySpreadConstraints:
844+
- maxSkew: 1
845+
topologyKey: topology.kubernetes.io/zone
846+
whenUnsatisfiable: DoNotSchedule
847+
848+
extras:
849+
# Add a container with dnsutils (nslookup, dig, ping, etc.) installed.
850+
dnsutils: false

cockroachdb/templates/_helpers.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,23 @@ Construct the GODEBUG env var value (looks like: GODEBUG="foo=bar,baz=quux"; def
361361
{{- end }}
362362
{{- join "," $godebugList -}}
363363
{{- end }}
364+
365+
366+
{{/* Common labels that are applied to all managed objects. */}}
367+
{{- define "cluster.labels" -}}
368+
helm.sh/chart: {{ include "cockroachdb.chart" . }}
369+
{{ include "cluster.selectorLabels" . }}
370+
{{- if .Chart.AppVersion }}
371+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
372+
{{- end }}
373+
app.kubernetes.io/managed-by: {{ .Release.Service }}
374+
{{- end }}
375+
376+
{{/*
377+
Selector labels defines the set of labels that can be used as selectors for
378+
crdb nodes.
379+
*/}}
380+
{{- define "cluster.selectorLabels" -}}
381+
app.kubernetes.io/name: {{ include "cockroachdb.clusterfullname" . }}
382+
app.kubernetes.io/instance: {{ .Release.Name }}
383+
{{- end }}

cockroachdb/templates/crdb.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{- if .Values.operator.enabled }}
2+
---
3+
apiVersion: crdb.cockroachlabs.com/v1alpha1
4+
kind: CrdbCluster
5+
metadata:
6+
name: {{ template "cockroachdb.fullname" . }}
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{- include "cluster.labels" . | nindent 4 }}
10+
{{- with .Values.statefulset.labels }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- with .Values.labels }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
spec:
17+
{{- with .Values.operator.clusterSettings }}
18+
clusterSettings: {{- toYaml . | nindent 4 }}
19+
{{- end }}
20+
{{- with .Values.operator.regions }}
21+
regions: {{- toYaml . | nindent 4 }}
22+
{{- end }}
23+
features:
24+
- reconcile
25+
- reconcile-beta
26+
{{- with .Values.operator.flags }}
27+
flags: {{- toYaml . | nindent 4 }}
28+
{{- end }}
29+
rollingRestartDelay: {{ .Values.operator.rollingRestartDelay }}
30+
template:
31+
spec:
32+
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
33+
certificates:
34+
externalCertificates:
35+
{{- /* Note: defaults should match secrets and configmaps created by the self-signer job. */}}
36+
clientCaConfigMapName: {{ .Values.operator.certificates.externalCertificates.clientCaConfigMapName | default (printf "%s-ca-secret-crt" (include "cockroachdb.fullname" .)) }}
37+
nodeCaConfigMapName: {{ .Values.operator.certificates.externalCertificates.nodeCaConfigMapName | default (printf "%s-ca-secret-crt" (include "cockroachdb.fullname" .)) }}
38+
httpSecretName: {{ .Values.operator.certificates.externalCertificates.httpSecretName | default (printf "%s-client-secret" (include "cockroachdb.fullname" .)) }}
39+
nodeClientSecretName: {{ .Values.operator.certificates.externalCertificates.nodeClientSecretName | default (printf "%s-client-secret" (include "cockroachdb.fullname" .)) }}
40+
nodeSecretName: {{ .Values.operator.certificates.externalCertificates.nodeSecretName | default (printf "%s-node-secret" (include "cockroachdb.fullname" .)) }}
41+
rootSqlClientSecretName: {{ .Values.operator.certificates.externalCertificates.rootSqlClientSecretName | default (printf "%s-client-secret" (include "cockroachdb.fullname" .)) }}
42+
{{- with .Values.operator.dataStore }}
43+
dataStore: {{- toYaml . | nindent 8 }}
44+
{{- end }}
45+
{{- with .Values.operator.env }}
46+
env: {{- toYaml . | nindent 8 }}
47+
{{- end }}
48+
{{- with .Values.operator.topologySpreadConstraints }}
49+
topologySpreadConstraints: {{- toYaml . | nindent 8 }}
50+
{{- end }}
51+
podLabels:
52+
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
53+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
54+
{{- with .Values.operator.podLabels }}
55+
{{- toYaml . | nindent 8 }}
56+
{{- end }}
57+
{{- with .Values.operator.resources }}
58+
resourceRequirements: {{- toYaml . | nindent 8 }}
59+
{{- end }}
60+
serviceAccountName: {{ .Values.operator.rbac.serviceAccountName | default (include "cockroachdb.serviceAccount.name" .) }}
61+
{{- if .Values.operator.loggingConf }}
62+
loggingConfigMapName: {{ .Release.Name }}-logging
63+
{{- end }}
64+
# All properties below are solely to pass validation. They aren't used by the
65+
# betaclusterctrl controller so the values don't matter so long as they're
66+
# valid.
67+
dataStore: {}
68+
{{- end }}

cockroachdb/templates/job.init.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ $isClusterInitEnabled := and (eq (len .Values.conf.join) 0) (not (index .Values.conf `single-node`)) }}
22
{{ $isDatabaseProvisioningEnabled := .Values.init.provisioning.enabled }}
3-
{{- if or $isClusterInitEnabled $isDatabaseProvisioningEnabled }}
3+
{{- if and (or $isClusterInitEnabled $isDatabaseProvisioningEnabled) (not .Values.operator.enabled) }}
44
{{ template "cockroachdb.tlsValidation" . }}
55
kind: Job
66
apiVersion: batch/v1

cockroachdb/templates/poddisruptionbudget.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if (not .Values.operator.enabled) }}
12
kind: PodDisruptionBudget
23
{{- if or (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version) }}
34
apiVersion: policy/v1
@@ -24,3 +25,4 @@ spec:
2425
{{- toYaml . | nindent 6 }}
2526
{{- end }}
2627
maxUnavailable: {{ .Values.statefulset.budget.maxUnavailable | int64 }}
28+
{{- end }}

cockroachdb/templates/role-certSelfSigner.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ rules:
3030
- apiGroups: [""]
3131
resources: ["pods"]
3232
verbs: ["delete", "get"]
33+
- apiGroups: [""]
34+
resources: ["configmaps"]
35+
verbs: ["create", "get", "update", "delete"]
3336
{{- end }}

cockroachdb/templates/role.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,25 @@ rules:
2020
{{- else }}
2121
verbs: ["create", "get"]
2222
{{- end }}
23+
- apiGroups: [""]
24+
resources: ["nodes"]
25+
verbs: ["get", "list", "watch"]
26+
---
27+
kind: ClusterRole
28+
apiVersion: rbac.authorization.k8s.io/v1
29+
metadata:
30+
name: {{ template "cockroachdb.fullname" . }}-node-reader
31+
namespace: {{ .Release.Namespace | quote }}
32+
labels:
33+
helm.sh/chart: {{ template "cockroachdb.chart" . }}
34+
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
35+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
36+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
37+
{{- with .Values.labels }}
38+
{{- toYaml . | nindent 4 }}
39+
{{- end }}
40+
rules:
41+
- apiGroups: [""]
42+
resources: ["nodes"]
43+
verbs: ["get", "list", "watch"]
2344
{{- end }}

cockroachdb/templates/rolebinding.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,26 @@ subjects:
2020
- kind: ServiceAccount
2121
name: {{ template "cockroachdb.serviceAccount.name" . }}
2222
namespace: {{ .Release.Namespace | quote }}
23+
---
24+
kind: ClusterRoleBinding
25+
apiVersion: rbac.authorization.k8s.io/v1
26+
metadata:
27+
name: {{ template "cockroachdb.fullname" . }}-node-reader
28+
namespace: {{ .Release.Namespace | quote }}
29+
labels:
30+
helm.sh/chart: {{ template "cockroachdb.chart" . }}
31+
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
32+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
33+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
34+
{{- with .Values.labels }}
35+
{{- toYaml . | nindent 4 }}
36+
{{- end }}
37+
roleRef:
38+
apiGroup: rbac.authorization.k8s.io
39+
kind: ClusterRole
40+
name: {{ template "cockroachdb.fullname" . }}-node-reader
41+
subjects:
42+
- kind: ServiceAccount
43+
name: {{ template "cockroachdb.serviceAccount.name" . }}
44+
namespace: {{ .Release.Namespace | quote }}
2345
{{- end }}

cockroachdb/templates/service.discovery.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# the StatefulSet such that they can resolve each other's IP addresses.
33
# It does not create a load-balanced ClusterIP and should not be used directly
44
# by clients in most circumstances.
5+
{{- if not .Values.operator.enabled }}
56
kind: Service
67
apiVersion: v1
78
metadata:
@@ -62,3 +63,4 @@ spec:
6263
{{- with .Values.statefulset.labels }}
6364
{{- toYaml . | nindent 4 }}
6465
{{- end }}
66+
{{- end }}

cockroachdb/templates/service.public.yaml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,33 @@ metadata:
3030
{{- end }}
3131
{{- end }}
3232
spec:
33+
selector:
34+
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
35+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
36+
{{- if .Values.operator.enabled }}
37+
{{- with .Values.operator.podLabels }}
38+
{{- toYaml . | nindent 4 }}
39+
{{- end }}
40+
# Cockroach Cloud operator doesn't provide a way to change the sql,grpc and http ports for the pods. Hence, making these
41+
# ports static here.
42+
type: ClusterIP
43+
ports:
44+
- name: sql
45+
port: 26257
46+
protocol: TCP
47+
targetPort: 26257
48+
- name: grpc
49+
port: 26258
50+
protocol: TCP
51+
targetPort: 26258
52+
- name: http
53+
port: 8080
54+
protocol: TCP
55+
targetPort: 8080
56+
{{- else }}
57+
{{- with .Values.statefulset.labels }}
58+
{{- toYaml . | nindent 4 }}
59+
{{- end }}
3360
type: {{ .Values.service.public.type | quote }}
3461
ports:
3562
{{- $ports := .Values.service.ports }}
@@ -47,9 +74,4 @@ spec:
4774
- name: {{ $ports.http.name | quote }}
4875
port: {{ $ports.http.port | int64 }}
4976
targetPort: http
50-
selector:
51-
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
52-
app.kubernetes.io/instance: {{ .Release.Name | quote }}
53-
{{- with .Values.statefulset.labels }}
54-
{{- toYaml . | nindent 4 }}
55-
{{- end }}
77+
{{- end }}

0 commit comments

Comments
 (0)