kubernets创建有状态集,未启动pod

时间:2019-10-06 16:27:27

标签: kubernetes

我创建了一个有状态集合,但是运行kubectl apply -f wordpress-database.yamlkubectl get statefulset之后,我看到广告连播始终处于零状态(为什么?):

wordpress-database   0/1     25m

yaml(请不要考虑对齐)

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

1 个答案:

答案 0 :(得分:1)

首先检查您执行statefulset时发生了什么:

// MyComponent.vue
export default {
  // ...
  computed: {
    isFormTouchedOrInvalid() {
      return Object.keys(this.fields).some(key => this.fields[key].touched || this.fields[key].invalid);
    }
  },
  //...
}

您可能没有提供存储,未创建持久卷。检查您是否配置了storageclass或将其设置为默认值。

您的 volumeClaimTemplates 部分应类似于:

<ValidationProvider rules="required" v-slot="{ touched, invalid }">
  <pre>touched:{{touched}} invalid:{{invalid}}</pre>
  <input type="email" v-model="value">
</ValidationProvider>

有用的文档:PersistentVolumes