Skip to content

Commit 34f93dd

Browse files
committed
kubeadm: add notes about network setup to the "create cluster" doc
This is a top 3 question on support forums. "How to pass custom IP to kubeadm?" At one point there was a blog post on how to do this step-by-step, but we rejected that blog due to too many mistakes and not being a recommended practices, generally. In this PR, we add some detail on how to do it and tag the non-default-route-IP way as not-recommended with a warning. It is not considered as a foot gun for users, per se, but the setup is just awkward, prone to mistakes and not easy to maintain. If k8s supported something like a global /etc/kubernetes/DEFAULT_IP config of sorts, it would have seemed much more manageable.
1 parent de5baa1 commit 34f93dd

File tree

1 file changed

+57
-5
lines changed

1 file changed

+57
-5
lines changed

content/en/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm.md

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Any commands under `kubeadm alpha` are, by definition, supported on an alpha lev
7272

7373
### Preparing the hosts
7474

75+
#### Component installation
76+
7577
Install a {{< glossary_tooltip term_id="container-runtime" text="container runtime" >}} and kubeadm on all the hosts.
7678
For detailed instructions and other prerequisites, see [Installing kubeadm](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/).
7779

@@ -84,6 +86,61 @@ kubeadm to tell it what to do. This crashloop is expected and normal.
8486
After you initialize your control-plane, the kubelet runs normally.
8587
{{< /note >}}
8688

89+
#### Network setup
90+
91+
kubeadm similarly to other Kubernetes components tries to find a usable IP on
92+
the network interface associated with the default gateway on a host. Such
93+
an IP is then used for the advertising and/or listening performed by a component.
94+
95+
To find out what this IP is on a Linux host you can use:
96+
97+
```shell
98+
ip route show # Look for a line starting with "default via"
99+
```
100+
101+
Kubernetes components do not accept custom network interface as an option,
102+
therefore a custom IP address must be passed as a flag to all components instances
103+
that need such a custom configuration.
104+
105+
To configure the API server advertise address for control plane nodes created with both
106+
`init` and `join`, the flag `--apiserver-advertise-address` can be used.
107+
Preferably, this option can be set in the [kubeadm API](/docs/reference/config-api/kubeadm-config.v1beta3)
108+
as `InitConfiguration.localAPIEndpoint` and `JoinConfiguration.controlPlane.localAPIEndpoint`.
109+
110+
For kubelets on all nodes, the `--node-ip` option can be passed in
111+
`.nodeRegistration.kubeletExtraArgs` inside a kubeadm configuration file
112+
(`InitConfiguration` or `JoinConfiguration`).
113+
114+
For dual-stack see
115+
[Dual-stack support with kubeadm](/docs/setup/production-environment/tools/kubeadm/dual-stack-support).
116+
117+
{{< note >}}
118+
IP addresses become part of certificates SAN fields. Changing these IP addresses would require
119+
signing new certificates and restarting the affected components, so that the change in
120+
certificate files is reflected. See
121+
[Manual certificate renewal](/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/#manual-certificate-renewal)
122+
for more details on this topic.
123+
{{</ note >}}
124+
125+
{{< warning >}}
126+
The Kubernetes project recommends against this approach (configuring all component instances
127+
with custom IP addresses). Instead, the Kubernetes maintainers recommend to setup the host network,
128+
so that the default gateway IP is the one that Kubernetes components auto-detect and use.
129+
On Linux nodes, you can use commands such as `ip route` to configure networking; your operating
130+
system might also provide higher level network management tools. If your node's default gateway
131+
is a public IP address, you should configure packet filtering or other security measures that
132+
protect the nodes and your cluster.
133+
{{< /warning >}}
134+
135+
{{< note >}}
136+
If the host does not have a default gateway, it is recommended to setup one. Otherwise,
137+
without passing a custom IP address to a Kubernetes component, the component
138+
will exit with an error. If two or more default gateways are present on the host,
139+
a Kubernetes component will try to use the first one it encounters that has a suitable
140+
global unicast IP address. While making this choice, the exact ordering of gateways
141+
might vary between different operating systems and kernel versions.
142+
{{< /note >}}
143+
87144
### Preparing the required container images
88145

89146
This step is optional and only applies in case you wish `kubeadm init` and `kubeadm join`
@@ -117,11 +174,6 @@ a provider-specific value. See [Installing a Pod network add-on](#pod-network).
117174
known endpoints. To use different container runtime or if there are more than one installed
118175
on the provisioned node, specify the `--cri-socket` argument to `kubeadm`. See
119176
[Installing a runtime](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-runtime).
120-
1. (Optional) Unless otherwise specified, `kubeadm` uses the network interface associated
121-
with the default gateway to set the advertise address for this particular control-plane node's API server.
122-
To use a different network interface, specify the `--apiserver-advertise-address=<ip-address>` argument
123-
to `kubeadm init`. To deploy an IPv6 Kubernetes cluster using IPv6 addressing, you
124-
must specify an IPv6 address, for example `--apiserver-advertise-address=2001:db8::101`
125177

126178
To initialize the control-plane node run:
127179

0 commit comments

Comments
 (0)