首页 > 其他分享 >wordpress

wordpress

时间:2023-10-08 15:46:08浏览次数:34  
标签:name value wordpress mysql spec metadata

目录

压测

[root@master-1 ai]# cat wordpress.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql01
  template:
    metadata:
      labels:
        app: mysql01
    spec:
      containers:
        - name: mysql
          image: mysql:5.7
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3306
              name: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "123"
            - name: MYSQL_DATABASE
              value: wordpress
            - name: MYSQL_USER
              value: wp-
            - name: MYSQL_PASSWORD
              value: "123"
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          hostPath:
            path: /data/db
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  selector:
    app: mysql01
  ports:
    - protocol: TCP
      port: 3306

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      containers:
        - name: wordpress
          image: wordpress:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              name: http
          env:
            - name: WORDPRESS_DB_HOST
              value: mysql
            - name: WORDPRESS_DB_USER
              value: wp-
            - name: WORDPRESS_DB_PASSWORD
              value: "123"
            - name: WORDPRESS_DB_NAME
              value: wordpress
          volumeMounts:
            - name: wordpress-persistent-storage
              mountPath: /var/www/html
          resources:
            requests:
              cpu: 200m
      volumes:
        - name: wordpress-persistent-storage
          hostPath:
            path: /data/wordpress
---
apiVersion: v1
kind: Service
metadata:
  name: wordpress
spec:
  type: NodePort
  selector:
    app: wordpress
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: http
## hpa
[root@master-1 ai]# cat hpa-wordpress.yaml 
apiVersion: "autoscaling/v1"
kind: "HorizontalPodAutoscaler"
metadata:
  name: php-apache
  namespace: default
spec:
  maxReplicas: 10
  minReplicas: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: wordpress
  targetCPUUtilizationPercentage: 50
  
## 压测工具siege
[root@master-1 ai]# yum install -y siege
# 50个并发,持续1分钟
[root@master-1 ai]# siege -c 50 -t 1m http://10.0.0.111:31963/wp-admin/install.php
 
#  查看每个服务的cpu占用(解决的疑问点:新启动的服务是不是缓解服务压力了)
[root@master-1 ai]# kubectl top pod
NAME                         CPU(cores)   MEMORY(bytes)   
mysql-5bf4b6549b-lc87m       77m          223Mi           
wordpress-8549676bc6-26lxj   29m          99Mi            
wordpress-8549676bc6-gkwvr   30m          110Mi           
wordpress-8549676bc6-nzwwk   24m          95Mi            
wordpress-8549676bc6-pp9w6   45m          125Mi           
wordpress-8549676bc6-swgx8   28m          107Mi           
wordpress-8549676bc6-xwtzl   29m          118Mi           
wordpress-8549676bc6-zt67p   36m          115Mi   
[root@master-1 cf]# cat ../wordpress.yaml 
apiVersion: v1
kind: Service
metadata:
  name: wp-pod
spec:
  type: NodePort
  selector:
    name: wp-dp
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: http

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wp-dp01
spec:
  replicas: 1
  selector:
    matchLabels:
      name: wp-dp
  template:
    metadata:
      name: wp
      labels:
        name: wp-dp
    spec:
      volumes:
      - name: guazaidian
        hostPath:
          path: /data/db

      - name: guazaidian2
        hostPath:
          path: /data/wordpress

      containers:
      - name: wordpress
        image: wordpress:latest
        imagePullPolicy: IfNotPresent
        env:
        - name: WORDPRESS_DB_HOST
          value: "127.0.0.1"
        - name: WORDPRESS_DB_USER
          value: wp-
        - name: WORDPRESS_DB_PASSWORD
          value: "123"
        - name: WORDPRESS_DB_NAME
          value: wordpress
        ports:
        - containerPort: 80
          name: http
        volumeMounts:
        - name: guazaidian2
          mountPath: /var/www/html
        resources:
          requests:
            cpu: "200m"

      - name: db
        image: mysql:5.7
        imagePullPolicy: IfNotPresent
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "123"
        - name: MYSQL_DATABASE
          value: wordpress
        - name: MYSQL_USER
          value: wp-
        - name: MYSQL_PASSWORD
          value: "123"
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: guazaidian
          mountPath: /var/lib/mysql
