当前位置: 首页 > news >正文

9.23-部署项目

部署项目

一、先部署mariadb

[root@k8s-master ~]# mkdir aaa
[root@k8s-master ~]# cd aaa/
[root@k8s-master aaa]# # 先部署mariadb
[root@k8s-master aaa]# # configmap
[root@k8s-master aaa]# vim mariadb-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:name: mariadb-configmap
data:USER: "wp"PASSWORD: "123"ROOT_PASSWORD: "123"DATABASE: "db"[root@k8s-master aaa]# kubectl create -f mariadb-configmap.yaml 
configmap/mariadb-configmap created
[root@k8s-master aaa]# # deployment
[root@k8s-master aaa]# vim mariadb.deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:name: mariadb-deploymentlabels:app: mariadb-deployment
spec:replicas: 1selector:matchLabels:app: mariadb-deploymenttemplate:metadata:labels:app: mariadb-deploymentspec:containers:-       name: mariadbimage: docker.io/library/mariadb:latestimagePullPolicy: Neverports:-       name: mariadbportcontainerPort: 3306envFrom:-       prefix: "MARIADB_"configMapRef:name: mariadb-configmap[root@k8s-master aaa]# kubectl create -f mariadb.deployment.yaml 
deployment.apps/mariadb-deployment created
[root@k8s-master aaa]# kubectl get pod
NAME                                  READY   STATUS             RESTARTS      AGE
cluster-test0-58689d5d5d-7c49r        1/1     Running            4 (16m ago)   3d2h
haha-96567ff6f-r2mh5                  0/1     ImagePullBackOff   0             3d2h
mariadb-deployment-5bf6d9f98c-9mddb   1/1     Running            0             22s
wordpress-7695bd58f4-42hx2            1/1     Running            1 (16m ago)   2d23h
wordpress-7695bd58f4-dqp8q            1/1     Running            1 (16m ago)   2d23h
wordpress-7695bd58f4-v8j7l            1/1     Running            1 (16m ago)   2d23h
[root@k8s-master aaa]# kubectl get po -o wide
NAME                                  READY   STATUS             RESTARTS      AGE     IP              NODE         NOMINATED NODE   READINESS GATES
cluster-test0-58689d5d5d-7c49r        1/1     Running            4 (20m ago)   3d2h    172.16.58.193   k8s-node02   <none>           <none>
haha-96567ff6f-r2mh5                  0/1     ImagePullBackOff   0             3d2h    172.16.85.234   k8s-node01   <none>           <none>
mariadb-deployment-5bf6d9f98c-9mddb   1/1     Running            0             4m34s   172.16.85.237   k8s-node01   <none>           <none>
wordpress-7695bd58f4-42hx2            1/1     Running            1 (20m ago)   2d23h   172.16.58.255   k8s-node02   <none>           <none>
wordpress-7695bd58f4-dqp8q            1/1     Running            1 (20m ago)   2d23h   172.16.85.233   k8s-node01   <none>           <none>
wordpress-7695bd58f4-v8j7l            1/1     Running            1 (20m ago)   2d23h   172.16.85.235   k8s-node01   <none>           <none>[root@k8s-master aaa]# mysql -h 172.16.85.237 -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 11.5.2-MariaDB-ubu2404 mariadb.org binary distributionCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> exit
Bye[root@k8s-master aaa]# vim mariadb-service.yaml
[root@k8s-master aaa]# kubectl create -f mariadb-service.yaml 
service/mariadb-service created
[root@k8s-master aaa]# kubectl get svc
NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes        ClusterIP   10.96.0.1       <none>        443/TCP          12d
mariadb-service   NodePort    10.96.148.212   <none>        3306:30117/TCP   15s
[root@k8s-master aaa]# kubectl get pod
NAME                                  READY   STATUS             RESTARTS      AGE
cluster-test0-58689d5d5d-7c49r        1/1     Running            4 (33m ago)   3d2h
haha-96567ff6f-r2mh5                  0/1     ImagePullBackOff   0             3d2h
mariadb-deployment-5bf6d9f98c-9mddb   1/1     Running            0             17m
wordpress-7695bd58f4-42hx2            1/1     Running            1 (33m ago)   2d23h
wordpress-7695bd58f4-dqp8q            1/1     Running            1 (33m ago)   2d23h
wordpress-7695bd58f4-v8j7l            1/1     Running            1 (33m ago)   2d23h

二、在远程登录工具上进行登录测试,端口号为30117,用户为root,密码为123

三、使用测试工具:

[root@k8s-master aaa]# kubectl exec -it pods/cluster-test0-58689d5d5d-7c49r -- bash

四、部署wordpress

[root@k8s-master aaa]# vim wordpress-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:name: wordpress-config
data:NAME: "db"USER: "wp"PASSWORD: "123"HOST: "mariadb-service"[root@k8s-master aaa]# kubectl create -f wordpress-configmap.yaml 
configmap/wordpress-config created
[root@k8s-master aaa]# kubectl get cm
NAME                DATA   AGE
kube-root-ca.crt    1      12d
mariadb-cm          4      3d2h
mariadb-configmap   4      50m
wordpress-cm        4      3d
wordpress-config    4      38s
[root@k8s-master aaa]# vim wordpress-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:name: wordpress-deploymentlabels:app: wordpress-deployment
spec:replicas: 2selector:matchLabels:app: wordpress-deploymenttemplate:metadata:labels:app: wordpress-deploymentspec:containers:-       name: wpimage: docker.io/library/wordpress:latestimagePullPolicy: Neverports:-       name: wordpressportcontainerPort: 80envFrom:-        prefix: "WORDPRESS_DB_"configMapRef:name: wordpress-config[root@k8s-master aaa]# kubectl create -f wordpress-deployment.yaml 
deployment.apps/wordpress-deployment created
[root@k8s-master aaa]# kubectl get pod
NAME                                    READY   STATUS             RESTARTS        AGE
cluster-test0-58689d5d5d-7c49r          1/1     Running            5 (9m35s ago)   3d3h
haha-96567ff6f-r2mh5                    0/1     ImagePullBackOff   0               3d3h
mariadb-deployment-5bf6d9f98c-9mddb     1/1     Running            0               54m
wordpress-7695bd58f4-42hx2              1/1     Running            1 (70m ago)     3d
wordpress-7695bd58f4-dqp8q              1/1     Running            1 (70m ago)     3d
wordpress-7695bd58f4-v8j7l              1/1     Running            1 (70m ago)     3d
wordpress-deployment-555685954b-52lbs   1/1     Running            0               15s
wordpress-deployment-555685954b-d8qqz   1/1     Running            0               15s
[root@k8s-master aaa]# vim wordpress-service.yaml
apiVersion: v1
kind: Service
metadata:name: wordpress-deployment
spec:selector:app: wordpress-deploymentports:-       name: httpport: 80targetPort: 80nodePort: 32000protocol: TCPtype: NodePort[root@k8s-master aaa]# kubectl create -f wordpress-service.yaml 
service/wordpress-deployment created
[root@k8s-master aaa]# kubectl get svc
NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes             ClusterIP   10.96.0.1       <none>        443/TCP          12d
mariadb-service        NodePort    10.96.148.212   <none>        3306:30117/TCP   46m
wordpress-deployment   NodePort    10.96.26.205    <none>        80:32000/TCP     1s

五、浏览器访问本机地址: 192.168.2.66:32000


http://www.mrgr.cn/news/34320.html

相关文章:

  • AlphaFold3中文安装教程
  • TofuAI处理BT1120时序视频要求
  • 商品规格递归拼接
  • 基于ECS实例搭建Hadoop环境
  • Hive基础
  • 【Webpack配置全解析】打造你的专属构建流程️(4)
  • 基于深度学习的竞争性对抗学习
  • 场景题面试题——第一篇
  • freemobus阅读笔记
  • 比亚迪技术面试(测试、测开)
  • 公测两次延期、被网易拉黑,乙游《米修斯之印》能“活”下来吗?
  • python对文件的写入和追加
  • 基于QT的C++中小项目软件开发架构源码
  • 【Centos 8安装VNC及多用户配置详细教程】
  • docker安装及使用
  • 公司将被千万美金收购,工程师却误删数据库 —— 没 有 备 份!!!
  • 深度解读 2024 Gartner DevOps 魔力象限
  • cadence 17.4之allegro 不能设置net颜色
  • 中小微企业生产管理利器-- 超轻量生产工单系统
  • 【实战篇】读写分离有哪些坑?
  • 对条件语言模型(Conditional Language Model)的目标函数的理解
  • 美业SaaS收银系统如何收银?博弈美业实操/美业门店管理系统源码
  • 湖北建筑类初级职称申报的全方位解读
  • 1000Km弹射巡飞器技术详解
  • struts2
  • 使用代理服务导致网络延迟增大的影响