<commit_before>= Networking
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

Kubernetes ensures that pods are able to network with each other, and
allocates each pod an IP address from an internal network. This ensures all
containers within the pod behave as if they were on the same host. Giving each
pod its own IP address means that pods can be treated like physical hosts or
virtual machines in terms of port allocation, networking, naming, service
discovery, load balancing, application configuration, and migration.

Creating links between pods is unnecessary. However, it is not recommended that
you have a pod talk to another directly by using the IP address. Instead, we
recommend that you create a
link:../core_objects/kubernetes_model.html#service[service], then interact with
the service.

== OpenShift DNS

If you are running multiple
link:../core_objects/kubernetes_model.html#service[services], such as frontend
and backend services for use with multiple pods, in order for the frontend pods
to communicate with the backend services, environment variables are created for
user names, service IP, and more. If the service is deleted and recreated, a new
IP address can be assigned to the service, and requires the frontend pods to be
recreated in order to pick up the updated values for the service IP environment
variable. Additionally, the backend service has to be created before any of the
frontend pods to ensure that the service IP is generated properly and that it
can be provided to the frontend pods as an environment variable.

For this reason, OpenShift has a built-in DNS so that the services can be
reached by the service DNS as well as the service IP/port. OpenShift supports
split DNS by running link:https://github.com/skynetservices/skydns[SkyDNS] on the master that answers DNS queries for
services. The master listens to port 53 by default.

When the node starts, the following message indicates the Kubelet is correctly
resolved to the master:

----
0308 19:51:03.118430    4484 node.go:197] Started Kubelet for node
openshiftdev.local, server at 0.0.0.0:10250
I0308 19:51:03.118459    4484 node.go:199]   Kubelet is setting 10.0.2.15 as a
DNS nameserver for domain "local"
----

If the second message does not appear, the Kubernetes service may not be available.

On a node host, each Docker container's nameserver has the master added to the
front, and the default search domain for the container will be
`._<pod_namespace>_.local`. The container will then direct any nameserver
queries to the master before any other nameservers on the node, which is the
default Docker behavior. The master will answer queries on the `.local` domain
that have the following form:

----
<pod_namespace>.local
<service>.<pod_namespace>.local
----

This prevents having to restart frontend pods in order to pick up new services,<commit_msg>edited DNS info and changed to table<commit_after>= Networking
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

Kubernetes ensures that pods are able to network with each other, and
allocates each pod an IP address from an internal network. This ensures all
containers within the pod behave as if they were on the same host. Giving each
pod its own IP address means that pods can be treated like physical hosts or
virtual machines in terms of port allocation, networking, naming, service
discovery, load balancing, application configuration, and migration.

Creating links between pods is unnecessary. However, it is not recommended that
you have a pod talk to another directly by using the IP address. Instead, we
recommend that you create a
link:../core_objects/kubernetes_model.html#service[service], then interact with
the service.

== OpenShift DNS

If you are running multiple
link:../core_objects/kubernetes_model.html#service[services], such as frontend
and backend services for use with multiple pods, in order for the frontend pods
to communicate with the backend services, environment variables are created for
user names, service IP, and more. If the service is deleted and recreated, a new
IP address can be assigned to the service, and requires the frontend pods to be
recreated in order to pick up the updated values for the service IP environment
variable. Additionally, the backend service has to be created before any of the
frontend pods to ensure that the service IP is generated properly and that it
can be provided to the frontend pods as an environment variable.

For this reason, OpenShift has a built-in DNS so that the services can be
reached by the service DNS as well as the service IP/port. OpenShift supports
split DNS by running link:https://github.com/skynetservices/skydns[SkyDNS] on the master that answers DNS queries for
services. The master listens to port 53 by default.

When the node starts, the following message indicates the Kubelet is correctly
resolved to the master:

----
0308 19:51:03.118430    4484 node.go:197] Started Kubelet for node
openshiftdev.local, server at 0.0.0.0:10250
I0308 19:51:03.118459    4484 node.go:199]   Kubelet is setting 10.0.2.15 as a
DNS nameserver for domain "local"
----

If the second message does not appear, the Kubernetes service may not be available.

On a node host, each Docker container's nameserver has the master name added to the
front, and the default search domain for the container will be
`._<pod_namespace>_.cluster.local`. The container will then direct any nameserver
queries to the master before any other nameservers on the node, which is the
default Docker behavior. The master will answer queries on the `.cluster.local` domain
that have the following form:

.DNS Example Names
[cols=".2,.^5,8",options="header"]
|===

|Object Type |Example

|Default
|<pod_namespace>.cluster.local

|Services
|<service>.<pod_namespace>.svc.cluster.local

|Endpoints
|<name>.<namespace>.endpoints.cluster.local
|===

This prevents having to restart frontend pods in order to pick up new services,
{'fraction_non_alphanumeric': 0.05790866975512905, 'fraction_numerical': 0.021343481138318993, 'mean_word_length': 4.686735653809972, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4547795', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1546, 'n_words': 867}