[root@master-1 ai]# cat wordpress.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql                                      // 指定pod的标签
  template:
    metadata:
      labels:                                         // 打pod的标签()
        app: mysql                                    // pod的标签
    spec:
      containers:
        - name: mysql
          image: mysql:5.7
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3306
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "123"
            - name: MYSQL_DATABASE
              value: wordpress
            - name: MYSQL_USER
              value: wp-
            - name: MYSQL_PASSWORD
              value: "123"
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          hostPath:
            path: /data/db

---
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  selector:
    app: mysql                                             // 指定pod的标签
  ports:
    - protocol: TCP
      port: 3306

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      containers:
        - name: wordpress
          image: wordpress:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              name: http
          env:
            - name: WORDPRESS_DB_HOST
              value: mysql
            - name: WORDPRESS_DB_USER
              value: wp-
            - name: WORDPRESS_DB_PASSWORD
              value: "123"
            - name: WORDPRESS_DB_NAME
              value: wordpress
          volumeMounts:
            - name: wordpress-persistent-storage
              mountPath: /var/www/html
      volumes:
        - name: wordpress-persistent-storage
          hostPath:
            path: /data/wordpress

---
apiVersion: v1
kind: Service
metadata:
  name: wordpress
spec:
  type: NodePort
  selector:
    app: wordpress
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: http

wordpress才分3个

apiVersion: apps/v1
kind: Deployment
metadata:
  name: php-server
  labels:
    name: php-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: php-server
  template:
    metadata:
      labels:
        app: php-server
    spec:
      containers:
      - name: php-server
        image: php:0.1
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - mountPath: /var/www/html/
          name: nginx-data
        ports:
        - containerPort: 9000
      volumes:
      - name: nginx-data
        hostPath:
         path: /root/k8s/nmp/html
--- 
apiVersion: v1
kind: Service
metadata:
  name: php
spec:
  ports:
  - name: php
    port: 9000
    protocol: TCP
    targetPort: 9000
  selector:
    app: php-server

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-php
spec:
  selector:
    matchLabels:
      app: nginx-php
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-php
    spec:
      containers:
      - name: nginx-php
        image: nginx:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
        volumeMounts:
        - name: nginx-data
          mountPath: /usr/share/nginx/html
        - name: nginx-conf
          mountPath: /etc/nginx/conf.d/
      volumes:
      - name: nginx-data
        hostPath:
         path: /root/k8s/nmp/html
      - name: nginx-conf
        hostPath:
         path: /root/k8s/nmp/conf
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-php
spec:
  type: NodePort
  ports:
  - name: nginx
    port: 80
    protocol: TCP
    targetPort: 80
    nodePort: 30003
  selector:
    app: nginx-php

网络资源in

[root@master-1 ai]# cat wordpress.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql01
  template:
    metadata:
      labels:
        app: mysql01
    spec:
      containers:
        - name: mysql
          image: mysql:5.7
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3306
              name: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "123"
            - name: MYSQL_DATABASE
              value: wordpress
            - name: MYSQL_USER
              value: wp-
            - name: MYSQL_PASSWORD
              value: "123"
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          hostPath:
            path: /data/db
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  selector:
    app: mysql01
  ports:
    - protocol: TCP
      port: 3306

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      containers:
        - name: wordpress
          image: wordpress:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              name: http
          env:
            - name: WORDPRESS_DB_HOST
              value: mysql
            - name: WORDPRESS_DB_USER
              value: wp-
            - name: WORDPRESS_DB_PASSWORD
              value: "123"
            - name: WORDPRESS_DB_NAME
              value: wordpress
          volumeMounts:
            - name: wordpress-persistent-storage
              mountPath: /var/www/html
          resources:
            requests:
              cpu: 200m
      volumes:
        - name: wordpress-persistent-storage
          hostPath:
            path: /data/wordpress
---
apiVersion: v1
kind: Service
metadata:
  name: wordpress
spec:
  type: ClusterIP
  selector:
    app: wordpress
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: welcom-in
spec:
  rules:
  - host: www.zls.com
    http:
      paths:
      - path: /
        pathType: ImplementationSpecific
        backend:
          service:
            name: wordpress
            port:
              number: 80

标签:name,value,wordpress,mysql,spec,metadata
From: https://www.cnblogs.com/xiutai/p/17749247.html

相关文章

  • dokcer命令安装wordpress
    目录##1.镜像准备[root@docker01~]#dockerimagesREPOSITORYTAGIMAGEIDCREATEDSIZEcentos7eeb6ee3f44bd24monthsago204MB##2.创建容器[root@docker01~]#dockerrun-p80:80-dcentos:7/bin/bash-c"while......
  • DockerFile部署wordpress并制作成镜像实践
    目录DockerFile部署wordpress实践部署wordpress准备Dockerfile所需文件开始制作成镜像访问网页将wordpress打包成镜像DockerFile部署wordpress实践部署wordpress#创建dockerfile目录[root@docker02~]#mkdir/Dockerfile#进入dockerfile目录[root@docker02......
  • 不关站备案技巧分享 亲测WordPress隐藏首页正常通过备案
    官老爷规定备案过程中需要关闭网站、不要问为什么,但是正常关站会影响网站收录、流量及口碑等一系列问题,那么有没有办法(1)既不影响搜索引擎收录(2)又能顺利通过备案呢?答案是:可以。简单说就是利用JS和CSS技术隐藏网站首页,但对于搜索引擎来说首页还是正常存在的,而且其它内页均不受影响......
  • wordpress - wp_cron 计划但未触发
    我正在尝试使用wp_schedule_single_event运行在用户操作时触发的后台脚本,虽然我已经确认事件正在安排中并且wp_cron认识到预定的时间已经过去,但它不会触发事件处理程序。更复杂的是,代码在我安装的本地WP上运行良好,但在我的服务器上什么也不做。要安排事件,我正在使用:if(......
  • 彻底解决 WordPress cURL error 28 错误
    cURL连接超时。这种情况最普遍,这里的超时并不是完全不可连接,而是因为网络状况或其它原因数据传输缓慢,超过连接的时间限制导致传输中断引起的错误。不论是何种原因导致连接超时,都可以通过增加超时限制来解决此问题。但URL完全不可访问此方法是解决不了的。首先将WordPress......
  • 利用LNMP实现wordpress站点搭建
     #环境准备:nginx+php+wordpress10.0.0.152mysql+redis10.0.0.162#在10.0.0.162编写脚本实现mysqk数据库一键安装[root@localhost~]#catinstall_mysql.sh#!/bin/bash##********************************************************......
  • wordpress 编写插件实现自动汇总超链接
    背景写长篇文章时,文章内容可能会引用了很多外站的超链接。事后我再来翻阅文章,找到想要的超链很吃力。尝试过在插件商城寻找现有的插件,都不太令人满意。因为需求其实很简单:将文章内容中出现过的超链接,汇总展示在文章的末尾,类似论文的引用文献。‍实施将如下代码,放在wordpres......
  • wordpress搭建-AlmaLinux
    yuminstall-ywget&&wget-Oinstall.shhttp://download.bt.cn/install/install_6.0.sh&&shinstall.sh==================================================================Congratulations!Installedsuccessfully!========================面板账......
  • linux下shell脚本实现wordpress搭建
    wordpress_auto_install.sh  #!/bin/bashuser=$(whoami)functionwordpress_auto_install(){if[$user=="root"];thenecho"前提:调整系统配置,如关闭selinux、firewall等!"sed-i's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/......
  • 基于Linux+宝塔面板+LNMP+Wordpress搭建的网站主页的网站漏洞修补的解决方案 (1)
    基于Linux+宝塔面板+LNMP+Wordpress搭建的网站主页1.网站漏洞修补的解决方案@目录基于Linux+宝塔面板+LNMP+Wordpress搭建的网站主页前言为什么要做网站漏洞扫描降低资产所面临的风险满足法律合规要求满足业界安全最佳实践及认证需求其他参考信息等级保护网络安全法安全建议漏......