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 12, 2018 in Kubernetes by shubham
• 6,890 points
1,032 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 12, 2018 by DareDev
• 6,810 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
1 answer

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

I have followed the link which you have ...READ MORE

answered Jul 23, 2018 in Kubernetes by Atul
• 10,240 points
114 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

“403 Insufficient Permission” while creating a Kubernetes Cluster on Google Cloud instance

To run ./cluster/kube-up.sh, you most likely need compute scope ...READ MORE

answered Aug 28, 2018 in Kubernetes by Kalgi
• 39,170 points
114 views
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
• 39,170 points
56 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
• 39,170 points
48 views
0 votes
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 in Kubernetes by lyza
4,127 views