利用deployment创建挂载本地路径的容器
在宿主机上创建路径mkdir /root/k8s/vnc_host_path创建vnc.yamlapiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2kind: Deploymentmetadata:name: vnclabels:app: vncspec:selector:...
·
在宿主机上创建路径
mkdir /root/k8s/vnc_host_path
创建vnc.yaml
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: vnc
labels:
app: vnc
spec:
selector:
matchLabels:
app: vnc
strategy:
type: Recreate
template:
metadata:
labels:
app: vnc
spec:
containers:
- image: lys/centos-xfce-vnc:v1
name: vnc
ports:
- containerPort: 6901
name: vnc-port
volumeMounts:
- name: vnc-host-path
mountPath: /usr/lys
volumes:
- name: vnc-host-path
hostPath:
path: /root/k8s/vnc_host_path
执行启动命令
kubectl create -f vnc.yaml
检查结果
#查看deployment
[root@lys-192 vnc_host_path]# kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
vnc 1 1 1 1 2d20h
#查看容器运行情况
[root@lys-192 vnc_host_path]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default vnc-8487cdb8d4-znprt 1/1 Running 0 2d20h
kube-system coredns-576cbf47c7-87bwt 1/1 Running 0 6d
kube-system coredns-576cbf47c7-bv58g 1/1 Running 0 6d
kube-system etcd-localhost.localdomain 1/1 Running 2 6d
kube-system kube-apiserver-localhost.localdomain 1/1 Running 1 5d14h
kube-system kube-controller-manager-localhost.localdomain 1/1 Running 2 5d14h
kube-system kube-flannel-ds-amd64-jc6mj 1/1 Running 0 5d14h
kube-system kube-proxy-f56ln 1/1 Running 0 6d
kube-system kube-scheduler-localhost.localdomain 1/1 Running 1 6d
kube-system nvidia-device-plugin-daemonset-8rm5x 1/1 Running 0 4d14h
vnc-space rc-name-vnc-rthj4 1/1 Running 0 23h
vnc-space vncpod535615460617556 1/1 Running 0 25h
vnc-space vncpod535617847595744 1/1 Running 0 25h
更多推荐
已为社区贡献5条内容
所有评论(0)