0

I've just started learning kubernetes and was playing around in katakoda platform. I created a statefulset for mysql. It is just a test so i didnt declare any pvc and mount any volumes. It's declaration and the service's declaration in yml:


---

apiVersion: v1
kind: Service
metadata:
  name: mysql-headless
  labels:
    run: mysql-sts-demo
spec:
  ports:
  - port: 3306
    name: db
  selector:
    run: mysql-sts-demo

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql-sts-demo
spec:
  serviceName: "mysql-headless"
  replicas: 1
  selector:
    matchLabels:
      run: mysql-sts-demo
  template:
    metadata:
      labels:
        run: mysql-sts-demo
    spec:
      containers:
      - name: mysql
        image: mysql:5.7.8
        env:
          - name: MYSQL_ROOT_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mysql-secrets
                key: ROOT_PASSWORD
          - name: MYSQL_DATABASE
            valueFrom:
              secretKeyRef:
                name: mysql-secrets
                key: DBNAME
          - name: MYSQL_USER
            valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: USER
          - name: MYSQL_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mysql-secrets
                key: PASSWORD


it creates those resources successfully , but when I type kubectl get statefulsets , my ss is always being displayed as not ready. What may the issue be? Btw I need it for using with a spring petclinic app which I declared and launched previously as a deployment .

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • Add the result of `kubectl describe statefulset mysql-sts-demo` and `kubectl describe pods mysql-sts-demo-0` ? – Kamol Hasan May 23 '20 at 10:34
  • Did you create the matching Secret? As you've shown it, `MYSQL_USER` isn't from the same Secret (`mysql-secret` vs. `secrets`) which could prevent things from starting too. – David Maze May 23 '20 at 10:39

1 Answers1

1

can you paste the logs for statefulsets or an output of kubectl get events and kubectl describe <your stateful-set name>

now coming to secrets can you check whether those secrets which you are using in your stateful-sets definitions are already present using kubectl get secrets

Ashish Kamat
  • 76
  • 2
  • 8