---
slug: "kubernetes-manifetst-host-alias"
title: "Writing Host Aliases in Kubernetes Manifests"
description: "Bottle's SimpleTemplate basics, plus how to switch to Jinja2 / Mako templates inside Python's bottle framework."
url: "https://www.ytyng.com/en/blog/kubernetes-manifetst-host-alias"
publish_date: "2022-04-22T13:24:42Z"
created: "2022-04-22T13:24:42Z"
updated: "2026-05-11T13:21:44.118Z"
categories: ["kubernetes"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/3c7b8ede30a14db4871eb1324e29e73e.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Writing Host Aliases in Kubernetes Manifests

I often forget this, so here's a note.

[https://kubernetes.io/ja/docs/tasks/network/customize-hosts-file-for-pods/](https://kubernetes.io/ja/docs/tasks/network/customize-hosts-file-for-pods/)

```yaml
apiVersion: apps/v1
kind: Deployment
  spec:
  ...
  template:
    ...
    spec:
      hostAliases:
        - hostnames:
            - target-host.example.com
          ip: 192.168.0.XX
```

How to check

```
$ cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
172.31.XX.XX    podname-aaaabbbb

# Entries added by HostAliases.
192.168.0.XX   target-host.example.com
```
