我正在尝试创建MySQL数据库部署,但收到以下错误。
你能帮我检查并解决这个问题吗?
- 错误消息:**C:\用户\Azvmadmin15.docker\YAML〉kubectl应用-f mysqlpvc. yaml服务/mysql-srv已创建
来自服务器的错误(BadRequest):
创建"mysqlpvc. yaml"时出错:版本"v1"中的状态集不能作为状态集处理:严格解码错误:未知字段"规范.模板.规范.端口",未知字段"规范.模板.规范.卷装载"
C:\用户\Azvmadmin15.docker\YAML〉kubectl get all名称类型集群-IP外部-IP端口(S)年龄服务/kubernetes集群IP www. example. com 443/TCP 78m服务/mysql-srv集群IP www. example. com 3306/TCP 17m 10.96.0.1 443/TCP 78m service/mysql-srv ClusterIP 10.108.13.118 3306/TCP 17m
C:\Users\Azvmadmin15.docker\YAML〉kubectl获取pv名称容量访问模式回收策略状态索赔存储类原因年限mysql-pv-卷10Gi RWO保留范围默认值/mysql-pv-索赔手册64m
C:\Users\Azvmadmin15.docker\YAML〉kubectl获取PVC名称状态卷容量访问模式存储类年龄mysql-pv-claim绑定mysql-pv-卷10Gi RWO手册67m
C:\用户\Azvmadmin15.docker\YAML〉kubectl get all名称类型集群-IP外部-IP端口(S)年龄服务/kubernetes集群IP www. example. com 443/TCP 78m服务/mysql-srv集群IP www. example. com 3306/TCP 17m 10.96.0.1 443/TCP 78m service/mysql-srv ClusterIP 10.108.13.118 3306/TCP 17m
YAML file:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-ss
spec:
replicas: 1
selector:
matchLabels:
app: "mysql-pod"
serviceName: "mysql"
template:
metadata:
labels:
app: "mysql-pod"
spec:
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: tiger1234
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql-srv
spec:
ports:
- port: 3306
selector:
app: "mysql"
1条答案
按热度按时间gojuced71#
您遇到
ports
和volumeMounts
的缩进问题,下面的YAML应该可以工作有关卷装载和端口,请参见文档中的示例