Orchestrate a Local Cluster with Kubernetes

On top of CockroachDB's built-in automation, you can use a third-party orchestration system to simplify and automate even more of your operations, from deployment to scaling to overall cluster management.

This page walks you through a simple demonstration, using the open-source Kubernetes orchestration system. Using either the CockroachDB Helm chart or a few configuration files, you'll quickly create a 3-node local cluster. You'll run some SQL commands against the cluster and then simulate node failure, watching how Kubernetes auto-restarts without the need for any manual intervention. You'll then scale the cluster with a single command before shutting the cluster down, again with a single command.

Note:

To orchestrate a physically distributed cluster in production, see Orchestrated Deployments.

Before you begin

Before getting started, it's helpful to review some Kubernetes-specific terminology:

FeatureDescription
minikubeThis is the tool you'll use to run a Kubernetes cluster inside a VM on your local workstation.
podA pod is a group of one of more Docker containers. In this tutorial, all pods will run on your local workstation, each containing one Docker container running a single CockroachDB node. You'll start with 3 pods and grow to 4.
StatefulSetA StatefulSet is a group of pods treated as stateful units, where each pod has distinguishable network identity and always binds back to the same persistent storage on restart. StatefulSets are considered stable as of Kubernetes version 1.9 after reaching beta in version 1.5.
persistent volumeA persistent volume is a piece of storage mounted into a pod. The lifetime of a persistent volume is decoupled from the lifetime of the pod that's using it, ensuring that each CockroachDB node binds back to the same storage on restart.When using minikube, persistent volumes are external temporary directories that endure until they are manually deleted or until the entire Kubernetes cluster is deleted.
persistent volume claimWhen pods are created (one per CockroachDB node), each pod will request a persistent volume claim to “claim” durable storage for its node.

Step 1. Start Kubernetes

  • Follow Kubernetes' documentation to install minikube, the tool used to run Kubernetes locally, for your OS. This includes installing a hypervisor and kubectl, the command-line tool used to managed Kubernetes from your local workstation.

Note:
Make sure you install minikube version 0.21.0 or later. Earlier versions do not include a Kubernetes server that supports the maxUnavailability field and PodDisruptionBudget resource type used in the CockroachDB StatefulSet configuration.

  • Start a local Kubernetes cluster:
  1. $ minikube start

Step 2. Start CockroachDB

To start your CockroachDB cluster, you can either use our StatefulSet configuration and related files directly, or you can use the Helm package manager for Kubernetes to simplify the process.

Note:

If you want to use a different certificate authority than the one Kubernetes uses, or if your Kubernetes cluster doesn't fully support certificate-signing requests (e.g., in Amazon EKS), use these configuration files instead of the ones referenced below.

  • From your local workstation, use our cockroachdb-statefulset-secure.yaml file to create the StatefulSet that automatically creates 3 pods, each with a CockroachDB node running inside it:
  1. $ kubectl create -f https://raw.githubusercontent.com/cockroachdb/cockroach/master/cloud/kubernetes/cockroachdb-statefulset-secure.yaml
  1. serviceaccount "cockroachdb" created
  2. role "cockroachdb" created
  3. clusterrole "cockroachdb" created
  4. rolebinding "cockroachdb" created
  5. clusterrolebinding "cockroachdb" created
  6. service "cockroachdb-public" created
  7. service "cockroachdb" created
  8. poddisruptionbudget "cockroachdb-budget" created
  9. statefulset "cockroachdb" created

Alternatively, if you'd rather start with a configuration file that has been customized for performance:

  1. $ curl -O https://raw.githubusercontent.com/cockroachdb/cockroach/master/cloud/kubernetes/performance/cockroachdb-statefulset-secure.yaml
  • Modify the file wherever there is a TODO comment.

  • Use the file to create the StatefulSet and start the cluster:

  1. $ kubectl create -f cockroachdb-statefulset-secure.yaml
  • As each pod is created, it issues a Certificate Signing Request, or CSR, to have the node's certificate signed by the Kubernetes CA. You must manually check and approve each node's certificates, at which point the CockroachDB node is started in the pod.

    • Get the name of the Pending CSR for the first pod:
  1. $ kubectl get csr
  1. NAME AGE REQUESTOR CONDITION
  2. default.node.cockroachdb-0 1m system:serviceaccount:default:default Pending
  3. node-csr-0Xmb4UTVAWMEnUeGbW4KX1oL4XV_LADpkwjrPtQjlZ4 4m kubelet Approved,Issued
  4. node-csr-NiN8oDsLhxn0uwLTWa0RWpMUgJYnwcFxB984mwjjYsY 4m kubelet Approved,Issued
  5. node-csr-aU78SxyU69pDK57aj6txnevr7X-8M3XgX9mTK0Hso6o 5m kubelet Approved,Issued

