hwuukki
hwuukki

Reputation: 21

Fetch Request to a Docker container

In my front end (deployed as an AWS ECS service), I have a fetch request to an AWS Route 53 host name which is directed to a backend ECS service. Now I would like to deploy this infrastructure locally in a Kubernetes Minikube cluster. If the front-end pod and the back-end pod are connected together using a Kubernetes Service, should I replace that fetch's method argument to the DNS name of the back-end pod?

fetch(Route_53_Route)

to

fetch(DNS_name_of_backend_pod)

Upvotes: 0

Views: 348

Answers (1)

Asri Badlah
Asri Badlah

Reputation: 2123

1- Creating the backend Service object:

he key to connecting a frontend to a backend is the backend Service. A Service creates a persistent IP address and DNS name entry so that the backend microservice can always be reached.

apiVersion: v1
kind: Service
metadata:
  name: hello
spec:
  selector:
    app: hello
    tier: backend
  ports:
  - protocol: TCP
    port: 80
    targetPort: http

2- Creating the frontend:

Now that you have your backend, you can create a frontend that connects to the backend. The frontend connects to the backend worker Pods by using the DNS name given to the backend Service. The DNS name is "hello", which is the value of the name field in the preceding Service configuration file.

Upvotes: 1

Related Questions