-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use controller-runtime's cluster instead of manager (#256)
## Summary Hegel originally integrated with Kubernetes by using a tink repo defined client that handled the client construction for a service. The implementation leveraged the controller-runtime manager data structure that comes with a lot more than whats needed by a service. Consequently, it needs to mute features such as metrics endpoints etc. This change switches to the cluster object which is much lighter weight and focus' on representing a cluster (with caching of obects) instead of a fully fledged controller manager. ## Other notes `go mod tidy` cleaned up a bunch of dependencies probably left from the Go v1.20 update. ## Issues Closes #195
- Loading branch information
Showing
7 changed files
with
59 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"github.com/tinkerbell/tink/pkg/apis/core/v1alpha1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// hardwareIPAddrIndex is the index used to retrieve hardware by IP address. It is used with | ||
// the controller-runtimes MatchingFields selector. | ||
const hardwareIPAddrIndex = ".Spec.Interfaces.DHCP.IP" | ||
|
||
// hardwareIPIndexFunc satisfies the controller runtimes index. | ||
func hardwareIPIndexFunc(obj client.Object) []string { | ||
hw, ok := obj.(*v1alpha1.Hardware) | ||
if !ok { | ||
return nil | ||
} | ||
resp := []string{} | ||
for _, iface := range hw.Spec.Interfaces { | ||
if iface.DHCP != nil && iface.DHCP.IP != nil && iface.DHCP.IP.Address != "" { | ||
resp = append(resp, iface.DHCP.IP.Address) | ||
} | ||
} | ||
return resp | ||
} |