Kubernets创建有状态集失败

时间:2019-10-06 15:47:36

标签: kubernetes

我正在尝试使用下面的定义创建一个有状态集,但出现此错误:

error: unable to recognize "wordpress-database.yaml": no matches for kind "StatefulSet" in version "apps/v1beta2"

怎么了?

yaml文件为(请不要考虑行的对齐):

apiVersion: apps/v1beta2
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的api版本应为:

apiVersion: apps/v1

From the official documentation


祝你好运。