Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HowTo: cover Rancher Provisioning IP options #447

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions docs/rancher-ip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
sidebar_label: Rancher IP address options
title: ''
---

<head>
<link rel="canonical" href="https://elemental.docs.rancher.com/rancher-ip"/>
</head>

import Registration from "!!raw-loader!@site/examples/labeltemplates/registration.yaml"

# Configure K3s and RKE2 internal and external IP addresses

K3s and RKE2 allow to specify the internal and external IP addresses of a node via the
`--node-ip` and `--node-external-ip` parameters.

Rancher Provisioning allows to fill those parameters collecting the IP address from each node's network
interface.

Anyway, the methods to collect those ip options for _Custom_ Rancher Clusters and
_Elemental_ Rancher Clusters differ.

## K3s and RKE2 internal and external IP addresses configuration in Rancher Cluster provisioning
Rancher provisioning allows to specify in the Rancher Agent section the network interfaces that should
be bound to the internal and external IP addresses of each provisioned node.

This is performed by adding the network interface names from which the IP addresses should be extracted
in the `CATTLE_INTERNAL_ADDRESS` and the `CATTLE_ADDRESS` Agent Environment Variables
([see Rancher docs](https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/use-existing-nodes/rancher-agent-options#ip-address-options)).

:::note
The `CATTLE_INTERNAL_ADDRESS` and the `CATTLE_ADDRESS` Agent Environment Variables can be directly filled
with the desired IP addresses. Anyway, since the internal and external IP addresses are *per node*,
this would not work but for single node clusters.
:::

:::warning
While during the creation of an Elemental Cluster it is possible to add Agent Environment Variables,
the `CATTLE_ADDRESS` and the `CATTLE_INTERNAL_ADDRESS` ones are ignored and would not result in the
configuration of the internal and external IP addresses of the provisioned nodes.
:::

## Configure K3s and RKE2 internal and external IP addresses in Elemental Clusters
Elemental allows to configure the internal and external IP addresses of the Cluster Nodes attaching
the `elemental.cattle.io/InternalIP` and `elemental.cattle.io/ExternalIP` labels to the
[MachineInventory](machineinventory-reference.md) resources tracking the target nodes.

These labels when attached to a [MachineInventory](machineinventory-reference.md) resource are used
to fill the internal and external IP addresses of the associated nodes.

The labels can be added to the [MachineRegistration](machineregistration-reference.md)
`machineInventoryLabels` fields, using the
[Network Label Template](label-templates-network.md) IP address variables as values, in order
to allow to collect the IP addresses of each node.

Example: [MachineRegistration](machineregistration-reference.md) where nodes will have the internal IP
address set from interface eth0 and the external IP address from eth1.

<CodeBlock language="yaml" title="registration.yaml" showLineNumbers>{Registration}</CodeBlock>
20 changes: 20 additions & 0 deletions examples/labeltemplates/registration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: elemental.cattle.io/v1beta1
kind: MachineRegistration
metadata:
name: fire-nodes
namespace: fleet-default
spec:
config:
cloud-config:
users:
- name: root
passwd: root
elemental:
install:
reboot: true
device: /dev/sda
debug: true
machineInventoryLabels:
element: fire
elemental.cattle.io/InternalIP: ${Network/NICs/eth0/IPv4Address}
elemental.cattle.io/ExternalIP: ${Network/NICs/eth1/IPv4Address}
15 changes: 8 additions & 7 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ const sidebars = {
"collapsed": true,
"label": "How to",
"items": [
"custom-certificate",
"airgap",
"custom-images",
"raspi-disk",
"ntp",
{
"type": "category",
"collapsible": true,
Expand All @@ -152,16 +156,13 @@ const sidebars = {
"lvm-drives-example"
]
},
"elemental_behind_proxy",
"hostname",
"ntp",
"elemental_behind_proxy",
"rancher-vmware",
"removable-device-cloudconfig",
"custom-certificate",
"airgap",
"raspi-disk",
"tpm",
"unmanaged-os"
"rancher-ip",
"unmanaged-os",
"tpm"
]
},
{
Expand Down