<p>I'm trying to set up Cassandra on a Kubernetes cluster made of three virtual machines using two different files (Deployment and Service). In order to do this I use the command </p>

<blockquote>
  <p>kubectl create -f <em>file</em>.yaml</p>
</blockquote>

<p>The service file works perfectly but when I start the other one with three replicas, the state of the pods is CrashLoopBackOff instead of running. </p>

<p>The configuration of the deployment file is the following </p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: cassandra
  labels:
    app: cassandra
spec:
  replicas: 3
  selector:
    matchLabels:
      app: cassandra
  template:
    metadata:
      labels:
        app: cassandra
    spec:
      containers:
      - name: cassandra
        image: gcr.io/google_containers/cassandra:v5
        ports:
        - containerPort: 9042
</code></pre>

<p>And this is the service file</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: cassandra
  name: cassandra
spec:
  type: NodePort
  ports:
    - port: 9042
  selector:
    app: cassandra
</code></pre>

<p>I appreciate any help on this.</p>

Paloma Gómez
<p>You shouldnt be using Deployment for running stateful applications. StatefulSets are recommended for running databases like cassandra.</p>

<p>follow the below link for reference --> <a href="https://kubernetes.io/docs/tutorials/stateful-application/cassandra/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/stateful-application/cassandra/</a></p>
