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 访问

相关推荐
摸鱼也很难19 分钟前
Docker 镜像加速和配置的分享 && 云服务器搭建beef-xss
运维·docker·容器
鸠摩智首席音效师3 小时前
Docker 中如何限制CPU和内存的使用 ?
docker·容器
Michaelwubo3 小时前
Docker dockerfile镜像编码 centos7
运维·docker·容器
远游客07133 小时前
centos stream 8下载安装遇到的坑
linux·服务器·centos
jingyu飞鸟4 小时前
centos-stream9系统安装docker
linux·docker·centos
好像是个likun4 小时前
使用docker拉取镜像很慢或者总是超时的问题
运维·docker·容器
玖疯子6 小时前
介绍 Docker 的基本概念和优势,以及在应用程序开发中的实际应用。
docker
暴富的Tdy6 小时前
【快速上手Docker 简单配置方法】
docker·容器·eureka
cominglately6 小时前
centos单机部署seata
linux·运维·centos
魏 无羡7 小时前
linux CentOS系统上卸载docker
linux·kubernetes·centos