利用deployment创建挂载本地路径的容器
2023-06-25 07:05:18 阅读次数:173
centos,Deployment
在宿主机上创建路径
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
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/liuyunshengsir/5998305,作者:liuyunshengsir,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:IPV6过渡技术_6 to 4 隧道中继
下一篇:防火墙的发展历史