Skip to content

Commit

Permalink
[fix] [rke2] - set node-ip, use internal-only-ips for rke2 registrati…
Browse files Browse the repository at this point in the history
…on, set the ip type properly for the machine addresses (#156)

* add workaround to get both container logs working and server join working without controlPlaneEndpoint registration support on rke2

* fix ip type setting for addresses on machine controller
  • Loading branch information
AshleyDumaine authored Mar 4, 2024
1 parent aeaa747 commit b0ba979
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,14 @@ func (r *LinodeMachineReconciler) reconcileCreate(
machineScope.LinodeMachine.Spec.ProviderID = util.Pointer(fmt.Sprintf("linode://%d", linodeInstance.ID))

machineScope.LinodeMachine.Status.Addresses = []clusterv1.MachineAddress{}
for _, add := range linodeInstance.IPv4 {
for _, addr := range linodeInstance.IPv4 {
addrType := clusterv1.MachineExternalIP
if addr.IsPrivate() {
addrType = clusterv1.MachineInternalIP
}
machineScope.LinodeMachine.Status.Addresses = append(machineScope.LinodeMachine.Status.Addresses, clusterv1.MachineAddress{
Type: clusterv1.MachineExternalIP,
Address: add.String(),
Type: addrType,
Address: addr.String(),
})
}

Expand Down
4 changes: 4 additions & 0 deletions templates/flavors/rke2/rke2ConfigTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ spec:
kubelet:
extraArgs:
- "provider-id=linode://{{ ds.meta_data.id }}"
# TODO: use MDS to get public and private IP instead because hostname ordering can't always be assumed
preRKE2Commands:
- |
mkdir -p /etc/rancher/rke2/config.yaml.d/
echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
4 changes: 4 additions & 0 deletions templates/flavors/rke2/rke2ControlPlane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
name: linode-${CLUSTER_NAME}-crs-0
owner: root:root
path: /var/lib/rancher/rke2/server/manifests/linode-token-region.yaml
registrationMethod: internal-only-ips
serverConfig:
cni: cilium
cloudProviderName: external
Expand All @@ -36,6 +37,9 @@ spec:
extraArgs:
- "provider-id=linode://{{ ds.meta_data.id }}"
preRKE2Commands:
- |
mkdir -p /etc/rancher/rke2/config.yaml.d/
echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
Expand Down

0 comments on commit b0ba979

Please sign in to comment.