Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
How to access mysql outside my kubernetes cluster?

I am running a kubernetes cluster in my centos machine. I donot want to create a pod for mysql. MySQL is installed in another machine in same network (Machine is not in kubernates private network).

How can I access the mysql service from the pods running in kubernetes cluster ?

I have tried with service and end point with below configuration. But, No luck.

apiVersion: v1
kind: Service
metadata:
  name: database
spec:
  ports:
  - port: 13080
    targetPort: 13080
    protocol: TCP
---
kind: Deployment
apiVersion: v1
metadata:
  name: database
subsets:
  - addresses:
      - ip: XX.XX.XX.XX
    ports:
      - port: 13080
---
kind: ReplicationController
metadata:
  name: test
spec:
  replicas: 1
  selector:
    app: test
  template:
    metadata:
      name: test
      labels:
        app: test
    spec:
      containers:
      - name: my_pods
        image: my_pods
        env:
         - name: DATABASE_HOST
           value: database
         - name: DATABASE_PORT
           value: "13080"
         - name: DATABASE_USER
           value: "SAAS"
         - name: DATABASE_PASSWORD
           value: "SAAS"
         - name: DATABASE_NAME
           value: "SAASDB"
        ports:
          - containerPort: 8080
      imagePullSecrets:
        - name: my-secret
---
apiVersion: v1
kind: Service
metadata:
  name: test-service
  labels:
    name: test-service
spec:
  type: NodePort
  ports:
     - port: 11544
       targetPort: 8080
       nodePort: 30600
  selector:
    name: test
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You don't need a service for things outside the cluster. Depending on the networking model you're using, the docker container (ie kubernetes pod) should be able to connect to the MySQL container normally via the bridge that Docker sets up. Check the host has connectivity on port 3306, and it does, simply put in the DNS name (your kube-dns pod should forward any non kubernetes based requests on to the hosts resolv.conf of the host it was scheduled on)

over 4 years ago · Santiago Trujillo Denunciar

0

pls try this:

kubectl delete svc database kubectl create service nodeport database --tcp=13080:13080

then use cmd below to get right ip and port

kubectl get svc database

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda