Created
January 9, 2017 04:34
-
-
Save BruceZu/35ef618baaa068e4f67b32fc9b65509e to your computer and use it in GitHub Desktop.
persistent-volumes of k8s kubernetes
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
| http://kubernetes.io/docs/user-guide/persistent-volumes/walkthrough/ |
Author
Author
[root@k8s-08 volumes-ci-cd]# pwd
/volumes-ci-cd
[root@k8s-08 volumes-ci-cd]# chmod -R 777 bugzilla/
[root@k8s-09 ~]# kubectl label nodes k8s-08 pesistent=bugzilla
[root@k8s-09 ~]# kubectl get nodes --show-labels
NAME STATUS AGE LABELS
k8s-04.huaweilab.com Ready 61d beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-04.huaweilab.com
k8s-05.huaweilab.com Ready 61d beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-05.huaweilab.com
k8s-06.huaweilab.com Ready 61d beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-06.huaweilab.com
k8s-07.huaweilab.com Ready 61d beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-07.huaweilab.com
k8s-08.huaweilab.com Ready 61d beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-08.huaweilab.com,pesistent=bugzilla
k8s-09.huaweilab.com Ready 61d beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubeadm.alpha.kubernetes.io/role=master,kubernetes.io/hostname=k8s-09.huaweilab.com
[root@k8s-09 ~]#
then prepare yaml file
[root@k8s-09 ~]# cat bugzilla-host-volume-on-08.yaml
apiVersion: v1
kind: Pod
metadata:
name: bugzilla.withpv
labels:
name: bugzilla.withpv
spec:
containers:
- name: bugzilla
image: dklawren/docker-bugzilla
ports:
- containerPort: 80
- containerPort: 22
- containerPort: 5900
securityContext:
privileged: true
volumeMounts:
- mountPath: /home/bugzilla
name: pv-bugzilla
- mountPath: /var/lib/mysql
name: pv-mysql
nodeSelector:
pesistent: bugzilla
volumes:
- name: pv-bugzilla
hostPath:
# directory location on host
path: /volumes-ci-cd/bugzilla/bugzilla
- name: pv-mysql
hostPath:
path: /volumes-ci-cd/bugzilla/mysql
Test
1 create a test.txt in container and check the content from node
2 delete pod and re deploy it, it is still on the specified node and the status is still there
3 compare with the one without persistent storage pod:
there is not data in the mounted path
http://10.145.101.91:30146/ work
http://10.145.101.91:30146/bugzilla/ does not work
[root@k8s-09 ~]# kubectl expose pod bugzilla.withpv --type=NodePort --name bugzilla-withpv
service "bugzilla-withpv" exposed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.slideshare.net/Docker/persistent-data-storage-for-docker-containers-by-andre-moruga
https://github.com/kubernetes/kubernetes/blob/master/docs/design/persistent-storage.md
http://kubernetes.io/docs/user-guide/persistent-volumes/
HostPath (single node testing only – local storage is not supported in any way and WILL NOT WORK in a multi-node cluster)
Assigning Pods to Nodes
https://kubernetes.io/docs/user-guide/node-selection/