<p>I created a stateful set but after running <code>kubectl apply -f wordpress-database.yaml</code> and <code>kubectl get  statefulset</code> I see the pod is alwayson status zero (why?):</p>

<pre><code>wordpress-database   0/1     25m
</code></pre>

<p>yaml (please do not consider alignment)</p>

<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: wordpress-database
spec:
  selector:
    matchLabels:
      app: blog
  serviceName: "blog"
  replicas: 1
  template:
  metadata:
  labels:
    app: blog 
  spec:
  containers:
  - name: database
    image: mysql:5.7
    ports:
    - containerPort: 3306
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: rootPassword
    - name: MYSQL_DATABASE
      value: database
    - name: MYSQL_USER
      value: user
    - name: MYSQL_PASSWORD
      value: password          
    volumeMounts:
    - name: data
      mountPath: /var/lib/mysql
  - name: blog
    image: wordpress:latest
    ports:
    - containerPort: 80
    env:
    - name: WORDPRESS_DB_HOST
      value: 127.0.0.1:3306
    - name: WORDPRESS_DB_NAME
      value: database
    - name: WORDPRESS_DB_USER
      value: user
    - name: WORDPRESS_DB_PASSWORD
      value: password  
    volumeClaimTemplates:
    - metadata:
    name: data
    spec:
    resources:
    requests:
      storage: 1Gi
</code></pre>

<p>Firstly to check what happend with your <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">statefulset</a> execute:</p>

<pre><code>$ kubectl describe statefulset wordpress-database 
</code></pre>

<p>You probably don't have storage provided, your persistent volume is not being created. Check if you have configured <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">storageclass</a> or set it as default. </p>

<p>your <strong>volumeClaimTemplates</strong> section should looks similar:</p>

<pre><code> volumeClaimTemplates:
  - metadata:
      name: example
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "your-storage-class"
      resources:
        requests:
          storage: 1Gi
</code></pre>

<p>Useful documentation: <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">PersistentVolumes</a>.</p>
