apiVersion: "apps/v1"
kind: StatefulSet
metadata:
  name: cassandra
  labels:
    app: cassandra
    app.kubernetes.io/name: cassandra
    app.kubernetes.io/component: storage-backend
    app.kubernetes.io/part-of: jaeger
spec:
  serviceName: cassandra
  replicas: 3
  selector:
    matchLabels:
      app: cassandra
      app.kubernetes.io/name: cassandra
      app.kubernetes.io/component: storage-backend
      app.kubernetes.io/part-of: jaeger
  template:
    metadata:
      labels:
        app: cassandra
        app.kubernetes.io/name: cassandra
        app.kubernetes.io/component: storage-backend
        app.kubernetes.io/part-of: jaeger
    spec:
      terminationGracePeriodSeconds: 1800
      containers:
      - name: cassandra
        image: cassandra:3.11.2
        command:
        - /docker-entrypoint.sh
        - "-R"
        ports:
        - containerPort: 7000
          name: intra-node
        - containerPort: 7001
          name: tls-intra-node
        - containerPort: 7199
          name: jmx
        - containerPort: 9042
          name: cql
        - containerPort: 9160
          name: thrift
        lifecycle:
          preStop:
            exec:
              command: ["/bin/sh", "-c", "nodetool drain"]
        env:
          - name: MAX_HEAP_SIZE
            value: 512M
          - name: HEAP_NEWSIZE
            value: 100M
          - name: CASSANDRA_LISTEN_ADDRESS
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
          - name: CASSANDRA_CLUSTER_NAME
            value: "jaeger"
          - name: CASSANDRA_DC
            value: "dc1"
          - name: CASSANDRA_RACK
            value: "rack1"
          - name: CASSANDRA_ENDPOINT_SNITCH
            value: "GossipingPropertyFileSnitch"
          - name: CASSANDRA_SEEDS
            value: cassandra-0.cassandra
        volumeMounts:
        - name: cassandra-data
          mountPath: /var/lib/cassandra
        - name: cassandra-logs
          mountPath: /var/log/cassandra
      volumes:
      - name: cassandra-data
        emptyDir: {}
      - name: cassandra-logs
        emptyDir: {}