1

This is my first foray into Kubernetes land... I'm still pretty shaky on how things work and still wrapping my head around some of the concepts so please bear with me there.

The application I am deploying needs access to a couple of external third party http rest apis. What I believe I need from reading the docs is a service with an endpoint that points to the external rest apis ip. This is what I have in my helm templates:

service.yaml:

apiVersion: v1
kind: Service
metadata:
  labels:
    run: external_rest_service
  name: external_rest_service
spec:
  ports:
  - port: 443

My endpoint.yaml:

kind: Endpoints
apiVersion: v1
metadata:
 name: external_rest_service
subsets:
 - addresses:
     - ip: https://www.someservice.com/api
   ports:
     - port: 443

This of course doesn't work because ip needs to be an ip address. However, when I do an nslookup of the rest api I get back 3 different ip addresses which I believe may be because of round robin dns. Oddly when I try any of the ip addresses directly via curl I don't get a response. My questions are..

  • Is this the correct or best practice approach to giving access to an outside resource from within my cluster?
  • Can I configure (and should I) configure Kubernetes to allow access via domain name instead of ip? If so.. where do I configure this? I'm not seeing it when searching the docs.

If anyone could give me any guidance here I would really appreciate it. Thanks much!

2 Answers 2

1

Usually to access an external API you can just use its URL. But you can create a Service for it if you like, the type of service should be ExternalName as described in the documentation https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types

1

A service in kubernetes is (mostly) used for internal communication. If you want to access an external resource by domain/ip you can just do so. If you have an IP address and you would like to have some sort of domain connected to it, you could you am service with the external name field set to the up address (we use that for database purposes). An endpoint is automatically created for you when you create an service so you don’t nees to bother with that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.