All
kubectl steps should be performed in the . By default, this is cockroach-operator-system.Memory and CPU
You can set the CPU and memory resources allocated to the CockroachDB container on each pod.1 CPU in Kubernetes is equivalent to 1 vCPU or 1 hyperthread. For best practices on provisioning CPU and memory for CockroachDB, see the .
resources.requests and resources.limits in the Public operator’s custom resource, which is used to :
resources.requests and resources.limits in the StatefulSet manifest you used to :
resources.requests and resources.limits in the custom values file you created when :
resources.requests and resources.limits. When setting the new values, note that not all of a pod’s resources will be available to the CockroachDB container. This is because a fraction of the CPU and memory is reserved for Kubernetes.
If no resource limits are specified, the pods will be able to consume the maximum available CPUs and memory. However, to avoid overallocating resources when another memory-intensive workload is on the same instance, always set resource requests and limits explicitly.
Cache and SQL memory size
Each CockroachDB node reserves a portion of its available memory for its cache and for storing temporary data for SQL queries. For more information on these settings, see the . Our Kubernetes manifests dynamically set cache size and SQL memory size each to 1/4 (the recommended fraction) of the available memory, which depends on the memory request and limit you specified for your configuration. If you want to customize these values, set them explicitly. Specifycache and maxSQLMemory in the Public operator’s custom resource, which is used to :
Specifying these values is equivalent to using the
--cache and --max-sql-memory flags with .Cache and SQL memory size
Each CockroachDB node reserves a portion of its available memory for its cache and for storing temporary data for SQL queries. For more information on these settings, see the . Our Kubernetes manifests dynamically set cache size and SQL memory size each to 1/4 (the recommended fraction) of the available memory, which depends on the memory request and limit you specified for your configuration. If you want to customize these values, set them explicitly. Specifycache and maxSQLMemory in the custom values file you created when :
Persistent storage
When you start your cluster, Kubernetes dynamically provisions and mounts a persistent volume into each pod. For more information on persistent volumes, see the Kubernetes documentation. The storage capacity of each volume is set inpvc.spec.resources in the Public operator’s custom resource, which is used to :
volumeClaimTemplates.spec.resources in the StatefulSet manifest you used to :
Expand disk size
If you discover that you need more capacity, you can expand the persistent volumes on a running cluster. Increasing disk size is often . Specify a new volume size inresources.requests and resources.limits in the Public operator’s custom resource, which is used to :
kubectl get pvc to view the persistent volume claims (PVCs). It will take a few minutes before the PVCs are completely updated.
You can expand certain types of persistent volumes (including GCE Persistent Disk and Amazon Elastic Block Store) by editing their persistent volume claims.
These steps assume you followed the tutorial Deploy CockroachDB on Kubernetes.
-
Get the persistent volume claims for the volumes:
-
In order to expand a persistent volume claim,
AllowVolumeExpansionin its storage class must betrue. Examine the storage class:If necessary, edit the storage class: - Edit one of the persistent volume claims to request more space:
The requested
storage value must be larger than the previous value. You cannot use this method to decrease the disk size.-
Check the capacity of the persistent volume claim:
If the PVC capacity has not changed, this may be because
AllowVolumeExpansionwas initially set tofalseor because the volume has a file system that has to be expanded. You will need to start or restart a pod in order to have it reflect the new capacity.
-
Examine the persistent volume claim. If the volume has a file system, you will see a
FileSystemResizePendingcondition with an accompanying message: -
Delete the corresponding pod to restart it:
The
FileSystemResizePendingcondition and message will be removed. -
View the updated persistent volume claim:
- The CockroachDB cluster needs to be expanded one node at a time. Repeat steps 3 - 6 to increase the capacities of the remaining volumes by the same amount.
-
Get the persistent volume claims for the volumes:
-
In order to expand a persistent volume claim,
AllowVolumeExpansionin its storage class must betrue. Examine the storage class:If necessary, edit the storage class: -
Edit one of the persistent volume claims to request more space:
The requested
storagevalue must be larger than the previous value. You cannot use this method to decrease the disk size. -
Check the capacity of the persistent volume claim:
If the PVC capacity has not changed, this may be because
AllowVolumeExpansionwas initially set tofalseor because the volume has a file system that has to be expanded. You will need to start or restart a pod in order to have it reflect the new capacity. Runningkubectl get pvwill display the persistent volumes with their requested capacity and not their actual capacity. This can be misleading, so it’s best to usekubectl get pvc. -
Examine the persistent volume claim. If the volume has a file system, you will see a
FileSystemResizePendingcondition with an accompanying message: -
Delete the corresponding pod to restart it:
The
FileSystemResizePendingcondition and message will be removed. -
View the updated persistent volume claim:
- The CockroachDB cluster needs to be expanded one node at a time. Repeat steps 3 - 6 to increase the capacities of the remaining volumes by the same amount.
Network ports
The Public operator separates network traffic into three ports:
Specify alternate port numbers in the Public operator’s (for example, to match the default port
5432 on PostgreSQL):
Currently, only the pods are updated with new ports. To connect to the cluster, you need to ensure that the
public service is also updated to use the new port. You can do this by deleting the service with kubectl delete service {cluster-name}-public. When service is recreated by the operator, it will use the new port. This is a known limitation.Ingress
You can configure an Ingress object to expose an internal HTTP or SQLClusterIP service through a hostname.
In order to use the Ingress resource, your cluster must be running an Ingress controller for load balancing. This is not handled by the Public operator and must be deployed separately.
Specify Ingress objects in ingress.ui (HTTP) or ingress.sql (SQL) in the Public operator’s custom resource, which is used to :
-
ingressClassNamespecifies theIngressClassof the Ingress controller. This example uses the nginx controller. -
The
hostmust be made publicly accessible. For example, create a route in Amazon Route 53, or add an entry to/etc/hoststhat maps the IP address of the Ingress controller to the hostname.
Multiple hosts can be mapped to the same Ingress controller IP.
- TCP connections for SQL clients must be enabled for the Ingress controller. For an example, see the nginx documentation.
Changing the SQL Ingress
host on a running deployment will cause a rolling restart of the cluster, due to new node certificates being generated for the SQL host.
