Kubernetes(k8s) 实战集群部署Discuz x3.5 k8s使用本地私有仓库镜像 Centos 8.5 安装部署NFS

本文环境可参考:

详细教程 Centos8.5 基于 k8s v1.30.1 部署高可用集群 kubeadm 安装 kubernetes v1.30.1 docker集群搭建 延长证书有效期-CSDN博客

1 集群部署,需要PV,安装NFS

#master11,slave12,slave13都安装

yum install nfs-utils rpcbind -y

2 配置

#master11
vim /etc/exports
/data/share 192.168.50.0/24(sync,rw,no_root_squash)
#启动服务
systemctl enable rpcbind.service
systemctl enable nfs-server.service
systemctl start rpcbind.service
systemctl start nfs-server.service
#查看服务
[root@master11 share]# showmount -e 192.168.50.11
Export list for 192.168.50.11:
/data/share 192.168.50.0/24

#客户端

#slave12
#启动服务
systemctl enable rpcbind.service
systemctl enable nfs-server.service
systemctl start rpcbind.service
systemctl start nfs-server.service
#查看
[root@slave12 ~]# showmount -e 192.168.50.11
Export list for 192.168.50.11:
/data/share 192.168.50.0/24
#挂载
mkdir  -p /mnt/nfs
mount -t nfs 192.168.50.11:/data/share  /mnt/nfs
#查看
[root@slave12 ~]# df -h| grep nfs
192.168.50.11:/data/share   36G   16G   21G  44% /mnt/nfs
#slave13同样安装配置

3 yaml配置

[root@master11 soft]# cat  discuz.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: discuz
spec:
  replicas: 3
  selector:
    matchLabels:
      app: discuz
  template:
    metadata:
      labels:
        app: discuz
    spec:
      containers:
      - name: discuz
        image: 192.168.50.11:5000/discuz:x3.5
        ports:
            - containerPort: 80
        volumeMounts:
        - name: host-data
          mountPath: /var/www/html
      volumes:
      - name: host-data
        hostPath:
          path: /mnt/nfs/discuz/html
          type: DirectoryOrCreate
#
[root@master11 soft]# cat  discuz-srv.yaml 
apiVersion: v1
kind: Service
metadata:
  name: discuz-service
  labels:
    app: discuz
spec:
  selector:
    app: discuz
  ports:
  - protocol: TCP
    port: 88
    targetPort: 80
    nodePort: 30036
  type: NodePort

4 创建应用

#master11
kubectl apply -f discuz.yaml
kubectl apply -f discuz-srv.yaml
#删除
kubectl delete -f discuz.yaml
kubectl delete -f discuz-srv.yaml

5 查看和访问

[root@master11 discuz]# kubectl get node,po,svc -A -owide|grep discuz
default                pod/discuz-859bc9f964-d79mj                                 1/1     Running   0               31m     10.244.126.205   slave13    <none>           <none>
default                pod/discuz-859bc9f964-dgxfw                                 1/1     Running   0               31m     10.244.126.206   slave13    <none>           <none>
default                pod/discuz-859bc9f964-v8ff9                                 1/1     Running   0               31m     10.244.199.16    slave12    <none>           <none>
default                service/discuz-service                         NodePort    10.97.87.138     <none>        88:30036/TCP                    31m     app=discuz
#salve12
[root@slave12 ~]# docker ps  -a 
CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                    PORTS     NAMES
b588cf2f03f1   2835ba731e97                "docker-php-entrypoi..."   31 minutes ago   Up 31 minutes                       k8s_discuz_discuz-859bc9f964-v8ff9_default_cf503e04-c42f-4e96-9523-165b37ef0634_0
#slave13
ONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                     PORTS     NAMES
b468798d3f94   2835ba731e97                "docker-php-entrypoi..."   32 minutes ago   Up 32 minutes                        k8s_discuz_discuz-859bc9f964-dgxfw_default_5032b3ee-4b11-4121-a1a8-064b7d633f34_0
5ce6b41bd645   2835ba731e97                "docker-php-entrypoi..."   32 minutes ago   Up 32 minutes                        k8s_discuz_discuz-859bc9f964-d79mj_default_4cf410ea-e0c1-42b7-8fb6-d7bc4edf15e4_0

#IP+Nodeport 访问

相关推荐
昌sit!1 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
追风林2 小时前
mac 本地docker-mysql主从复制部署
mysql·macos·docker
A ?Charis3 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
城南vision4 小时前
Docker学习—Docker核心概念总结
java·学习·docker
wclass-zhengge4 小时前
Docker篇(Docker Compose)
运维·docker·容器
北漂IT民工_程序员_ZG4 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes
梦魇梦狸º7 小时前
腾讯轻量云服务器docker拉取不到镜像的问题:拉取超时
docker·容器·github
鬼才血脉8 小时前
docker+mysql配置
mysql·adb·docker
Diamond技术流8 小时前
从0开始学习Linux——远程连接工具
linux·学习·centos·ssh·xshell·ftp
詹姆斯爱研究Java8 小时前
Docker 的基本概念和优势
docker