If you do not see a Pending CSR, wait a minute and try again.

  • Examine the CSR for the first pod:
  1. $ kubectl describe csr default.node.cockroachdb-0
  1. Name: default.node.cockroachdb-0
  2. Labels: <none>
  3. Annotations: <none>
  4. CreationTimestamp: Thu, 09 Nov 2017 13:39:37 -0500
  5. Requesting User: system:serviceaccount:default:default
  6. Status: Pending
  7. Subject:
  8. Common Name: node
  9. Serial Number:
  10. Organization: Cockroach
  11. Subject Alternative Names:
  12. DNS Names: localhost
  13. cockroachdb-0.cockroachdb.default.svc.cluster.local
  14. cockroachdb-public
  15. IP Addresses: 127.0.0.1
  16. 10.48.1.6
  17. Events: <none>
  • If everything looks correct, approve the CSR for the first pod:
  1. $ kubectl certificate approve default.node.cockroachdb-0
  1. certificatesigningrequest "default.node.cockroachdb-0" approved
  • Repeat steps 1-3 for the other 2 pods.
  • Initialize the cluster:

    • Confirm that three pods are Running successfully. Note that they will notbe considered Ready until after the cluster has been initialized:
  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. cockroachdb-0 0/1 Running 0 2m
  3. cockroachdb-1 0/1 Running 0 2m
  4. cockroachdb-2 0/1 Running 0 2m
  • Confirm that the persistent volumes and corresponding claims were created successfully for all three pods:
  1. $ kubectl get persistentvolumes
  1. NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM REASON AGE
  2. pvc-52f51ecf-8bd5-11e6-a4f4-42010a800002 1Gi RWO Delete Bound default/datadir-cockroachdb-0 26s
  3. pvc-52fd3a39-8bd5-11e6-a4f4-42010a800002 1Gi RWO Delete Bound default/datadir-cockroachdb-1 27s
  4. pvc-5315efda-8bd5-11e6-a4f4-42010a800002 1Gi RWO Delete Bound default/datadir-cockroachdb-2 27s
  1. $ kubectl create -f https://raw.githubusercontent.com/cockroachdb/cockroach/master/cloud/kubernetes/cluster-init-secure.yaml
  1. job "cluster-init-secure" created
  • Approve the CSR for the one-off pod from which cluster initialization happens:
  1. $ kubectl certificate approve default.client.root
  1. certificatesigningrequest "default.client.root" approved
  • Confirm that cluster initialization has completed successfully. The jobshould be considered successful and the CockroachDB pods should soon beconsidered Ready:
  1. $ kubectl get job cluster-init-secure
  1. NAME DESIRED SUCCESSFUL AGE
  2. cluster-init-secure 1 1 2m
  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. cockroachdb-0 1/1 Running 0 3m
  3. cockroachdb-1 1/1 Running 0 3m
  4. cockroachdb-2 1/1 Running 0 3m

Tip:

The StatefulSet configuration sets all CockroachDB nodes to log to stderr, so if you ever need access to a pod/node's logs to troubleshoot, use kubectl logs <podname> rather than checking the log on the persistent volume.

In the likely case that your Kubernetes cluster uses RBAC (e.g., if you are using GKE), you need to create RBAC resources to grant Tiller access to the Kubernetes API:

  • Create a rbac-config.yaml file to define a role and service account:
  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: tiller
  5. namespace: kube-system
  6. ---
  7. apiVersion: rbac.authorization.k8s.io/v1
  8. kind: ClusterRoleBinding
  9. metadata:
  10. name: tiller
  11. roleRef:
  12. apiGroup: rbac.authorization.k8s.io
  13. kind: ClusterRole
  14. name: cluster-admin
  15. subjects:
  16. - kind: ServiceAccount
  17. name: tiller
  18. namespace: kube-system
  • Create the service account:
  1. $ kubectl create -f rbac-config.yaml
  1. serviceaccount "tiller" created
  2. clusterrolebinding "tiller" created
  • Start the Helm server:
  1. $ helm init --service-account tiller
  • Install the CockroachDB Helm chart, providing a "release" name to identify and track this particular deployment of the chart and setting the Secure.Enabled parameter to true:

