Reputation: 63
Hi guys i am trying to Create the MySQL manifest file with nfs-mysql.yaml using the below content:
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-nfs
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
mountOptions:
- hard
- nfsvers=4.1
nfs:
path: /data
server: xxxxxxxxxxxx
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mysql-nfs
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 500Mi
---
apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql-wordpress
spec:
ports:
- port: 3306
selector:
app: mysql-wordpress
product: mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql-wordpress
spec:
selector:
matchLabels:
app: mysql-wordpress
product: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql-wordpress
product: mysql
spec:
containers:
- image: mysql
name: mysql-container
env:
- name: MYSQL_DATABASE
value: wordpress
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret-password
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-storage
persistentVolumeClaim:
claimName: mysql-nfs
but It's throwing this error when I Try to run the yaml file:
error validating "nfs-mysql.yaml": error validating data: [unknown object type "nil" in Deployment.spec.selector.matchLabels.strategy, ValidationError(Deployment.spec): unknown field "spec" in io.k8s.api.apps.v1.DeploymentSpec]; if you choose to ignore these errors, turn validation off with --validate=false
I don't understand the error can someone help me with this error?
Upvotes: 0
Views: 85
Reputation: 30083
There us that your YAML file having the issue with strategy
spec:
selector:
matchLabels:
app: mysql-wordpress
product: mysql
strategy:
type: Recreate
template:
metadata:
it should be like
strategy:
type: RollingUpdate
it should not be part the selector like you have mentioned so there is indentation issue with that, you can use below on for ref
spec:
replicas: 4
selector:
matchLabels:
app: nginx
minReadySeconds: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
even your selector having the issue so make you follow the proper indentation path in YAML.
Refer the official doc for more : https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
Upvotes: 0