Reputation: 583
I am unable to deploy MySQL on Redhat openshift. My pod keep going into CrashLoopBackOff. From the error, I don't understand what is the issue because it states that initializing of server in progress as process and after that, it directly goes into shutdown state. Need to understand what is actually happening.
Deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-wordpress-deployment
namespace: wordpress-website
labels:
app: mysql-wordpress
spec:
selector:
matchLabels:
app: mysql-wordpress
strategy:
type: Recreate
template:
metadata:
labels:
app: mysql-wordpress
spec:
volumes:
- name: mysql-local-pv
persistentVolumeClaim:
claimName: local-mysql-pvc
containers:
- name: mysql-container
image: mysql
imagePullPolicy: IfNotPresent
port:
- containerPorts: 3306
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: pass
volumeMounts:
- name: mysql-local-pv
mountPath: /var/lib/mysql
PersistentVolume.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-mysql-pv
spec:
storageClassName: ibmc-block-bronze
accessModes:
- ReadWriteOnce
capacity:
storage: "20Gi"
hostPath:
path: /tmp/data/
persistentVolumeReclaimPolicy: Recycle
PersistentVolumeClaim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
Error Logs
Initializing database
mysqld: Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists)
2019-08-18T10:16:22.005955Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2019-08-18T10:16:22.006063Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.17) initializing of server in progress as process 17
2019-08-18T10:16:22.008464Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2019-08-18T10:16:22.008504Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-08-18T10:16:22.008970Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.
Upvotes: 1
Views: 1773
Reputation: 4683
hostPath
is required privileged
scc to write something to host by pod.
So you configure privileged
permission as following steps.
# oc adm policy add-scc-to-user privileged -z default
# oc edit deployment mysql-wordpress-deployment
spec:
...
template:
...
spec:
...
containers:
- name: mysql-container
securityContext:
privileged: true
Basically, privileged
mode is not recommended as aspect of security, because privileged
allow to access directly to host resources without any constraints.
I hope it help you.
Upvotes: 1