Minikube expose MySQL running on localhost as service

后端 未结 3 701
囚心锁ツ
囚心锁ツ 2020-11-29 06:23

I have minikube version v0.17.1 running on my machine. I want to simulate the environment I will have in AWS, where my MySQL instance will be outside of my Kubernetes cluste

3条回答
  •  情书的邮戳
    2020-11-29 07:06

    Kubernetes allows you to create a service without selector, and cluster will not create related endpoint for this service, this feature is usually used to proxy a legacy component or an outside component.

    1. Create a service without selector

      apiVersion: v1
      kind: Service
      metadata:
          name: my-service
      spec:
          ports:
              - protocol: TCP
                port: 1443
                targetPort: 
      
    2. Create a relative Endpoint object

      apiVersion: v1
      kind: Endpoints
      metadata:
          name: my-service
      subsets:
          - addresses:
              - ip: 
            ports:
              - port: 
      
    3. Get service IP

      $ kubectl get svc my-service
      NAME         CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
      my-service              1443/TCP    18m
      
    4. Access your MYSQL from service :1443 or my-service:1443

提交回复
热议问题