Minikube Exposing mysql as a service on localhost

0 votes

I am running minikube 0.17.1 on my local machine to simulate the environment for my setup in AWS. I want to run mysql outside of my kubernetes cluster.

I just want to now how I can expose my local mysql instance to the kubernetes cluster using minikube?

Oct 13, 2018 in Kubernetes by shubham
• 7,340 points
7,764 views

1 answer to this question.

0 votes

You can create services without selector in kubernetes and the cluster will not create a related endpoint for the created service. This is used in the situation like yours, where you want to access an outside component.

  1. Firstly, create a service without selector

    apiVersion: v1
    kind: Service
    metadata:
        name: my-service
    spec:
        ports:
            - protocol: TCP
              port: 1443
              targetPort: <YOUR_MYSQL_PORT>
    
  2. Now, create a relative Endpoint object

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

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

answered Oct 13, 2018 by DareDev
• 6,890 points
What is <YOUR_MYSQL_PORT> when the service is running on my localhost?
here the <YOUR_MYSQL_PORT> would be the port on which the service is hosted, could be port 80 or 8080.

Related Questions In Kubernetes

0 votes
2 answers

How can I access a service installed on Kubernetes from anywhere?

if u want to directly want to ...READ MORE

answered Jul 26, 2020 in Kubernetes by Akash Gupta
1,317 views
0 votes
1 answer
0 votes
1 answer

What is Ingress ? Is it something that runs as a pod or on a pod?

An ingress is an object that holds ...READ MORE

answered Jul 19, 2019 in Kubernetes by Sirajul
• 59,230 points
1,900 views
0 votes
1 answer
0 votes
1 answer

permissions related to AWS ECR

if you add allowContainerRegistry: true, kops will add those permissions ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 52,350 points
1,396 views
0 votes
1 answer

Create LoadBalancer for kubernetes cluster in aws

Hello @Lina, If you're running your cluster on ...READ MORE

answered Oct 8, 2018 in Kubernetes by Kalgi
• 52,350 points
751 views
+1 vote
1 answer
0 votes
1 answer
0 votes
3 answers

Using multiple commands in a kubernetes yaml file

Try something like this: containers: - name: ...READ MORE

answered Apr 23, 2019 in Kubernetes by lyza
49,873 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP