Professional Documents
Culture Documents
40-Kubernetes Io Docs Concepts Services Networking Add Entries
40-Kubernetes Io Docs Concepts Services Networking Add Entries
40-Kubernetes Io Docs Concepts Services Networking Add Entries
Home
Adding entries to Pod /etc/hosts with
Getting started HostAliases
Concepts
Adding entries to a Pod's /etc/hosts le provides Pod-level override of hostname resolution
Overview
when DNS and other options are not applicable. You can add these custom entries with the
Cluster HostAliases eld in PodSpec.
Architecture
Modi cation not using HostAliases is not suggested because the le is managed by the kubelet
Containers
and can be overwritten on during Pod creation/restart.
Workloads
Services, Load
Balancing, and
Networking
Default hosts le content
Service Start an Nginx Pod which is assigned a Pod IP:
Topology-aware
tra c routing with
topology keys kubectl run nginx --image nginx
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
By default, the hosts le only includes IPv4 and IPv6 boilerplates like localhost and its own
hostname.
Documentation Kubernetes Blog Training Partners Community Case Studies Versions English
service/networking/hostaliases-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: hostaliases-pod
spec:
restartPolicy: Never
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "foo.local"
- "bar.local"
- ip: "10.1.2.3"
hostnames:
- "foo.remote"
- "bar.remote"
containers:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
- name: cat-hosts
image: busybox
command:
- cat
Documentationargs:
Kubernetes Blog Training Partners Community Case Studies Versions English
- "/etc/hosts"
pod/hostaliases-pod created
Examine a Pod's details to see its IPv4 address and its status:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
The hosts le content looks like this:
Caution:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Avoid making manual changes to the hosts le inside a container.
If you make manual changes to the hosts le, those changes are lost when the container
exits.
Documentation Kubernetes Blog Training Partners Community Case Studies Versions English
Feedback
Was this page helpful?
Yes No
Last modi ed June 25, 2020 at 1:37 PM PST: Update kubectl run from docs where necessary
(00f502fa6)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD