我们还是使用内网的Docker私有镜像仓库,第一次运行时会从镜像仓库中拉取镜像到机器上,以后就直接在机器上运行加快速度;
直接上配置文件:
mysql-rc.yaml
kind: ReplicationController
metadata:
name: my-mysql-v1
namespace: default
labels:
name: my-mysql
version: v1
spec:
replicas: 1
selector:
name: my-mysql
version: v1
template:
metadata:
labels:
name: my-mysql
version: v1
spec:
containers:
- image: reg.docker.tb/harbor/mysql:latest
name: my-mysql-v1
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: abcd123
volumeMounts:
- name: mysql-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-storage
hostPath:
path: /data/mysql
mysql-svc.yaml 注意这里直接指定了宿主机的IP地址;
apiVersion: v1
kind: Service
metadata:
name: my-mysql
namespace: default
labels:
name: my-mysql
spec:
externalIPs:
- 10.0.10.135
ports:
- port: 3306
targetPort: 3306
selector:
name: my-mysql