Skip to content

Commit

Permalink
fix ip type setting on machine controller
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed Mar 1, 2024
1 parent fc96291 commit d73b110
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 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
5 changes: 0 additions & 5 deletions templates/flavors/rke2/rke2ConfigTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ 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 | awk '{print $2}')" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml
sed -i "/tls-san:/a - $(hostname -I | awk '{print $1}')" /etc/rancher/rke2/config.yaml
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
5 changes: 0 additions & 5 deletions templates/flavors/rke2/rke2ControlPlane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ 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 | awk '{print $2}')" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml
sed -i "/tls-san:/a - $(hostname -I | awk '{print $1}')" /etc/rancher/rke2/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 d73b110

Please sign in to comment.