apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  namespace: development
spec:
  replicas: 2
  template:
    metadata:
      labels:
        name: mysql
    spec:
      containers:
      - name: mysql
        image: mysql
        imagePullPolicy: Always
        ports:
        - containerPort: 3306
        environment:
          MYSQL_ROOT_PASSWORD:123456
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: development
spec:
  type: NodePort
  ports: 
  - port: 3306
    nodePort: 10306
    targetPort: 3306
  selector:
    name: mysql
访问数据库:IP+10306端口
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