access a external service running on a vm form inside kubernetes pod

1/26/2018

I have a cluster in aws and using kubernetes. I have an app running on a machine (vm) in the same network as the cluster in my browser i can type http://ipaddress:port/status and i get a response

In my pod i can ping the ip address and i get a response but if i do wget://ipaddress:port/status it doesn't connect.

I have tried some things but not able to succeed. How do i get the pod in the cluster to be be able to open this url, what do I need to do?

-- Anita Kumar
kubernetes

1 Answer

1/27/2018

You can integrate external services within kubernetes.

endpoint.yaml

    kind: Endpoints
    apiVersion: v1
    metadata:
      name: external-ip-database
    subsets:
      - addresses:
        - ip: 192.168.0.1
        ports:
    - port: 3306

service.yaml

    apiVersion: v1
    kind: Service
    metadata:
      name: database
    spec:
      ports:
      - port: 1433
        targetPort: 1433
        protocol: TCP
    ---
    # Because this service has no selector, the corresponding Endpoints
    # object will not be created. You can manually map the service to
    # your own specific endpoints:
    kind: Endpoints
    apiVersion: v1
    metadata:
      name: database
    subsets:
      - addresses:
          - ip: "192.168.1.103"
        ports:
          - port: 1433
-- Pamir Erdem
Source: StackOverflow