%title缩略图

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"

%title插图%num

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

%title插图%num

执行部署:

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

%title插图%num

删除命名空间:

kubectl delete ns mysql

作者 匿名

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

18 − 1 =