Note:

This tutorial uses my-release as the release name. If you use a different value, be sure to adjust the release name in subsequent commands.

  1. $ helm install --name my-release --set Secure.Enabled=true stable/cockroachdb

Behind the scenes, this command uses our cockroachdb-statefulset.yaml file to create the StatefulSet that automatically creates 3 pods, each with a CockroachDB node running inside it, where each pod has distinguishable network identity and always binds back to the same persistent storage on restart.

Note:

You can customize your deployment by passing additional configuration parameters to helm install using the —set key=value[,key=value] flag. For a production cluster, you should consider modifying the Storage and StorageClass parameters. This chart defaults to 100 GiB of disk space per pod, but you may want more or less depending on your use case, and the default persistent volume StorageClass in your environment may not be what you want for a database (e.g., on GCE and Azure the default is not SSD).

  • As each pod is created, it issues a Certificate Signing Request, or CSR, to have the node's certificate signed by the Kubernetes CA. You must manually check and approve each node's certificates, at which point the CockroachDB node is started in the pod.

    • Get the name of the Pending CSR for the first pod:
  1. $ kubectl get csr
  1. NAME AGE REQUESTOR CONDITION
  2. default.client.root 21s system:serviceaccount:default:my-release-cockroachdb Pending
  3. default.node.my-release-cockroachdb-0 15s system:serviceaccount:default:my-release-cockroachdb Pending
  4. default.node.my-release-cockroachdb-1 16s system:serviceaccount:default:my-release-cockroachdb Pending
  5. default.node.my-release-cockroachdb-2 15s system:serviceaccount:default:my-release-cockroachdb Pending

If you do not see a Pending CSR, wait a minute and try again.

  • Examine the CSR for the first pod:
  1. $ kubectl describe csr default.node.my-release-cockroachdb-0
  1. Name: default.node.my-release-cockroachdb-0
  2. Labels: <none>
  3. Annotations: <none>
  4. CreationTimestamp: Mon, 10 Dec 2018 05:36:35 -0500
  5. Requesting User: system:serviceaccount:default:my-release-cockroachdb
  6. Status: Pending
  7. Subject:
  8. Common Name: node
  9. Serial Number:
  10. Organization: Cockroach
  11. Subject Alternative Names:
  12. DNS Names: localhost
  13. my-release-cockroachdb-0.my-release-cockroachdb.default.svc.cluster.local
  14. my-release-cockroachdb-0.my-release-cockroachdb
  15. my-release-cockroachdb-public
  16. my-release-cockroachdb-public.default.svc.cluster.local
  17. IP Addresses: 127.0.0.1
  18. 10.48.1.6
  19. Events: <none>
  • If everything looks correct, approve the CSR for the first pod:
  1. $ kubectl certificate approve default.node.my-release-cockroachdb-0
  1. certificatesigningrequest "default.node.my-release-cockroachdb-0" approved
  • Repeat steps 1-3 for the other 2 pods.
  • Confirm that three pods are Running successfully:
  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. my-release-cockroachdb-0 0/1 Running 0 6m
  3. my-release-cockroachdb-1 0/1 Running 0 6m
  4. my-release-cockroachdb-2 0/1 Running 0 6m
  5. my-release-cockroachdb-init-hxzsc 0/1 Init:0/1 0 6m
  • Approve the CSR for the one-off pod from which cluster initialization happens:
  1. $ kubectl certificate approve default.client.root
  1. certificatesigningrequest "default.client.root" approved
  • Confirm that cluster initialization has completed successfully, with each pod showing 1/1 under READY:
  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. my-release-cockroachdb-0 1/1 Running 0 8m
  3. my-release-cockroachdb-1 1/1 Running 0 8m
  4. my-release-cockroachdb-2 1/1 Running 0 8m
  • Confirm that the persistent volumes and corresponding claims were created successfully for all three pods:
  1. $ kubectl get persistentvolumes
  1. NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
  2. pvc-71019b3a-fc67-11e8-a606-080027ba45e5 100Gi RWO Delete Bound default/datadir-my-release-cockroachdb-0 standard 11m
  3. pvc-7108e172-fc67-11e8-a606-080027ba45e5 100Gi RWO Delete Bound default/datadir-my-release-cockroachdb-1 standard 11m
  4. pvc-710dcb66-fc67-11e8-a606-080027ba45e5 100Gi RWO Delete Bound default/datadir-my-release-cockroachdb-2 standard 11m

