citus icon indicating copy to clipboard operation
citus copied to clipboard

Kubernetes support

Open rimusz opened this issue 8 years ago • 45 comments

Run citus on Kubernetes

rimusz avatar Apr 01 '16 10:04 rimusz

@rimusz Thanks for opening this issue!

I've had this on my list for a while to look at, although I haven't gotten to a fully blown setup yet. Could you describe your use case in more detail?

Happy to update this issue once I've done some more testing :-)

lfittl avatar Apr 01 '16 17:04 lfittl

@lfittl I'm just looking an easy way to bootstrap citus cluster on kubernetes for now

rimusz avatar Apr 03 '16 13:04 rimusz

@lfittl I would love to have an easy way to bootstrap citus cluster on Kubernetes as e.g. youtube vitess does for mysql http://vitess.io/getting-started/

rimusz avatar Apr 21 '16 12:04 rimusz

@rimusz 💯, I'm a fan of the work YouTube did with Vitess.

I haven't been able to find time for this just yet (we've been busy with the launch of Citus Cloud), but its on my list still - although someone else from the team might find time sooner.

Out of curiosity, are you running on Google Compute Engine, or is this for another K8S-based environment?

lfittl avatar Apr 21 '16 20:04 lfittl

@lfittl I'm a big fan of GKE, no needs to setup/maintain CoreOS based Kube clusters anymore :) This is why I tweeted back about Citus Cloud on Google Cloud as well.

rimusz avatar Apr 22 '16 08:04 rimusz

This would indeed be awesome. And I think with the release of Kubernetes 1.3, and the inclusion of "Pet Sets", this would fit perfectly with the goal of Citus.

JeanMertz avatar Jun 29 '16 07:06 JeanMertz

+1

derekperkins avatar Nov 19 '16 04:11 derekperkins

Big +1 here as well. Has anybody started working on this yet? If so I'd like to help out!

UPDATE: After looking around a bit I found this: https://github.com/jberkus/atomicdb/tree/master/citus_petset - haven't tested it myself yet.

xarg avatar Nov 22 '16 22:11 xarg

@xarg -- As you noted, @jberkus has been looking at Kubernetes integration with Citus.

Josh had a talk at PGConf SV where he demoed a Citus cluster deployment with Kubernetes: http://www.pgconfsv.com/ccp-containerized-clustered-postgres-0

Once the talk is online, I'll also post the link to it here.

Also happy to send an introduction to @jberkus and also be a part of this conversation. We're paying close attention to Kubernetes.

ozgune avatar Nov 29 '16 22:11 ozgune

First cut at this is up on my project: https://github.com/jberkus/atomicdb/tree/master/citus_petset

Not really production-quality yet, working on it. Contributions welcome.

jberkus avatar Nov 29 '16 23:11 jberkus

@jberkus Glad for your great work! Question: "Due to an outstanding bug with PetSet and PVs on AWS;" Could you link to that issue so I can follow it?

tslater avatar Mar 08 '17 14:03 tslater

that actually has to do with KubeAdm more than anything.

I'll be building a Helm chart this week.

jberkus avatar Mar 08 '17 19:03 jberkus

Hello Team,

Do you have any plans to have citus Integrated with Kubernetes?.

I heard, that citus has plans to integrate with K8s in their pipeline.

Thanks and Regards, Arjun.M

arjunm183 avatar Mar 30 '18 02:03 arjunm183

Any updates?

Raidus avatar Nov 05 '18 15:11 Raidus

+1

hrdymchl avatar Dec 22 '18 16:12 hrdymchl

👍 Any updates on this?

botzill avatar Jan 14 '19 12:01 botzill

Check this:

https://github.com/jinhong-/citus-k8s

ramki1979 avatar Apr 04 '19 07:04 ramki1979

+1 came up in a customer conversation as an important item. cc @lfittl

saicitus avatar May 20 '19 15:05 saicitus

Looking to run this in Kube as well. I would love to help out with an OSS solution if I can. Writing an helm chart is probably the easiest way, but an operator is probably the best. @lfittl

colek42 avatar Jun 21 '19 18:06 colek42

Official helm integreted in documentation while be real plus....

mcarbonneaux avatar Jul 10 '19 06:07 mcarbonneaux

Working example for "local-ssd-storage" aka affinity on special node node01.vm.domain.com where available.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: database
spec:
  capacity:
    storage: 100Gi
  # volumeMode field requires BlockVolume Alpha feature gate to be enabled.
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-ssd-storage
  local:
    path: /mnt/disks/ssd1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node01.vm.domain.com
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: citus-master-pvc
  labels:
    app: citus-master
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
  storageClassName: local-ssd-storage
  local:
    path: /mnt/local-storage/ssd/disk1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node01.vm.domain.com
apiVersion: v1
kind: Service
metadata:
  name: citus-master
  labels:
    app: citus-master
