apiVersion: v1
kind: Pod
metadata:
  labels:
    app: cassandra
    cassandra_cr: cassandra
    contrail_manager: cassandra
spec:
  terminationGracePeriodSeconds: 1800
  containers:
  - image: hub.juniper.net/contrail-nightly/contrail-external-cassandra:5.2.0-0.740
    imagePullPolicy: IfNotPresent
    env:
    - name: POD_IP
      valueFrom:
        fieldRef:
          fieldPath: status.podIP
    lifecycle:
      preStop:
        exec:
          command: 
          - /bin/sh
          - -c
          - nodetool decommission
    readinessProbe:
      exec:
        command:
        - /bin/bash
        - -c
        - "seeds=$(grep -r '  - seeds:' /mydata/${POD_IP}.yaml |awk -F'  - seeds: ' '{print $2}'|tr  ',' ' ') &&  for seed in $(echo $seeds); do if [[ $(nodetool status | grep $seed |awk '{print $1}') != 'UN' ]]; then exit -1; fi; done"
      initialDelaySeconds: 15
      timeoutSeconds: 5
    name: cassandra
    securityContext:
      capabilities:
        add:
          - IPC_LOCK
      privileged: false
      procMount: Default
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/log/cassandra
      name: cassandra-logs
    - mountPath: /var/lib/cassandra
      name: cassandra-data
  dnsPolicy: ClusterFirst
  hostNetwork: true
  imagePullSecrets:
  - name: contrail
  initContainers:
  - command:
    - sh
    - -c
    - until grep ready /tmp/podinfo/pod_labels > /dev/null 2>&1; do sleep 1; done
    image: busybox
    imagePullPolicy: IfNotPresent
    name: init
    resources: {}
    securityContext:
      privileged: false
      procMount: Default
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /tmp/podinfo
      name: status
  nodeSelector:
    node-role.kubernetes.io/master: ""
  restartPolicy: Always
  schedulerName: default-scheduler
  tolerations:
  - effect: NoSchedule
    operator: Exists
  - effect: NoExecute
    operator: Exists
  volumes:
  - hostPath:
      path: /var/log/contrail/cassandra
      type: ""
    name: cassandra-logs
  - hostPath:
      path: /var/lib/contrail/cassandra
      type: ""
    name: cassandra-data
  - downwardAPI:
      defaultMode: 420
      items:
      - fieldRef:
          apiVersion: v1
          fieldPath: metadata.labels
        path: pod_labels
      - fieldRef:
          apiVersion: v1
          fieldPath: metadata.labels
        path: pod_labelsx
    name: status