Tip:

The StatefulSet configuration sets all CockroachDB nodes to log to stderr, so if you ever need access to a pod/node's logs to troubleshoot, use kubectl logs <podname> rather than checking the log on the persistent volume.

Step 3. Use the built-in SQL client

To use the built-in SQL client, you need to launch a pod that runs indefinitely with the cockroach binary inside it, get a shell into the pod, and then start the built-in SQL client.

  • From your local workstation, use our client-secure.yaml file to launch a pod and keep it running indefinitely:
  1. $ kubectl create -f https://raw.githubusercontent.com/cockroachdb/cockroach/master/cloud/kubernetes/client-secure.yaml
  1. pod "cockroachdb-client-secure" created

The pod uses the root client certificate created earlier to initialize the cluster, so there's no CSR approval required.

  1. $ kubectl exec -it cockroachdb-client-secure -- ./cockroach sql --certs-dir=/cockroach-certs --host=cockroachdb-public
  1. # Welcome to the cockroach SQL interface.
  2. # All statements must be terminated by a semicolon.
  3. # To exit: CTRL + D.
  4. #
  5. # Server version: CockroachDB CCL v1.1.2 (linux amd64, built 2017/11/02 19:32:03, go1.8.3) (same version as client)
  6. # Cluster ID: 3292fe08-939f-4638-b8dd-848074611dba
  7. #
  8. # Enter \? for a brief introduction.
  9. #
  10. root@cockroachdb-public:26257/>
  1. > CREATE DATABASE bank;
  1. > CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL);
  1. > INSERT INTO bank.accounts VALUES (1, 1000.50);
  1. > SELECT * FROM bank.accounts;
  1. +----+---------+
  2. | id | balance |
  3. +----+---------+
  4. | 1 | 1000.5 |
  5. +----+---------+
  6. (1 row)
  1. > CREATE USER roach WITH PASSWORD 'Q7gc8rEdS';

You will need this username and password to access the Admin UI later.

  • Exit the SQL shell and pod:
  1. > \q
  • From your local workstation, use our client-secure.yaml file to launch a pod and keep it running indefinitely.

    • Download the file:
  1. $ curl -OOOOOOOOO \
  2. https://raw.githubusercontent.com/cockroachdb/cockroach/master/cloud/kubernetes/client-secure.yaml
  • In the file, change serviceAccountName: cockroachdb to serviceAccountName: my-release-cockroachdb.

  • Use the file to launch a pod and keep it running indefinitely:

  1. $ kubectl create -f client-secure.yaml
  1. pod "cockroachdb-client-secure" created

The pod uses the root client certificate created earlier to initialize the cluster, so there's no CSR approval required.

  1. $ kubectl exec -it cockroachdb-client-secure -- ./cockroach sql --certs-dir=/cockroach-certs --host=my-release-cockroachdb-public
  1. # Welcome to the cockroach SQL interface.
  2. # All statements must be terminated by a semicolon.
  3. # To exit: CTRL + D.
  4. #
  5. # Server version: CockroachDB CCL v1.1.2 (linux amd64, built 2017/11/02 19:32:03, go1.8.3) (same version as client)
  6. # Cluster ID: 3292fe08-939f-4638-b8dd-848074611dba
  7. #
  8. # Enter \? for a brief introduction.
  9. #
  10. root@my-release-cockroachdb-public:26257/>
  1. > CREATE DATABASE bank;
  1. > CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL);
  1. > INSERT INTO bank.accounts VALUES (1, 1000.50);
  1. > SELECT * FROM bank.accounts;
  1. +----+---------+
  2. | id | balance |
  3. +----+---------+
  4. | 1 | 1000.5 |
  5. +----+---------+
  6. (1 row)
  1. > CREATE USER roach WITH PASSWORD 'Q7gc8rEdS';

