Search code examples
kuberneteskubernetes-networking

Problems to communicate kubernetes pod with external endpoints (rest services, sql server, kafka, redis etc...)


I have a kubernetes cluster of one node. I have java services dockerized that access to rest services, sql server, kafka and another endpoints outside kubernetes cluster but in the same google cloud network.

The main reason cause I ask for help is that I can't connect the java services dockerized inside the pod to before mentioned external endpoints.

I've try before with flannel network but now I've reset the cluster and I've installed calico network without positive results.

Pods of the custer running by default: Cluster pods

Cluster nodes:

Cluster nodes

I deploy some java services dockerized as cronjobs, others as deployments. To comunicate this cronjobs or deployments with external endpoints like Kafka, Sql Server, etc I use services.

An example of each of them: Cronjob:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
   name: cronjob-name
spec:
  schedule: "*/5 * * * *"
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            cronjob1: cronjob-name
        spec:
          containers:
            - image: repository/repository-name:service-name:version
              imagePullPolicy: ""
              name: service-name
              resources: {}
          restartPolicy: OnFailure
  selector:
    matchLabels:
      cronjob1: cronjob-name

Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    deployment1: deployment_name
  name: deployment_name
spec:
  replicas: 1
  selector:
    matchLabels:
      deployment1: deployment_name
  strategy: {}
  template:
    metadata:
      labels:
        deployment1: deployment_name
    spec:
      containers:
      - image: repository/repository-name:service-name:version
        imagePullPolicy: ""
        name: service-name
        resources: {}
      imagePullSecrets:
       - name: dockerhub
      restartPolicy: Always
      serviceAccountName: ""
      volumes: null
status: {}

Service:

apiVersion: v1
kind: Service
metadata:
  name: sqlserver
spec:
  type: ClusterIP
  selector:
    cronjob1: cronjob1
    deployment1: deployment1
  ports:
    - protocol: TCP
      port: 1433
      targetPort: 1433

My problem is that from java services I can't connect, for example, with Sql Server Instance. I've verified DNS and calico pods logs and there weren't errors. I've try to connect by ssh to pods while it's running and from pod inside I can't do telnet to Sql Server instance.

¿Could you give me some idea about the problem is? or ¿what test could I do?

¡Thank you very much!


Solution

  • I resolved the problem configuring Kubernetes cluster again but with calico instead of fannel.Thanks for the replies. I hope this help anyone else.