当前位置:网站首页>k8s部署mysql
k8s部署mysql
2022-04-22 21:06:00 【吕海洋】
目录
一、新建namespace
1、创建 namespace
kubectl create namespace lhynamespace
2、查看 namespace
kubectl get namespace
3、删除 namespace
kubectl delete namespace lhynamespace
二、新建deployment
1、生成yaml文件
kubectl create deployment mysql8 --image=mysql:8 --dry-run -o yaml > mysql8_deployment.yaml
2、修改yaml文件
指定 namespace
metadata:
namespace: lhynamespace
3、创建 deployment
kubectl apply -f mysql8_deployment.yaml
4、查看 lhynamespace 命名空间下的 deployment
kubectl get deployment -n lhynamespace
kubectl get deployment --all-namespaces //查看所有namespace
5、删除 lhynamespace 命名空间下的 mysql8 的 deployment ,删除deployment 之后 pod 自动删除 通过yaml创建的,通过yaml文件删除
kubectl delete -f mysql8_deployment.yaml
kubectl delete deployment mysql8 -n lhynamespace //命令删除
三、新建service
kubectl expose -f mysql8_deployment.yaml --port=3306 --target-port=3306 --type=NodePort -n lhynamespace -o yaml > mysql8_service.yaml
集群内部访问端口 3306
物理机映射端口 可以查看生成的yaml文件的 nodePort
也可以根据生成的yaml 修改配置重新部署service
四、部署用到的yaml文件
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: mysql8
name: mysql8
namespace: lhynamespace
spec:
replicas: 2
selector:
matchLabels:
app: mysql8
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: mysql8
spec:
containers:
- image: mysql:8
name: mysql8
resources: {}
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
ports:
- name: mysql-3306
containerPort: 3306
protocol: TCP
status: {}
service.yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2022-04-22T11:22:53Z"
labels:
app: mysql8
name: mysql8
namespace: lhynamespace
resourceVersion: "11201"
uid: ea56fbb1-4e20-4c4e-8990-c3859e2cb9fc
spec:
clusterIP: 10.105.91.138
clusterIPs:
- 10.105.91.138
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- nodePort: 30001
port: 3306
protocol: TCP
targetPort: 3306
selector:
app: mysql8
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
版权声明
本文为[吕海洋]所创,转载请带上原文链接,感谢
https://blog.csdn.net/wuchenlhy/article/details/124353338
边栏推荐
猜你喜欢
阿里面试官:简历上最好不要写Glide,不是问源码那么简单

88 r user portrait linear regression logical regression comprehensive practice 1

【MySQL从入门到精通】:关于常用like子句中通配符的总结

(1) UART subsystem learning plan

345-Leetcode 赎金信

WampServer 搭建本地服务器及 XSS 基本原理和初步实践(一)

DSPACE模拟简单事故现场
![[radar] point target simulation of simulated synthetic aperture radar (SAR)](/img/65/12a9a76c5e5590e0008bdc00f3148c.png)
[radar] point target simulation of simulated synthetic aperture radar (SAR)
![buuctf-[Flask]SSTI](/img/62/f272848dd18b75fd837621458b573c.png)
buuctf-[Flask]SSTI

Smart agriculture has become a development path, give full play to intelligence and liberate manpower
随机推荐
. 102 keyboard move div
站长工具大全-站长软件网站-站长工具网站-站长必备工具免费
UnityShader入门精要——素描效果渲染
jmeter视频教学课程
工控安全解决方案
Rong Lianyun joined hands with China Academy of information and communications to start the development of a series of standards for office instant messaging software
基于SEIR模型的传染病预测软件开发
Summary of software testing knowledge points | JMeter implementation Interface Association
How to install monitoring without network in rural areas, and what kind of monitoring without WiFi at home
软件测试工具最全的抓包工具的综合对比
【youcans 的 OpenCV 例程200篇】160. 图像处理之OTSU 方法
2、 Linear regression
置信区间与区间估计
TC 结构管理器 - 打包 解包
自媒体运营中千万不能做的四件事情
Minio基本使用与原理
MySQL advanced stored procedure storage function -- Introduction to stored procedure, basic syntax of stored procedure, variables (system variables, user-defined variables, local variables), if, param
TC process addition status
Implementation of simple FreeRTOS task blocking delay based on gd32f1x0 manual programming
LeetCode-238-除自身以外数组的乘积