Clivern / Peanut

🐺 Deploy Databases and Services Easily for Development and Testing Pipelines.

Home Page:https://clivern.github.io/Peanut/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kubernetes driver

andrepiske opened this issue · comments

Is having a Kubernetes driver something on the roadmap for this project? I'm exploring the possibilities here, not really requesting a feature 🙂

I noticed the code contains something like:

if viper.GetString("app.containerization.driver") == "docker" {
    result.containerization = runtime.NewDockerCompose()
} else {
    panic("Invalid containerization runtime!")
}

which makes me think it's already prepared to be extensible for other drivers than docker+etcd.

Thinking of a possible implementation, there are many ways to do it in Kubernetes. I'd think the most "kubernetes way" would be to add a driver that replaces Docker calls with Kubernetes calls and use Kubernete's CRDs as a storage means instead of etcd.

commented

Yeah, it is not tightly coupled with docker. there is an interface that has the needed functionality for k8s implementation (https://github.com/Clivern/Peanut/blob/main/core/runtime/base.go#L8-L11). tbh i am not sure when i will support k8s since i care about the command line first and there will a lot to do to support k8s.

Anyways here is how i see it:

  • Peanut can run outside the k8s cluster & uses the kube config to create/modify deployments, services and configmaps.
  • and it can be deployed inside the cluster and have service account to be able to create/modify deployments, services and configmaps from inside the cluster.

like here https://github.com/Clivern/Beetle/blob/main/core/kubernetes/cluster.go#L79-L106

for example here is how peanut will deploy etcd of course with API calls

# Deploy nginx ingress or you have it already
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.41.2/deploy/static/provider/cloud/deploy.yaml
$ kubectl get pods -n ingress-nginx \
  -l app.kubernetes.io/name=ingress-nginx --watch
$ kubectl get svc --namespace=ingress-nginx

#-------------------------

# Deploy Etcd
echo "---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: etcd-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: etcd
  template:
    metadata:
      labels:
        app: etcd
      name: etcd
    spec:
      containers:
        -
          image: 'bitnami/etcd:3.5.0'
          name: etcd-app
          ports:
          - containerPort: 2379
          env:
          - 
            name: ALLOW_NONE_AUTHENTICATION
            value: 'yes'
---
apiVersion: v1
kind: Service
metadata:
  name: etcd-svc
  labels:
    app: etcd
spec:
  ports:
    -
      port: 2379
      targetPort: 2379
  selector:
    app: etcd
  type: LoadBalancer" > etcd_test.yml

$ kubectl apply -f etcd_test.yml
deployment.apps/etcd-deployment created
service/etcd-svc created

# Peanut will return the load balancer IP and a port to use.
$ kubectl get svc
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)          AGE
etcd-svc     LoadBalancer     X.X.X.X          Y.Y.Y.Y          2379:32002/TCP      25m

$ etcdctl --endpoints Y.Y.Y.Y:2379 member list

Some services need a config file. we can mount the config files in pod using a configmap.