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

相关推荐
运维小文39 分钟前
K8S资源限制之LimitRange
云原生·容器·kubernetes·k8s资源限制
登云时刻40 分钟前
Kubernetes集群外连接redis集群和使用redis-shake工具迁移数据(二)
redis·容器·kubernetes
wuxingge9 小时前
k8s1.30.0高可用集群部署
云原生·容器·kubernetes
谭震鸿10 小时前
Zookeeper集群搭建Centos环境下
分布式·zookeeper·centos
志凌海纳SmartX10 小时前
趋势洞察|AI 能否带动裸金属 K8s 强势崛起?
云原生·容器·kubernetes
锅总10 小时前
nacos与k8s service健康检查详解
云原生·容器·kubernetes
BUG弄潮儿11 小时前
k8s 集群安装
云原生·容器·kubernetes
意疏11 小时前
【Linux 篇】Docker 的容器之海与镜像之岛:于 Linux 系统内探索容器化的奇妙航行
linux·docker
墨鸦_Cormorant11 小时前
使用docker快速部署Nginx、Redis、MySQL、Tomcat以及制作镜像
redis·nginx·docker
Code_Artist11 小时前
Docker镜像加速解决方案:配置HTTP代理,让Docker学会科学上网!
docker·云原生·容器