spec:
  selector:
    app: citus-master
  ports:
  - port: 5432
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: citus-master
spec:
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node01.vm.domain.com
  selector:
    matchLabels:
      app: citus-master
  replicas: 1
  template:
    metadata:
      labels:
        app: citus-master
    spec:
      containers:
      - name: citus
        image: citusdata/citus:8.0.0
        ports:
        - containerPort: 5432
        env:
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              name: citus-secrets
              key: password
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: citus-secrets
              key: password
        volumeMounts:
        - name: storage
          mountPath: /var/lib/postgresql/data
        livenessProbe:
          exec:
            command:
            - ./pg_healthcheck
          initialDelaySeconds: 60
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: citus-master-pvc`
apiVersion: v1
kind: Service
metadata:
  name: citus-workers
  labels:
    app: citus-workers
spec:
  selector:
    app: citus-workers
  clusterIP: None
  ports:
  - port: 5432
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: citus-worker
spec:
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node01.vm.domain.com
  selector:
    matchLabels:
      app: citus-workers
  serviceName: citus-workers
  replicas: 3
  template:
    metadata:
      labels:
        app: citus-workers
    spec:
      containers:
      - name: citus-worker
        image: citusdata/citus:8.0.0
        lifecycle:
          postStart:
            exec:
              command: 
              - /bin/sh
              - -c
              - if [ ${POD_IP} ]; then psql --host=citus-master --username=postgres --command="SELECT * from master_add_node('${HOSTNAME}.citus-workers', 5432);" ; fi
        ports:
        - containerPort: 5432
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              name: citus-secrets
              key: password
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: citus-secrets
              key: password
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        volumeMounts:
        - name: wstorage
          mountPath: /var/lib/postgresql/data
        livenessProbe:
          exec:
            command:
            - ./pg_healthcheck
          initialDelaySeconds: 60
  volumeClaimTemplates:
  - metadata:
      name: wstorage
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 50Gi
      storageClassName: local-ssd-storage    
      local:
        path: /mnt/local-storage/ssd/disk1
      nodeAffinity:
        required:
          nodeSelectorTerms:
          - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
              - node01.vm.domain.com

apiVersion: v1
kind: Secret
metadata:
  name: citus-secrets
type: Opaque
data:
  password: XXXXXXXXXXXXXXXXXXXXXXXXXXX

cforce avatar Jul 12 '19 06:07 cforce

Thanks for those kubernetes files of a citus deployment! I was wondering if anybody got it to work to run multiple independent citus instances in the same k8s cluster. I tried changing ports but that didn't got well. I miss something to assign workers to a specific master, don't know where to look

jenswachtel avatar Jan 08 '21 14:01 jenswachtel

@jenswachtel You might also want to give Azure Arc enabled PostgreSQL Hyperscale a try:

https://docs.microsoft.com/en-us/azure/azure-arc/data/create-postgresql-hyperscale-server-group

This is the officially supported version of Citus on Kubernetes (with a slightly more complex product name 😄), thats currently in Public Preview. Supports Citus running on Kubernetes anywhere (i.e. not just on Azure).

Running multiple Citus instances is a built-in capability that you can easily use from either the "azdata" CLI, or directly through Kubernetes resource definitions.

ghost avatar Jan 08 '21 19:01 ghost

@lfittl wow, thank you so much! It works perfectly!

I can highly recommend Azure ARC with Citus. I tested it on AKS, but looks like you can do this with GCP etc.

Pay attention to the smaller details e.g. don't provision cluster with different availability zones, it works pretty neatly also with existing clusters!

Step 1) Activate AKS ARC on Cluster & Connect Described here https://docs.microsoft.com/en-us/azure/azure-arc/kubernetes/connect-cluster#install-cli-extensions

Step 2) Install ARC Data Services on Cluster I can recommend going the way via Azure Portal Add > "Azure Arc data Controller" Fill out blanks and download juniper notebook which you then will have to run inside Azure Data Studio (minor addition, add this line to Step 5 in the scripts os.environ["ACCEPT_EULA"] = "yes"

Step 3) Create Citus Group Cluster as mentioned by @lfittl https://docs.microsoft.com/en-us/azure/azure-arc/data/create-postgresql-hyperscale-server-group

I am so amazed, I can finally provision citus clusters in a matter of minutes!

jenswachtel avatar Jan 09 '21 01:01 jenswachtel

helm chart for citus data can someone help me with that

SaiManikantha avatar Aug 06 '21 08:08 SaiManikantha

@jenswachtel does it require having microsoft accounts and or install stuff on azure? or is it entirely controlled by say GCP?

docteurklein avatar Oct 22 '21 13:10 docteurklein

Please be honest and close this issue as this won't be done officially. MS won't provide us with a helm chart to install this on kubernetes. They try to nudge customers to Azure. Azure arc is a paid service.

GeroL avatar Nov 08 '21 13:11 GeroL

passing by, just to say I got a working POC on kubernetes https://github.com/docteurklein/citus-test

docteurklein avatar Nov 08 '21 13:11 docteurklein

@docteurklein Yes, thanks for the start. The docker images are over a year old. MS really tries to raise the bar for entry. At least you can build your own fairly current docker images from this branch

GeroL avatar Nov 08 '21 15:11 GeroL

@GeroL The hub images look pretty recent to me https://hub.docker.com/r/citusdata/citus/tags

docteurklein avatar Nov 08 '21 16:11 docteurklein