Open source Kubernetes
Create and manage a YugabyteDB cluster with a Kubernetes native custom resource
ybcluster.yugabyte.com. The custom resource definition and other necessary specifications can be found in YugabyteDB k8s operator repository . This operator currently provides more configuration flags as compared to the Rook operator. The Rook operator, in near future, will get these flags too. See full list of configuration flags here.
Clone yugabyte-k8s-operator repository on your local computer. Change into the cloned directory and follow instructions as below.
Deploy a YugabyteDB cluster with this operator
To create a YugabyteDB cluster, first you need to register the custom resource that would represent YugabyteDB cluster:
kubectl create -f deploy/crds/yugabyte_v1alpha1_ybcluster_crd.yaml
Setup RBAC for operator and create the operator itself. Run the following command, from root of the repository, to do the same.
kubectl create -f deploy/operator.yaml
After a few seconds the operator should be up & running. Verify the operator status by running following command.
kubectl -n yb-operator get po,deployment
Finally create an instance of the custom resource with which the operator would create a YugabyteDB cluster.
kubectl create -f deploy/crds/yugabyte_v1alpha1_ybcluster_cr.yaml
Verify that the cluster is up and running with the following command. You should see 3 pods each for YB-Master and YB-TServer services.
kubectl get po,sts,svc
Once the cluster is up and running, you may start the YSQL API and start executing relational queries.
kubectl exec -it yb-tserver-0 -- ysqlsh -h yb-tserver-0 --echo-queries
You can also connect to the YCQL API as shown below.
kubectl exec -it yb-tserver-0 -- ycqlsh yb-tserver-0
Mention YugabyteDB Docker image attributes such as
Specify the required data replication factor. This is a required field.
Enable TLS encryption for YugabyteDB, if desired. It is disabled by default. You can enable the TLS encryption with 3 flags, explained later. If you have set
enabled to true, then you need to generate root certificate and key. Specify the two under
rootCA.key. Refer to TLS encryption docs (through the
Generate root configuration section) for how to generate the certificate and key files.
YB-Master and YB-TServer
YB-Master and YB-TServer are two essential components of a YugabyteDB cluster. YB-Master is responsible for recording and maintaining system metadata & for admin activities. YB-TServer is responsible for data I/O.
Specify YB-Master and YB-TServer attributes under
tserver. The valid attributes are as described below. These two are required fields.
Specify count of pods for
replicas field. This is a required field.
Control network configuration for Master & TServer, each of which support only a selected port attributes. Below table depicts the supported port attributes.
Note that these are optional fields, except
tserver.tserverUIPort, hence below table also mentions default values for each port. Default network configuration will be used, if any or all of the acceptable fields are absent.
A ClusterIP service will be created when
tserver.tserverUIPort port is specified. If it is not specified, only StatefulSet & headless service will be created for TServer. ClusterIP service creation will be skipped. Whereas for Master, all 3 kubernetes objects will always be created.
master.enableLoadBalancer is set to
true, then master UI service will be of type
LoadBalancer. TServer UI service will be of type
tserver.tserverUIPort is specified and
tserver.enableLoadBalancer is set to
tserver.enableLoadBalancer will be ignored if
tserver.tserverUIPort is not specified.
Table depicting acceptable port names, applicable component (Master/TServer) and port default values:
Specify pod management policy for Statefulsets created as part of YugabyteDB cluster. Valid values are
Parallel being the default value.
Specify storage configurations viz. Storage
storageClass of volumes. Typically, 1 volume per Master instance is sufficient, hence Master has a default storage count of
1. If storage class isn't specified, it will be defaulted to
standard. Make sure kubernetes admin has defined
standard storage class, before leaving this field out.
resources attribute. The resources to be specified are
resource property in itself is optional and will not be applied to created
StatefulSets, if omitted. You may also choose to specify either
resource.limits, or both.
If you have enabled TLS encryption, then you can set:
use_node_to_node_encryptionflag to enable node-to-node encryption
allow_insecure_connectionsflag to specify if insecure connections are allowed when TLS is enabled
use_client_to_server_encryptionflag to enable client-to-node encryption