Changes

Jump to navigation Jump to search
add External Name
: something
; <tt>type: ExternalName</tt>
: map a Service to a DNS name, not to a typical selector such as my-service or cassandra
: This Service definition, for example, maps the <tt>my-service</tt> Service in the <tt>prod</tt> namespace to <tt>my.database.example.com</tt>:
: <syntaxhighlight lang="yaml">
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: prod
spec:
type: ExternalName
externalName: my.database.example.com
</syntaxhighlight>
: When looking up the host <tt>my-service.prod.svc.cluster.local</tt>, the cluster DNS Service returns a <tt>CNAME</tt> record with the value <tt>my.database.example.com</tt>. Accessing <tt>my-service</tt> works in the same way as other Services but with the crucial difference that redirection happens at the DNS level rather than via proxying or forwarding. Should you later decide to move your database into your cluster, you can start its Pods, add appropriate selectors or endpoints, and change the Service's type.
:
: Note: although you can use an IPv4 address string of digits as the name, don't do it.
: Consider using [https://kubernetes.io/docs/concepts/services-networking/service/#headless-services headless services] for that use case.
{{References}}
[[Category:Kubernetes]]

Navigation menu