Kubernetes (container engine) by Google, Inc. is licensed under CC
Client applications can be configured to connect to services directly.
Client applications can be configured to connect to services via a gateway.
A client might be a web page running in a browser or a mobile phone app.
The diagram above demonstrates how an API gateway sits between a client and a collection of services.
An API Gateway introduces latency but provides a number of benefits:
Here we use nginx as the basis of our reverse proxy. In the Docker file we specify that the /etc/nginx/conf.d/default.conf file in the nginx image will be replaced by a custom my-server.config
Dockerfile
The proxied server URLs are set using the proxy_pass directive.
my-server.conf
Kubernetes is a platform for managing containerized workloads.
The yaml file below ensures that there are two copies of the books image, two copies of the books-react image and one copy of the books-reverse-proxy image running at all times.
The books-reverse-proxy image is the API Gateway.
The yaml file below ensures that clients are only able to connect to the API Gateway.
The books container image provides a REST API Service.
The books-react container image provides a React App.
Kubernetes cluster example
Kubernetes hosting is offered by Microsoft (Azure), Amazon (AWS) and Google (Google Cloud).
Kubernetes can be run on a developer's laptop using Docker Desktop or Minikube.
Kubernetes can be run on a collection of Raspberry Pi computers using K3s.
Shown below is a copy of Docker Desktop hosting the Kubernetes cluster described above.
Docker Desktop