Kubectl部署mysql

Kubectl部署mysql

vi mysql-rc.yaml

apiVersion: v1
kind: ReplicationController
metadata:
name: mysql
labels:
name: mysql
spec:
replicas: 2
selector:
name: mysql-pod
template:
metadata:
labels:
name: mysql-pod
spec:
containers:
- name: mysql
image: mysql:5.7
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"

image 92 - Kubectl部署mysql

vi mysql-svc.yaml

apiVersion: v1
kind: Service
metadata:
name: mysql-svc
labels:
name: mysql-svc
spec:
type: NodePort
ports:

- port: 3306
protocol: TCP
targetPort: 3306
name: http
nodePort: 30002
selector:
name: mysql-pod

image 91 - Kubectl部署mysql

执行部署:

kubectl create -f mysql-rc.yaml

kubectl create -f mysql-svc.yaml

安装mysql客户端:

yum install mysql -y

测试连接: mysql -h 192.168.36.19 -P30002 -uroot -p

image 90 - Kubectl部署mysql

删除命名空间:

kubectl delete ns mysql

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片