kubernetes endpoints

endpoints is normally used behind the scene, without the need of any manual intervention.

However, for local testing, it could become helpful to leverage on the endpoints customization.

---	
  kind: "Service"
  apiVersion: "v1"
  metadata:
    name: "svc-to-external-web"
  spec:
    ports:
      - name: "apache"
        protocol: "TCP"
        port: 80
        targetPort: 80 
---
  kind: "Endpoints"
  apiVersion: "v1"
  metadata:
    name: "svc-to-external-web" 
  subsets: 
    - addresses:
        - ip: "8.8.8.8" #The IP Address of the external web server
        ports:
        - port: 80 
          name: "apache"

for example, with above, if we create a service without any selector (of any pods/deployments), and manually create an endpoint with the same name as the service, then we can configure where the endpoint point to, which could be an external IP address, or maybe to a docker service

like

apiVersion: v1
kind: Endpoints
metadata:
  name: svc-to-external-web
subsets:
- addresses:
  - ip: 192.168.64.1 # minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }'"
  ports:
  - port: 80

ref: https://theithollow.com/2019/02/04/kubernetes-endpoints/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s