Skip to content

DongLiangTu/k8s_discuz

Repository files navigation

Deploy the Discuz forum using K8S and access it using the Nginx proxy

system structure drawing:

img

Pull images:

docker pull mysql:5.7.22
docker pull skyzhou/docker-discuz

Deploy mysql service:

kubectl apply -f mysql-dp.yml
kubectl apply -f mysql-svc.yml

Verify Mysql:

  • Obtain the mysql SVC, Record the cluster-ip (172.16.254.96) of mysql-service, and configure this IP when creating a link with discuz SVC
kubectl get svc -o wide

img

  • get mysql pods name
kubectl get pods -o wide
  • sign in mysql
kubectl exec -it mysql-5f87f4495c-9stsn  -- mysql -uroot -proot

img

Discuz deployment

  • # vim discuz-dp.yml
apiVersion: apps/v1         
kind: Deployment           
metadata:
  name: discuz              
spec:
  replicas: 1             
  selector:
    matchLabels:         
      app: discuz           
  strategy:                
    type: RollingUpdate     
  template:                
    metadata:
      labels:
        app: discuz        
    spec:
      containers:           
        - name: discuz      
          image: skyzhou/docker-discuz
          ports:
            - containerPort: 80
          env:             
            - name: MYSQL_PORT_3306_TCP
              value: mysql-service:3306
            - name: DISCUZ_DB_PASSWORD
              value: root

Deployment Discuz

kubectl apply -f discuz-dp.yml
kubectl apply -f discuz-svc.yml

Verify Discuz:

kubectl get deployment -o wide
kubectl get svc -o wide
  • Access to the cluster IP:30080

img

Deploy Nginx:

  • pull images
docker pull nginx:stable

# vim nginx.conf Enter the following configuration to configure the **URL for forwarding on proxy_pass **

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
    server {
                listen       80;
                server_name  localhost;
                location / {
                        proxy_pass **http://43.128.70.95:30080/install/;**
                }
            }
    include /etc/nginx/conf.d/*.conf;
}
  • create configmap
kubectl create configmap nginx-conf --from-file=./nginx.conf
  • nginx deployment svc
kubectl apply -f nginx-dp.yml
kubectl apply -f nginx-svc.yml

Verify Nginx proxy access:

  • Access to the cluster IP:30180

img

  • Follow the prompts to install Discuz:

img

img

About

user k8s to deploy discuz services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published