/tarantool-operator

Tarantool Operator manages Tarantool Cartridge clusters atop Kubernetes

Primary LanguageGoBSD 2-Clause "Simplified" LicenseBSD-2-Clause

Tarantool Kubernetes operator

Test

The Tarantool Operator provides automation that simplifies the administration of Tarantool Cartridge-based cluster on Kubernetes.

The Operator introduces new API version tarantool.io/v1alpha1 and installs custom resources for objects of three custom types: Cluster, Role, and ReplicasetTemplate.

Table of contents

Resources

Cluster represents a single Tarantool Cartridge cluster.

Role represents a Tarantool Cartridge user role.

ReplicasetTemplate is a template for StatefulSets created as members of Role.

Resource ownership

Resources managed by the Operator being deployed have the following resource ownership hierarchy:

Resource ownership

Resource ownership directly affects how Kubernetes garbage collector works. If you execute a delete command on a parent resource, then all its dependants will be removed.

Deploying the Tarantool operator on minikube

  1. Install the required deployment utilities:

    Pick one of these to run a local kubernetes cluster

    To install and configure a local minikube installation:

    1. Create a minikube cluster:

      minikube start --memory=4096

      You will need 4Gb of RAM allocated to the minikube cluster to run examples.

      Ensure minikube is up and running:

      minikube status

      In case of success you will see this output:

      host: Running
      kubelet: Running
      apiserver: Running
    2. Enable minikube Ingress add-on:

      minikube addons enable ingress
  2. Install the operator

    helm install tarantool-operator ci/helm-chart --namespace tarantool --create-namespace

    Ensure the operator is up:

    watch kubectl get pods -n tarantool

    Wait for tarantool-operator-xxxxxx-xx Pod's status to become Running.

Example Application: key-value storage

examples/kv contains a Tarantool-based distributed key-value storage. Data are accessed via HTTP REST API.

Application topology

App topology

Running the application

We assume that commands are executed from the repository root and Tarantool Operator is up and running.

  1. Create a cluster:

    helm install examples-kv-cluster examples/kv/helm-chart --namespace tarantool

    Wait until all the cluster Pods are up (status becomes Running):

    watch kubectl -n tarantool get pods
  2. Ensure cluster became operational:

    kubectl -n tarantool describe clusters.tarantool.io examples-kv-cluster

    wait until Status.State is Ready:

    ...
    Status:
      State:  Ready
    ...
  3. Access the cluster web UI:

    • If using minikube:

      • Get minikube vm IP-address:
      minikube ip
      • Open http://MINIKUBE_IP in your browser. Replace MINIKUBE_IP with the IP-address reported by the previous command.

      Web UI

      NOTE: Due to a recent bug in Ingress, web UI may be inaccessible. If needed, you can try this workaround.

    • If using kubernetes in docker-desktop

      Run: (MINIKUBE_IP will be localhost:8081 in this case)

      kc port-forward -n tarantool routers-0-0 8081:8081
  4. Access the key-value API:

    1. Store some value:

      curl -XPOST http://MINIKUBE_IP/kv -d '{"key":"key_1", "value": "value_1"}'

      In case of success you will see this output:

      {"info":"Successfully created"}
    2. Access stored values:

      curl http://MINIKUBE_IP/kv_dump

      In case of success you will see this output:

      {"store":[{"key":"key_1","value":"value_1"}]}

Scaling the application

  1. Increase the number of replica sets in Storages Role:

    in the examples-kv helm chart, edit the examples/kv/helm-chart/values.yaml file to be

    - RoleName: storage
      ReplicaCount: 1
      ReplicaSetCount: 2

    Then run:

    helm upgrade examples-kv-cluster examples/kv/helm-chart --namespace tarantool

    This will add another storage role replica set to the existing cluster. View the new cluster topology via the cluster web UI.

  2. Increase the number of replicas across all Storages Role replica sets:

    in the examples-kv helm chart, edit the examples/kv/helm-chart/values.yaml file to be

    - RoleName: storage
      ReplicaCount: 2
      ReplicaSetCount: 2

    Then run:

    helm upgrade examples-kv-cluster examples/kv/helm-chart --namespace tarantool

    This will add one more replica to each Storages Role replica set. View the new cluster topology via the cluster web UI.

Development

Regenerate the Custom Resource Definitions

make crds

Building tarantool-operator docker image

make docker

Running tests

# In the examples/kv directory
make build
make start
./bootstrap.sh
make test