Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
To learn more about this project, read the wiki.

CockroachDB configuration preparation

These steps reproduce how to generate Cockroach manifest files used in TeraFlowSDN and apply them to MicroK8s. For stability reasons, we fix the versions providing the manifest files. In future releases of TeraFlowSDN, we might consider dynamically downloading and modifying the files.

Steps:

DEPLOY_PATH="manifests/cockroachdb" OPERATOR_BASE_URL="https://raw.githubusercontent.com/cockroachdb/cockroach-operator/master"

mkdir -p ${DEPLOY_PATH}

Apply Custom Resource Definition for the CockroachDB Operator

curl -o "

DEPLOYPATH/crds.yaml""{DEPLOY_PATH}/crds.yaml" "
{OPERATOR_BASE_URL}/install/crds.yaml" kubectl apply -f "${DEPLOY_PATH}/crds.yaml"

Deploy CockroachDB Operator

curl -o "

DEPLOYPATH/operator.yaml""{DEPLOY_PATH}/operator.yaml" "
{OPERATOR_BASE_URL}/install/operator.yaml" nano "${DEPLOY_PATH}/operator.yaml"

- add env var: WATCH_NAMESPACE=%TFS_CRDB_NAMESPACE%

sed s/%TFS_CRDB_NAMESPACE%/crdb/g ${DEPLOY_PATH}/operator.yaml >

DEPLOYPATH/tfscrdboperator.yamlkubectlapplyf"{DEPLOY_PATH}/tfs_crdb_operator.yaml kubectl apply -f "
{DEPLOY_PATH}/tfs_crdb_operator.yaml"

Deploy CockroachDB

curl -o "

DEPLOYPATH/cluster.yaml""{DEPLOY_PATH}/cluster.yaml" "
{OPERATOR_BASE_URL}/examples/example.yaml" nano "${DEPLOY_PATH}/cluster.yaml"

- set version

- set number of replicas

kubectl create namespace crdb kubectl apply --namespace crdb -f "${DEPLOY_PATH}/cluster.yaml"

Deploy CockroachDB Client

curl -o "

DEPLOYPATH/clientsecureoperator.yaml""{DEPLOY_PATH}/client-secure-operator.yaml" "
{OPERATOR_BASE_URL}/examples/client-secure-operator.yaml" kubectl create --namespace crdb -f "${DEPLOY_PATH}/client-secure-operator.yaml"

Add tfs user with admin rights

kubectl exec -it cockroachdb-client-secure --namespace crdb -- ./cockroach sql --certs-dir=/cockroach/cockroach-certs --host=cockroachdb-public CREATE USER tfs WITH PASSWORD 'tfs123'; GRANT admin TO tfs;

Expose CockroachDB SQL port (26257)

PORT=

There was an error rendering this math block. KaTeX parse error: Expected '}', got 'EOF' at end of input: …H='{"data": {"'
{PORT}'": "crdb/cockroachdb-public:'
There was an error rendering this math block. KaTeX parse error: Expected 'EOF', got '}' at position 9: {PORT}'"}̲}' kubectl patc…
{PATCH}"

PORT_MAP='{"containerPort": '

PORT,"hostPort":{PORT}', "hostPort": '
{PORT}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['
There was an error rendering this math block. KaTeX parse error: Expected 'EOF', got '}' at position 13: {PORT_MAP}']}̲' PATCH='{"spec…
{CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}"

Expose CockroachDB Console port (8080)

PORT=

There was an error rendering this math block. KaTeX parse error: Expected '}', got 'EOF' at end of input: …H='{"data": {"'
{PORT}'": "crdb/cockroachdb-public:'
There was an error rendering this math block. KaTeX parse error: Expected 'EOF', got '}' at position 9: {PORT}'"}̲}' kubectl patc…
{PATCH}"

PORT_MAP='{"containerPort": '

PORT,"hostPort":{PORT}', "hostPort": '
{PORT}'}' CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['
There was an error rendering this math block. KaTeX parse error: Expected 'EOF', got '}' at position 13: {PORT_MAP}']}̲' PATCH='{"spec…
{CONTAINER}']}}}}' kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}"