树莓派集群安装rpi-mysql数据库服务

一.编排文件

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
    targetPort: 3306
    protocol: TCP
    nodePort: 31306
    protocol: TCP
    name: port
  type: NodePort
  selector:
    app: mysql
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: mysql
    spec:
      nodeSelector:
        kubernetes.io/hostname: knode3  #指定knode3运行服务
      volumes:
      - name: data
        hostPath:
          path: /data/mysql/data
      - name: conf
        hostPath:
          path: /data/mysql/conf
      containers:
        - name: server
          image: hypriot/rpi-mysql  #仍采用hypriot系列镜像做为基础镜像
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "123456"
          ports:
            - containerPort: 3306
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: data
            - mountPath: /etc/mysql/conf.d
              name: conf

执行kubectl create -f public/mysql
运行结果

POD运行在knode3上

服务端口指向了31306

客户端连接测试

你可能感兴趣的:(树莓派集群安装rpi-mysql数据库服务)