Skip to content

Commit f1c73fc

Browse files
authored
Merge pull request #1295 from apedriza/fix-machine-address-propagation
Fix machine address status propagation
2 parents 4e5b5b7 + 3d44d3d commit f1c73fc

File tree

6 files changed

+111
-5
lines changed

6 files changed

+111
-5
lines changed

api/infrastructure/v1beta1/remote_machine_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1beta1
1919
import (
2020
v1 "k8s.io/api/batch/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2223
)
2324

2425
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
@@ -113,6 +114,10 @@ type RemoteMachineStatus struct {
113114
// +kubebuilder:validation:Optional
114115
Ready bool `json:"ready,omitempty"`
115116

117+
// addresses contains the associated addresses for the machine.
118+
// +optional
119+
Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"`
120+
116121
FailureReason string `json:"failureReason,omitempty"`
117122
FailureMessage string `json:"failureMessage,omitempty"`
118123
}

api/infrastructure/v1beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/clusterapi/infrastructure/bases/infrastructure.cluster.x-k8s.io_remotemachines.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8815,6 +8815,32 @@ spec:
88158815
status:
88168816
description: RemoteMachineStatus defines the observed state of RemoteMachine
88178817
properties:
8818+
addresses:
8819+
description: addresses contains the associated addresses for the machine.
8820+
items:
8821+
description: MachineAddress contains information for the node's
8822+
address.
8823+
properties:
8824+
address:
8825+
description: address is the machine address.
8826+
maxLength: 256
8827+
minLength: 1
8828+
type: string
8829+
type:
8830+
description: type is the machine address type, one of Hostname,
8831+
ExternalIP, InternalIP, ExternalDNS or InternalDNS.
8832+
enum:
8833+
- Hostname
8834+
- ExternalIP
8835+
- InternalIP
8836+
- ExternalDNS
8837+
- InternalDNS
8838+
type: string
8839+
required:
8840+
- address
8841+
- type
8842+
type: object
8843+
type: array
88188844
failureMessage:
88198845
type: string
88208846
failureReason:

config/crd/bases/infrastructure/infrastructure.cluster.x-k8s.io_remotemachines.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8815,6 +8815,32 @@ spec:
88158815
status:
88168816
description: RemoteMachineStatus defines the observed state of RemoteMachine
88178817
properties:
8818+
addresses:
8819+
description: addresses contains the associated addresses for the machine.
8820+
items:
8821+
description: MachineAddress contains information for the node's
8822+
address.
8823+
properties:
8824+
address:
8825+
description: address is the machine address.
8826+
maxLength: 256
8827+
minLength: 1
8828+
type: string
8829+
type:
8830+
description: type is the machine address type, one of Hostname,
8831+
ExternalIP, InternalIP, ExternalDNS or InternalDNS.
8832+
enum:
8833+
- Hostname
8834+
- ExternalIP
8835+
- InternalIP
8836+
- ExternalDNS
8837+
- InternalDNS
8838+
type: string
8839+
required:
8840+
- address
8841+
- type
8842+
type: object
8843+
type: array
88188844
failureMessage:
88198845
type: string
88208846
failureReason:

docs/resource-reference/infrastructure.cluster.x-k8s.io-v1beta1.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17419,6 +17419,13 @@ RemoteMachineStatus defines the observed state of RemoteMachine
1741917419
</tr>
1742017420
</thead>
1742117421
<tbody><tr>
17422+
<td><b><a href="#remotemachinestatusaddressesindex">addresses</a></b></td>
17423+
<td>[]object</td>
17424+
<td>
17425+
addresses contains the associated addresses for the machine.<br/>
17426+
</td>
17427+
<td>false</td>
17428+
</tr><tr>
1742217429
<td><b>failureMessage</b></td>
1742317430
<td>string</td>
1742417431
<td>
@@ -17442,6 +17449,42 @@ RemoteMachineStatus defines the observed state of RemoteMachine
1744217449
</tr></tbody>
1744317450
</table>
1744417451

17452+
17453+
### RemoteMachine.status.addresses[index]
17454+
<sup><sup>[↩ Parent](#remotemachinestatus)</sup></sup>
17455+
17456+
17457+
17458+
MachineAddress contains information for the node's address.
17459+
17460+
<table>
17461+
<thead>
17462+
<tr>
17463+
<th>Name</th>
17464+
<th>Type</th>
17465+
<th>Description</th>
17466+
<th>Required</th>
17467+
</tr>
17468+
</thead>
17469+
<tbody><tr>
17470+
<td><b>address</b></td>
17471+
<td>string</td>
17472+
<td>
17473+
address is the machine address.<br/>
17474+
</td>
17475+
<td>true</td>
17476+
</tr><tr>
17477+
<td><b>type</b></td>
17478+
<td>enum</td>
17479+
<td>
17480+
type is the machine address type, one of Hostname, ExternalIP, InternalIP, ExternalDNS or InternalDNS.<br/>
17481+
<br/>
17482+
<i>Enum</i>: Hostname, ExternalIP, InternalIP, ExternalDNS, InternalDNS<br/>
17483+
</td>
17484+
<td>true</td>
17485+
</tr></tbody>
17486+
</table>
17487+
1744517488
## RemoteMachineTemplate
1744617489
<sup><sup>[↩ Parent](#infrastructureclusterx-k8siov1beta1 )</sup></sup>
1744717490

internal/controller/infrastructure/remote_machine_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
"k8s.io/apimachinery/pkg/runtime"
2626
"k8s.io/client-go/kubernetes"
2727
"k8s.io/client-go/rest"
28+
"k8s.io/client-go/util/retry"
2829

2930
infrastructure "github.com/k0sproject/k0smotron/api/infrastructure/v1beta1"
3031
"github.com/k0sproject/k0smotron/internal/provisioner"
3132
apierrors "k8s.io/apimachinery/pkg/api/errors"
32-
"k8s.io/client-go/util/retry"
3333
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3434
capiutil "sigs.k8s.io/cluster-api/util"
3535
"sigs.k8s.io/cluster-api/util/annotations"
@@ -274,14 +274,14 @@ func (r *RemoteMachineController) Reconcile(ctx context.Context, req ctrl.Reques
274274
}
275275

276276
rm.Spec.ProviderID = fmt.Sprintf("remote-machine://%s:%d", rm.Spec.Address, rm.Spec.Port)
277-
278-
m := machine.DeepCopy()
279-
m.Status.Addresses = []clusterv1.MachineAddress{
277+
rm.Status.Addresses = []clusterv1.MachineAddress{
280278
{
281279
Type: clusterv1.MachineExternalIP,
282280
Address: rm.Spec.Address,
283281
},
284282
}
283+
284+
m := machine.DeepCopy()
285285
for l := range rm.Labels {
286286
if _, ok := m.Labels[l]; !ok {
287287
m.Labels[l] = rm.Labels[l]

0 commit comments

Comments
 (0)