apiVersion: apps/v1
kind: Deployment
metadata:
  name: cassandra
spec:
  replicas: 1
  selector:
    matchLabels:
      service: cassandra
  template:
    metadata:
      labels:
        service: cassandra
    spec:
      initContainers:
        - name: wait-on-etcd
          image: {{ dockerhub_repo }}/busybox:1.28
          command: ['sh', '-c', 'until nslookup etcd; do echo waiting for etcd to start ...; sleep 2; done']
      containers:
      - image: "{{ dockerhub_repo }}/ollivier/clearwater-cassandra:hunter"
        name: cassandra
        ports:
        - containerPort: 22
        - containerPort: 7001
        - containerPort: 9042
        - containerPort: 9160
        envFrom:
        - configMapRef:
              name: env-vars
        env:
        - name: MY_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        livenessProbe:
          exec:
            command: ["/bin/bash", "/usr/share/kubernetes/liveness.sh", "7000 9042 9160"]
          # Cassandra can take a very, very long time to start up
          initialDelaySeconds: 600
        readinessProbe:
          exec:
            command: ["/bin/bash", "/usr/share/kubernetes/liveness.sh", "7000 9042 9160"]
      imagePullSecrets:
      - name: ~
      restartPolicy: Always