You will need this username and password to access the Admin UI later.

  • Exit the SQL shell and pod:
  1. > \q

Tip:

This pod will continue running indefinitely, so any time you need to reopen the built-in SQL client or run any other cockroach client commands (e.g., cockroach node), repeat step 2 using the appropriate cockroach command.

If you'd prefer to delete the pod and recreate it when needed, run kubectl delete pod cockroachdb-client-secure.

Step 4. Access the Admin UI

To access the cluster's Admin UI:

  • Port-forward from your local machine to one of the pods:
  1. $ kubectl port-forward cockroachdb-0 8080
  1. $ kubectl port-forward my-release-cockroachdb-0 8080
  1. Forwarding from 127.0.0.1:8080 -> 8080

Note:
The port-forward command must be run on the same machine as the web browser in which you want to view the Admin UI. If you have been running these commands from a cloud instance or other non-local shell, you will not be able to view the UI without configuring kubectl locally and running the above port-forward command on your local machine.

  • Go to https://localhost:8080 and log in with the username and password you created earlier.

  • In the UI, verify that the cluster is running as expected:

    • Click View nodes list on the right to ensure that all nodes successfully joined the cluster.
    • Click the Databases tab on the left to verify that bank is listed.

Step 5. Simulate node failure

Based on the replicas: 3 line in the StatefulSet configuration, Kubernetes ensures that three pods/nodes are running at all times. When a pod/node fails, Kubernetes automatically creates another pod/node with the same network identity and persistent storage.

To see this in action:

  • Kill one of CockroachDB nodes:
  1. $ kubectl delete pod cockroachdb-2
  1. pod "cockroachdb-2" deleted
  1. $ kubectl delete pod my-release-cockroachdb-2
  1. pod "my-release-cockroachdb-2" deleted
  • In the Admin UI, the Cluster Overview will soon show one node as Suspect. As Kubernetes auto-restarts the node, watch how the node once again becomes healthy.

  • Back in the terminal, verify that the pod was automatically restarted:

  1. $ kubectl get pod cockroachdb-2
  1. NAME READY STATUS RESTARTS AGE
  2. cockroachdb-2 1/1 Running 0 12s
  1. $ kubectl get pod my-release-cockroachdb-2
  1. NAME READY STATUS RESTARTS AGE
  2. my-release-cockroachdb-2 1/1 Running 0 44s

Step 6. Add nodes

  • Use the kubectl scale command to add a pod for another CockroachDB node:
  1. $ kubectl scale statefulset cockroachdb --replicas=4
  1. statefulset "cockroachdb" scaled
  1. $ kubectl scale statefulset my-release-cockroachdb --replicas=4
  1. statefulset "my-release-cockroachdb" scaled
  • Verify that the pod for a fourth node, cockroachdb-3, was added successfully:
  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. cockroachdb-0 1/1 Running 0 28m
  3. cockroachdb-1 1/1 Running 0 27m
  4. cockroachdb-2 1/1 Running 0 10m
  5. cockroachdb-3 1/1 Running 0 5s
  6. example-545f866f5-2gsrs 1/1 Running 0 25m
  1. NAME READY STATUS RESTARTS AGE
  2. my-release-cockroachdb-0 1/1 Running 0 28m
  3. my-release-cockroachdb-1 1/1 Running 0 27m
  4. my-release-cockroachdb-2 1/1 Running 0 10m
  5. my-release-cockroachdb-3 1/1 Running 0 5s
  6. example-545f866f5-2gsrs 1/1 Running 0 25m

Step 7. Remove nodes

To safely remove a node from your cluster, you must first decommission the node and only then adjust the —replicas value of your StatefulSet configuration to permanently remove it. This sequence is important because the decommissioning process lets a node finish in-flight requests, rejects any new requests, and transfers all range replicas and range leases off the node.

Warning:

