k8s创建http

创建共享存储目录

yum install -y rpcbind nfs-utils

创建共享目录

mkdir -p /home/sharedir/www

修改目录权限

chmod 755 sharedir

修改NFS配置文件

vi /etc/exports
/home/sharedir 192.168.2.0(rw,no_root_squash,no_all_squash,sync)
[目录(全目录)] [IP(可填范围,*代表全部)] ([OPTION])

启动NFS

systemctl start nfs

创建pv.yaml

cat > /root/httpd-pv.yaml <

创建pvc.yaml

cat > /root/httpd-pvc.yaml <

创建httpd.yaml

cat > /root/httpd.yaml <

执行资源创建

kubectl apply -f httpd-pv.yaml
kubectl apply -f httpd-pvc.yaml
kubectl apply -f httpd.yaml

查看容器

[root@master mysql]# kubectl get pod
NAME READY STATUS RESTARTS AGE
httpd-65c5d64bd7-pmwwr 1/1 Running 0 2m19s

进入httpd容器

[root@master mysql]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
httpd NodePort 10.103.239.58  80:32222/TCP 22m

访问站点

http://192.168.174.10:32222/

修改副本数量

kubectl scale deployment httpd --replicas=2




 

你可能感兴趣的:(kubernetes,http,容器)