---
apiVersion: "apps/v1"
kind: StatefulSet
metadata:
  name: cassandraa
spec:
  serviceName: cassandraa
  replicas: 1
  selector:
    matchLabels:
      app: cassandra
  template:
    metadata:
      labels:
        app: cassandra
        interface: cassandraa
    spec:
#      affinity:
#        nodeAffinity:
#          requiredDuringSchedulingIgnoredDuringExecution:
#            nodeSelectorTerms:
#            - matchExpressions:
#              - key: dc
#                operator: In
#                values:
#                - DC1
      containers:
        - name: cassandra
          image: cassandra:3.11.2
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 7000
              name: intra-node
            - containerPort: 7001
              name: tls-intra-node
            - containerPort: 7199
              name: jmx
            - containerPort: 9042
              name: cql
          env:
            - name: CASSANDRA_SEEDS
              # SERKAN value: cassandraa-0.cassandraa.c7a.svc.cluster.local,cassandrab-0.cassandrab.c7a.svc.cluster.local
              value: cassandraa-0.cassandraa.default.svc.cluster.local
            - name: MAX_HEAP_SIZE
              value: 256M
            - name: HEAP_NEWSIZE
              value: 100M
            - name: CASSANDRA_CLUSTER_NAME
              value: "Test Cluster"
            - name: CASSANDRA_DC
              # SERKAN value: "DC1-Thingsboard-Cluster"
              value: "datacenter1"
            - name: CASSANDRA_RACK
              # value: "Rack-Thingsboard-Cluster"
              value: "rack1"
            - name: CASSANDRA_ENDPOINT_SNITCH
              value: GossipingPropertyFileSnitch
          volumeMounts:
            - name: cassandra-data
              mountPath: /var/lib/cassandra
  volumeClaimTemplates:
    - metadata:
        name: cassandra-data
#        annotations:  # comment line if you want to use a StorageClass
#          volume.beta.kubernetes.io/storage-class: ""
      spec:
        accessModes: [ "ReadWriteOnce" ]
        storageClassName: nfs-client
        resources:
          requests:
            storage: 10Gi
          # or specify which StorageClass
