k8sasdb icon indicating copy to clipboard operation
k8sasdb copied to clipboard

k8sAsDb: Operator for database-like Kubernetes API usage. CRD for creating new schema. CRUD operation to schema.

K8sAsDB (k8sasdb)

Use Kubernetes as a database.

k8sasdb creates a new resource (Table) according to your request.

Usage

1. Create a table

Create this file as file-create-table.yaml and run the next kubectl command.

apiVersion: db.k8sasdb.org/v1
kind: Table
metadata:
  name: fruit
spec:
  columns:
  - name: sweetness
    type: bool
  - name: weight
    type: int
  - name: comment
    type: string
kubectl apply -f file-create-table.yaml

2. Create a record in the table

Create this file as file-create-record.yaml and run the next kubectl command.

apiVersion: user.k8sasdb.org/v1
kind: Fruit
metadata:
  name: orange
spec:
  sweetness: true
  weight: 40
  comment: nope
kubectl apply -f file-create-record.yaml

3.1 List records in a table

kubectl get fruits
# output
NAME     AGE
apple    9s
orange   9s

3.2 Get a record

kubectl get fruits orange -o yaml
# output
apiVersion: user.k8sasdb.org/v1
kind: Fruit
metadata:
  annotations:
    ...
spec:
  sweetness: true
  weight: 40
  comment: nope

4. Delete a record

kubectl delete fruit orange

Installation

kubectl apply -f https://raw.githubusercontent.com/onelittlenightmusic/k8sasdb/master/install.yaml

Try sample request

kubectl apply -f test/fruit.yaml

kubectl apply -f test/apple.yaml
kubectl apply -f test/banana.yaml

Tear down

kubectl delete -f https://raw.githubusercontent.com/onelittlenightmusic/k8sasdb/master/install.yaml