• Stars
    star
    264
  • Rank 149,662 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

k8s operator for CRDB

CockroachDB Kubernetes Operator

The CockroachDB Kubernetes Operator deploys CockroachDB on a Kubernetes cluster. You can use the Operator to manage the configuration of a running CockroachDB cluster, including:

  • Authenticating certificates
  • Configuring resource requests and limits
  • Scaling the cluster
  • Performing a rolling upgrade

Build Status

GKE Nightly: GKE Nightly

OpenShift Nightly: OpenShift Nightly

Limitations

Prerequisites

  • Kubernetes 1.18 or higher
  • kubectl
  • A GKE cluster (n2-standard-4 is the minimum requirement for testing)

Install the Operator

Apply the custom resource definition (CRD) for the Operator:

kubectl apply -f https://raw.githubusercontent.com/cockroachdb/cockroach-operator/master/install/crds.yaml

Apply the Operator manifest. By default, the Operator is configured to install in the cockroach-operator-system namespace. To use the Operator in a custom namespace, download the Operator manifest and edit all instances of namespace: cockroach-operator-system to specify your custom namespace. Then apply this version of the manifest to the cluster with kubectl apply -f {local-file-path} instead of using the command below.

kubectl apply -f https://raw.githubusercontent.com/cockroachdb/cockroach-operator/master/install/operator.yaml

Validate that the Operator is running:

kubectl get pods
NAME                                  READY   STATUS    RESTARTS   AGE
cockroach-operator-6f7b86ffc4-9ppkv   1/1     Running   0          54s

Start CockroachDB

Download the example.yaml custom resource.

Note: The latest stable CockroachDB release is specified by default in image.name.

Resource requests and limits

By default, the Operator allocates 2 CPUs and 8Gi memory to CockroachDB in the Kubernetes pods. These resources are appropriate for n2-standard-4 (GCP) and m5.xlarge (AWS) machines.

On a production deployment, you should modify the resources.requests object in the custom resource with values appropriate for your workload. For details, see the CockroachDB documentation.

Certificate signing

The Operator generates and approves 1 root and 1 node certificate for the cluster.

Apply the custom resource

Apply example.yaml:

kubectl create -f example.yaml

Check that the pods were created:

kubectl get pods
NAME                                  READY   STATUS    RESTARTS   AGE
cockroach-operator-6f7b86ffc4-9t9zb   1/1     Running   0          3m22s
cockroachdb-0                         1/1     Running   0          2m31s
cockroachdb-1                         1/1     Running   0          102s
cockroachdb-2                         1/1     Running   0          46s

Each pod should have READY status soon after being created.

Access the SQL shell

To use the CockroachDB SQL client, first launch a secure pod running the cockroach binary.

kubectl create -f https://raw.githubusercontent.com/cockroachdb/cockroach-operator/master/examples/client-secure-operator.yaml

Get a shell into the client pod:

kubectl exec -it cockroachdb-client-secure -- ./cockroach sql --certs-dir=/cockroach/cockroach-certs --host=cockroachdb-public

If you want to access the DB Console, create a SQL user with a password while you're here:

CREATE USER roach WITH PASSWORD 'Q7gc8rEdS';

Then assign roach to the admin role to enable access to secure DB Console pages:

GRANT admin TO roach;
\q

Access the DB Console

To access the cluster's DB Console, port-forward from your local machine to the cockroachdb-public service:

kubectl port-forward service/cockroachdb-public 8080

Access the DB Console at https://localhost:8080.

Scale the CockroachDB cluster

Note: Due to a known issue, automatic pruning of PVCs is currently disabled by default. This means that after decommissioning and removing a node, the Operator will not remove the persistent volume that was mounted to its pod. If you plan to eventually scale up the cluster after scaling down, you will need to manually delete any PVCs that were orphaned by node removal before scaling up. For more information, see the documentation.

To scale the cluster up and down, modify nodes in the custom resource. For details, see the CockroachDB documentation.

Do not scale down to fewer than 3 nodes. This is considered an anti-pattern on CockroachDB and will cause errors.

Note: You must scale by updating the nodes value in the Operator configuration. Using kubectl scale statefulset <cluster-name> --replicas=4 will result in new pods immediately being terminated.

Upgrade the CockroachDB cluster

Perform a rolling upgrade by changing image.name in the custom resource. For details, see the CockroachDB documentation.

Stop the CockroachDB cluster

Delete the custom resource:

kubectl delete -f example.yaml

Remove the Operator:

kubectl delete -f https://raw.githubusercontent.com/cockroachdb/cockroach-operator/master/manifests/operator.yaml

Note: If you want to delete the persistent volumes and free up the storage used by CockroachDB, be sure you have a backup copy of your data. Data cannot be recovered once the persistent volumes are deleted. For more information, see the Kubernetes documentation.

Releases

We have a few phases to our releases. The first involves creating a new branch, updating the version, and then getting a PR merged into master with all of the generated files.

Subsequent steps will need to be carried out in TeamCity and RedHat Connect.

Creating a new release PR

From a clean, up-to-date master (seriously...check), run the following where <version> is the desired new version (e.g. 2.2.0).

$ make release/new VERSION=<version>
...
...
$ git push origin release-$(cat version.txt)

This will do the following for you:

  • Create a new branch named release-<version>
  • Update version.txt
  • Generate the manifest, bundles, etc.
  • Commit the changes with the message Bump version to <version>.
  • Push to a new branch on origin (that wasn't automated)

Tag the release

After the PR is merged run the following to create the tag (you'll need to be a member of CRL to do this).

git tag v$(cat version.txt)
git push upstream v$(cat version.txt)

Run Release Automation

From here, the rest of the release process is done with TeamCity. A CRL team member will need to perform some manual steps in RedHat Connect as well. Ping one of us in Slack for info.

More Repositories

1

cockroach

CockroachDB - the open source, cloud-native distributed SQL database.
Go
29,128
star
2

pebble

RocksDB/LevelDB inspired key-value database in Go
Go
4,455
star
3

errors

Go error library with error portability over the network
Go
1,869
star
4

copyist

Mocking your SQL database in Go tests has never been easier.
Go
833
star
5

apd

Arbitrary-precision decimals for Go
Go
540
star
6

docs

CockroachDB user documentation
HTML
177
star
7

django-cockroachdb

CockroachDB Backend for Django
Python
155
star
8

sqlalchemy-cockroachdb

SQLAlchemy adapter for CockroachDB
Python
135
star
9

activerecord-cockroachdb-adapter

CockroachDB adapter for ActiveRecord.
Ruby
100
star
10

rpc-bench

Benchmarking various RPC implementations
Go
87
star
11

examples-orms

Sample uses of CockroachDB with popular ORMs
Go
82
star
12

helm-charts

Helm charts for cockroachdb
Go
81
star
13

examples-go

Sample uses of cockroachDB.
Go
75
star
14

terraform-provider-cockroach

Terraform provider for CockroachDB Cloud
Go
53
star
15

cdc-sink

cdc-sink is a toolkit for ingesting logical replication feeds into a CockroachDB cluster
Go
52
star
16

sequelize-cockroachdb

Use Sequelize and CockroachDB together
JavaScript
52
star
17

cockroachdb-todo-apps

CockroachDB To-Do Apps
Python
51
star
18

c-rocksdb

🚫 DEPRECATED
C++
46
star
19

datadriven

Data-Driven Testing for Go
Go
38
star
20

logtags

key/value annotations for Go contexts
Go
35
star
21

cockroach-gen

CockroachDB with pre-generated Go code
Go
33
star
22

movr

A fictional ride sharing company.
Python
32
star
23

loadgen

CockroachDB load generators
Go
30
star
24

k8s

Images and utilities to run cockroach on kubernetes
Go
26
star
25

redact

Utilities to redact Go strings for confidentiality
Go
25
star
26

c-snappy

C++
21
star
27

ui

Published assets for Cockroach Labs user interfaces
TypeScript
19
star
28

cockroachdb-parser

Apache licensed CockroachDB parser and dependencies.
Go
19
star
29

roachprod

Internal CockroachDB production testing tool
Go
15
star
30

cockroachdb-typescript

A modern cloud-native web app using TypeScript, React, Prisma, Netlify serverless functions, and CockroachDB
TypeScript
14
star
31

crlfmt

Formatter for CockroachDB's additions to the Go style guide.
Go
14
star
32

homebrew-tap

`brew install cockroachdb/tap/cockroach`
Ruby
14
star
33

c-protobuf

🚫 DEPRECATED: go-gettable version of google/protobuf
C++
13
star
34

watermill-crdb

CockroachDB Pub/Sub for the Watermill project.
Go
13
star
35

cockroachdb-cloudformation

Quickly setup dev/test CockroachDB clusters using AWS CloudFormation and Kubernetes
Shell
12
star
36

molt

Migrate Off Legacy Things - open-source tooling to assist migrations to CockroachDB.
Go
12
star
37

vendored

CockroachDB's vendored Go dependencies
Go
11
star
38

c-jemalloc

🚫 DEPRECATED
C
11
star
39

yacc

Fork of go yacc tool with increased hardcoded constants to handle larger grammars.
Go
11
star
40

examples-python

Sample uses of CockroachDB
Python
10
star
41

c-lz4

C
10
star
42

build-cache

Cache the installed output of go builds
Go
9
star
43

definitive_guide_sample_code

Sample code for The Definitive Guide to CockroachDB
JavaScript
8
star
44

quickstart-code-samples

Java
8
star
45

pcf-crdb-service-broker

Pivotal Cloud Foundry service broker for CockroachDB.
Go
8
star
46

dcos-cockroachdb-service

Framework for running CockroachDB on Mesosphere DC/OS
Python
8
star
47

backport

automatically backport pull requests
Go
7
star
48

cockroach-proto

Protocol Buffer
7
star
49

python-heroku-cockroachdb

A modern cloud-native web app using Python, Flask, Heroku, and CockroachDB
Python
7
star
50

walkabout

Walkabout generates visitor-pattern accessors for your existing go structs.
Go
6
star
51

sample-apps

6
star
52

nextjs-react-vercel-crdb-app

A CockroachDB sample app for coordinating social events using Next.js with react-bootstrap deployed on vercel
JavaScript
6
star
53

rksql

Fork of scaledata/rksql
Go
5
star
54

ddshop

TodoMVC app for distributed database workshop
JavaScript
5
star
55

postgres-test

Dockerfile
5
star
56

benchviz

A tool used for visualizing results from benchmark tests over time.
Go
5
star
57

stress

A fork of Golang's stress function.
Go
5
star
58

cockroach-cloud-sdk-go

Go client SDK for CockroachDB Cloud
Mustache
5
star
59

example-app-rust-postgres

Rust
4
star
60

protoc-gen-gogoroach

protoc (protobuf compiler) plugin for CockroachDB protobuf files
Go
4
star
61

generated-diagrams

HTML
4
star
62

roachspeed

codespeed instance
Python
4
star
63

hibernate-savepoint-fix

Java
4
star
64

scripts

Utility and helper scripts for CockroachDB contributors -
Vim Script
4
star
65

go-lab

Scripts and test programs to reveal what happens under the hood in Go.
Go
4
star
66

yarn-vendored

CockroachDB's vendored JavaScript dependencies
3
star
67

cockroachdb.github.io

Supporting static content for CockroachDB
JavaScript
3
star
68

cgo_static_boom

cgo static binary boom
Go
3
star
69

docs-docker

Docker image for the docs build
3
star
70

libedit

CockroachDB fork of the libedit terminal line-editing library
3
star
71

gostdlib

Vendor-friendly Go standard library packages
Go
3
star
72

dev

A utility for performing common CockroachDB development tasks
3
star
73

example-app-python-psycopg3

Simple CRUD application in Python using the psycopg3 driver.
Python
3
star
74

scp-interview

Shell
3
star
75

efcore.pg.cockroach

C#
3
star
76

university-event-driven-architecture-for-java-developers-app-exercises

Exercise code for Cockroach University - Event Driven Architecture for Java Developers
Java
3
star
77

bincheck

Verify CockroachDB binaries
Shell
3
star
78

eddie

Big Eddie, the golang contract enforcer
Go
3
star
79

roachperf-og

🚫 Deprecated CockroachDB performance tool β€” use roachprod instead!
Go
3
star
80

university-getting-started-with-sql-app-exercises

Exercise code for the Cockroach University - Getting Started with SQL for Application Developers course
Shell
3
star
81

jsonb-spec

Acceptance tests/spec for CockroachDB JSONB support, complement to scoping RFC
JavaScript
3
star
82

social-events-app

JavaScript
3
star
83

ttycolor

Conditionally expose ANSI color codes for use on a terminal
Go
2
star
84

admin-ui-components

Shared frontend components between the CRDB Admin UI and other apps
TypeScript
2
star
85

rails-crdb-app

A CockroachDB leaderboard sample application using Rails deployed on Heroku
Ruby
2
star
86

fullstack-node-cockroachdb-app

Fullstack sample application in Node.js using Sequelize
JavaScript
2
star
87

university-multi-region-course-app-exercises

exercise code for the cockroach university multi-region course
Java
2
star
88

go-plus

API library for CRL's custom Go extensions
Go
2
star
89

tokenbucket

Token bucket implementation in Go
Go
2
star
90

homebrew-go

🚫 DEPRECATED 🚫 β€” use `brew install go` instead
Ruby
2
star
91

build-utils

🚫 DEPRECATED: Build utilities for CockroachDB
Go
2
star
92

psycopg2-cockroachdb

Testing psycopg2 against cockroachdb
Shell
2
star
93

katacoda

In-browser, interactive tutorials on CockroachDB
Shell
2
star
94

cockroachdb-hibernate

Package to improve compatibility between CockroachDB and Hibernate
2
star
95

pulumi-poc

Demo of simple control plane built on top of Pulumi.
Go
2
star
96

avrogen

Avro generator for import testing
Go
1
star
97

redcarpet-extender

Extends the Redcarpet Markdown parser to handle CockroachDB documentation
1
star
98

s3checker

Check s3 support for bulk operations
Go
1
star
99

university-getting-started-with-node-postgres-app-exercises

JavaScript
1
star
100

university-multi-region-latency-exercises

Optimizing latency in multi-region database course exercise code
Shell
1
star