If you remove nodes without first telling CockroachDB to decommission them, you may cause data or even cluster unavailability. For more details about how this works and what to consider before removing nodes, see Decommission Nodes.

  • Get a shell into the cockroachdb-client-secure pod you created earlier and use the cockroach node status command to get the internal IDs of nodes:
  1. $ kubectl exec -it cockroachdb-client-secure -- ./cockroach node status --certs-dir=/cockroach-certs --host=cockroachdb-public
  1. id | address | build | started_at | updated_at | is_available | is_live
  2. +----+---------------------------------------------------------------------------------+--------+----------------------------------+----------------------------------+--------------+---------+
  3. 1 | cockroachdb-0.cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 16:04:36.486082+00:00 | 2018-11-29 18:24:24.587454+00:00 | true | true
  4. 2 | cockroachdb-2.cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 16:55:03.880406+00:00 | 2018-11-29 18:24:23.469302+00:00 | true | true
  5. 3 | cockroachdb-1.cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 16:04:41.383588+00:00 | 2018-11-29 18:24:25.030175+00:00 | true | true
  6. 4 | cockroachdb-3.cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 17:31:19.990784+00:00 | 2018-11-29 18:24:26.041686+00:00 | true | true
  7. (4 rows)
  1. $ kubectl exec -it cockroachdb-client-secure -- ./cockroach node status --certs-dir=/cockroach-certs --host=my-release-cockroachdb-public
  1. id | address | build | started_at | updated_at | is_available | is_live
  2. +----+---------------------------------------------------------------------------------+--------+----------------------------------+----------------------------------+--------------+---------+
  3. 1 | my-release-cockroachdb-0.my-release-cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 16:04:36.486082+00:00 | 2018-11-29 18:24:24.587454+00:00 | true | true
  4. 2 | my-release-cockroachdb-2.my-release-cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 16:55:03.880406+00:00 | 2018-11-29 18:24:23.469302+00:00 | true | true
  5. 3 | my-release-cockroachdb-1.my-release-cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 16:04:41.383588+00:00 | 2018-11-29 18:24:25.030175+00:00 | true | true
  6. 4 | my-release-cockroachdb-3.my-release-cockroachdb.default.svc.cluster.local:26257 | v2.1.1 | 2018-11-29 17:31:19.990784+00:00 | 2018-11-29 18:24:26.041686+00:00 | true | true
  7. (4 rows)

The pod uses the root client certificate created earlier to initialize the cluster, so there's no CSR approval required.

  • Note the ID of the node with the highest number in its address (in this case, the address including cockroachdb-3) and use the cockroach node decommission command to decommission it:

Note:

It's important to decommission the node with the highest number in its address because, when you reduce the —replica count, Kubernetes will remove the pod for that node.

  1. $ kubectl exec -it cockroachdb-client-secure -- ./cockroach node decommission <node ID> --insecure --host=cockroachdb-public
  1. $ kubectl exec -it cockroachdb-client-secure -- ./cockroach node decommission <node ID> --insecure --host=my-release-cockroachdb-public

You'll then see the decommissioning status print to stderr as it changes:

  1. id | is_live | replicas | is_decommissioning | is_draining
  2. +---+---------+----------+--------------------+-------------+
  3. 4 | true | 73 | true | false
  4. (1 row)

Once the node has been fully decommissioned and stopped, you'll see a confirmation:

  1. id | is_live | replicas | is_decommissioning | is_draining
  2. +---+---------+----------+--------------------+-------------+
  3. 4 | true | 0 | true | false
  4. (1 row)
  5. No more data reported on target nodes. Please verify cluster health before removing the nodes.
  • Once the node has been decommissioned, use the kubectl scale command to remove a pod from your StatefulSet:
  1. $ kubectl scale statefulset cockroachdb --replicas=3
  1. statefulset "cockroachdb" scaled
  1. $ kubectl scale statefulset my-release-cockroachdb --replicas=3
  1. statefulset "my-release-cockroachdb" scaled

Step 8. Stop the cluster

  • If you plan to restart the cluster, use the minikube stop command. This shuts down the minikube virtual machine but preserves all the resources you created:
  1. $ minikube stop
  1. Stopping local Kubernetes cluster...
  2. Machine stopped.

You can restore the cluster to its previous state with minikube start.

  • If you do not plan to restart the cluster, use the minikube delete command. This shuts down and deletes the minikube virtual machine and all the resources you created, including persistent volumes:
  1. $ minikube delete
  1. Deleting local Kubernetes cluster...
  2. Machine deleted.

Tip:
To retain logs, copy them from each pod's stderr before deleting the cluster and all its resources. To access a pod's standard error stream, run kubectl logs <podname>.

See also

Explore other core CockroachDB benefits and features:

Was this page helpful?
YesNo