NOTES INDEX This page is part of the collection of "notes" - these can be considered to be micro-blogs.
Kubernetes External Service

Kubernetes External Service

To make a local service in a Kubernetes cluster, which points to an address on a remote system, you can use the following yaml as example:

apiVersion: v1
kind: Service
metadata:
  name: local-service
  namespace: my-namespace
spec:
  externalName: remote-service.somewhere.com
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 80
  sessionAffinity: None
  type: ExternalNameCode language: YAML (yaml)

This probably (will test this some time later) will also work if you want to move a service from “namespace-a” to “namespace-b”, and want to keep a reference inside “namespace-a” for other pods which depend on it:

apiVersion: v1
kind: Service
metadata:
  name: the-service
  namespace: namespace-a
spec:
  externalName: the-service.namespace-b
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 8080
  sessionAffinity: None
  type: ExternalNameCode language: YAML (yaml)

December 19, 2021

Leave a Reply

Your email address will not be published. Required fields are marked *