Last active
March 27, 2018 10:38
-
-
Save shaikmdrafi/7c847bb4561d8e749972170d17d11eee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################## | |
[root@localhost ~]# cat pv-mysql.yml | |
apiVersion: v1 | |
kind: PersistentVolume | |
metadata: | |
name: mysql-volume | |
spec: | |
capacity: | |
storage: 2Gi | |
accessModes: | |
- ReadWriteMany | |
persistentVolumeReclaimPolicy: Recycle | |
nfs: | |
server: localhost | |
path: /nfsvolumes/pv01 | |
[root@localhost ~]# cat pvc-mysql.yml | |
kind: PersistentVolumeClaim | |
apiVersion: v1 | |
metadata: | |
name: mysql-pvclaim | |
spec: | |
accessModes: | |
- ReadWriteMany | |
resources: | |
requests: | |
storage: 2Gi | |
[root@localhost ~]# cat pod-mysql.yml | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: mysql | |
labels: | |
name: mysql | |
spec: | |
containers: | |
- resources: | |
limits : | |
cpu: 0.5 | |
image: mysql:5.6 | |
name: mysql | |
env: | |
- name: MYSQL_ROOT_PASSWORD | |
value: yourpassword | |
- name: MYSQL_USER | |
value: wp_user | |
- name: MYSQL_PASSWORD | |
value: wp_pass | |
- name: MYSQL_DATABASE | |
value: wp_db | |
ports: | |
- containerPort: 3306 | |
name: mysql | |
volumeMounts: | |
- name: mysql-persistent-storage | |
mountPath: /var/lib/mysql/data | |
volumes: | |
- name: mysql-persistent-storage | |
persistentVolumeClaim: | |
claimName: mysql-pvclaim | |
[root@localhost ~]# cat svc-mysql.yml | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
name: mysql | |
name: mysql | |
spec: | |
ports: | |
- port: 3306 | |
selector: | |
name: mysql | |
################### | |
[root@localhost ~]# oc create -f pv-mysql.yml | |
persistentvolume "mysql-volume" created | |
[root@localhost ~]# oc create -f pvc-mysql.yml | |
persistentvolumeclaim "mysql-pvclaim" created | |
[root@localhost ~]# oc create -f pod-mysql.yml | |
pod "mysql" created | |
[root@localhost ~]# oc create -f svc-mysql.yml | |
service "mysql" created | |
############### | |
[root@localhost ~]# oc get pv | |
NAME CAPACITY ACCESSMODES STATUS CLAIM REASON AGE | |
mysql-volume 2Gi RWX Bound default/mysql-pvclaim 1m | |
[root@localhost ~]# oc get pvc | |
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE | |
mysql-pvclaim Bound mysql-volume 2Gi RWX 1m | |
[root@localhost ~]# oc get pods | |
NAME READY STATUS RESTARTS AGE | |
mysql 0/1 ContainerCreating 0 1m | |
[root@localhost ~]# oc get svc | |
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE | |
mysql 172.30.167.208 <none> 3306/TCP 58s | |
################## | |
[root@localhost ~]# docker images |grep mysql | |
docker.io/mysql 5.6 079344ce5ebd 13 days ago 256 MB | |
################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment