Setting up a static IP on a Kubernetes node with Talos Linux

This article details the procedure for configuring a static IP address for Talos Kubernetes nodes.

Tip
You can do this before installing Talos, or if you have already installed it, do it with talosctl edit machineconfig.

This has to be done on each node you wish to have a static IP on. Change the values from the example with your own, keeping in mind that two nodes cannot have the same IP. In this example, we will use the eth0 network interface as it is the most common. If you have another interface, you need to place that one here. The example also includes the additional hosts entries, as it is a good practice for the nodes to know each other by hostname. Here is the configuration (click to expand):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
machine:
  network:
    hostname: example-main-0
    interfaces:
      - interface: eth0 # The interface name.
        addresses:
          - 192.168.0.241/24
        routes:
          - network: 0.0.0.0/0 # The route's network.
            gateway: 192.168.0.1 # The route's gateway.
        dhcp: true

    nameservers:
      - 192.168.0.1
      - 8.8.4.4
      - 8.8.8.8
      - 1.1.1.1

    extraHostEntries:
      - ip: 192.168.0.241
        aliases:
          - example-main-0
      - ip: 192.168.0.242
        aliases:
          - example-agent-0
      - ip: 192.168.0.243
        aliases:
          - example-agent-1