简体   繁体   中英

cant run mysql statefulset in kubernetes

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM