Skip to content

Commit

Permalink
feat: update for Talos 1.5.0
Browse files Browse the repository at this point in the history
Bump CAPI, controller-runtime, Talos dependencies, Kubernetes.

Fix some compatibility issues, but should be no functional changes.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Aug 22, 2023
1 parent f711a64 commit baaece8
Show file tree
Hide file tree
Showing 34 changed files with 536 additions and 1,310 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ linters:
- exhaustruct
- nosnakecase
- nonamedreturns
- depguard
# abandoned linters for which golangci shows the warning that the repo is archived by the owner
- interfacer
- maligned
- scopelint
- varcheck
- structcheck
- deadcode
disable-all: false
fast: false

Expand Down
23 changes: 14 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ FROM --platform=arm64 ghcr.io/siderolabs/ipmitool:${PKGS} AS pkg-ipmitool-arm64
FROM ghcr.io/siderolabs/openssl:${PKGS} AS pkg-openssl
FROM --platform=amd64 ghcr.io/siderolabs/openssl:${PKGS} AS pkg-openssl-amd64
FROM --platform=arm64 ghcr.io/siderolabs/openssl:${PKGS} AS pkg-openssl-arm64
FROM --platform=amd64 ghcr.io/siderolabs/linux-firmware:${PKGS} AS pkg-linux-firmware-amd64
FROM --platform=arm64 ghcr.io/siderolabs/linux-firmware:${PKGS} AS pkg-linux-firmware-arm64
FROM ghcr.io/siderolabs/musl:${PKGS} AS pkg-musl
FROM --platform=amd64 ghcr.io/siderolabs/musl:${PKGS} AS pkg-musl-amd64
FROM --platform=arm64 ghcr.io/siderolabs/musl:${PKGS} AS pkg-musl-arm64
Expand All @@ -33,6 +31,9 @@ FROM --platform=arm64 ghcr.io/siderolabs/util-linux:${PKGS} AS pkg-util-linux-ar
FROM --platform=amd64 ghcr.io/siderolabs/kmod:${PKGS} AS pkg-kmod-amd64
FROM --platform=arm64 ghcr.io/siderolabs/kmod:${PKGS} AS pkg-kmod-arm64

# linux-firmware is not arch-specific
FROM --platform=amd64 ghcr.io/siderolabs/linux-firmware:${PKGS} AS pkg-linux-firmware

# The base target provides the base for running various tasks against the source
# code

Expand All @@ -48,10 +49,10 @@ ARG CGO_ENABLED
ENV CGO_ENABLED ${CGO_ENABLED}
ENV GOCACHE /.cache/go-build
ENV GOMODCACHE /.cache/mod
RUN --mount=type=cache,target=/.cache go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3
RUN --mount=type=cache,target=/.cache go install k8s.io/code-generator/cmd/conversion-gen@v0.26.1
RUN --mount=type=cache,target=/.cache go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.0
RUN --mount=type=cache,target=/.cache go install k8s.io/code-generator/cmd/conversion-gen@v0.27.2
RUN --mount=type=cache,target=/.cache go install mvdan.cc/gofumpt/gofumports@v0.1.1
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 \
RUN --mount=type=cache,target=/.cache go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3 \
&& mv /go/bin/golangci-lint /toolchain/bin/golangci-lint
WORKDIR /src
COPY ./go.mod ./
Expand Down Expand Up @@ -189,8 +190,10 @@ COPY --from=pkg-kmod-amd64 / .
COPY --from=pkg-eudev-amd64 / .
COPY --from=pkg-ipmitool-amd64 / .
COPY --from=agent-build-amd64 /agent ./init
COPY --from=pkg-linux-firmware-amd64 /lib/firmware/bnx2 ./lib/firmware/bnx2
COPY --from=pkg-linux-firmware-amd64 /lib/firmware/bnx2x ./lib/firmware/bnx2x
COPY --from=pkg-linux-firmware /lib/firmware/bnx2 ./lib/firmware/bnx2
COPY --from=pkg-linux-firmware /lib/firmware/bnx2x ./lib/firmware/bnx2x
COPY --from=pkg-linux-firmware /lib/firmware/intel/ice/ddp/ice-*.pkg ./lib/firmware/intel/ice/ddp/ice.pkg
COPY --from=pkg-linux-firmware /lib/firmware/rtl_nic ./lib/firmware/rtl_nic
COPY --from=pkg-kernel-amd64 /lib/modules ./lib/modules
RUN set -o pipefail && find . 2>/dev/null | cpio -H newc -o | xz -v -C crc32 -0 -e -T 0 -z >/initramfs.xz

Expand All @@ -204,8 +207,10 @@ COPY --from=pkg-kmod-arm64 / .
COPY --from=pkg-eudev-arm64 / .
COPY --from=pkg-ipmitool-arm64 / .
COPY --from=agent-build-arm64 /agent ./init
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/bnx2 ./lib/firmware/bnx2
COPY --from=pkg-linux-firmware-arm64 /lib/firmware/bnx2x ./lib/firmware/bnx2x
COPY --from=pkg-linux-firmware /lib/firmware/bnx2 ./lib/firmware/bnx2
COPY --from=pkg-linux-firmware /lib/firmware/bnx2x ./lib/firmware/bnx2x
COPY --from=pkg-linux-firmware /lib/firmware/intel/ice/ddp/ice-*.pkg ./lib/firmware/intel/ice/ddp/ice.pkg
COPY --from=pkg-linux-firmware /lib/firmware/rtl_nic ./lib/firmware/rtl_nic
COPY --from=pkg-kernel-arm64 /lib/modules ./lib/modules
RUN set -o pipefail && find . 2>/dev/null | cpio -H newc -o | xz -v -C crc32 -0 -e -T 0 -z >/initramfs.xz

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ MODULE := $(shell head -1 go.mod | cut -d' ' -f2)

ARTIFACTS := _out
TEST_PKGS ?= ./...
TALOS_RELEASE ?= v1.4.0
DEFAULT_K8S_VERSION ?= v1.26.0
TALOS_RELEASE ?= v1.5.0
DEFAULT_K8S_VERSION ?= v1.27.2

TOOLS ?= ghcr.io/siderolabs/tools:v1.4.0-1-g955aabc
PKGS ?= v1.5.0-alpha.0-3-g174f8fc
TOOLS ?= ghcr.io/siderolabs/tools:v1.5.0
PKGS ?= v1.5.0

SFYRA_CLUSTERCTL_CONFIG ?= $(HOME)/.cluster-api/clusterctl.sfyra.yaml

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ This provider's versions are compatible with the following versions of Cluster A

This provider's versions are able to install and manage the following versions of Kubernetes:

| | v1.19 | v1.20 | v1.21 | v1.22 | v1.23 | v1.24 | v1.25 | v1.26 | v1.27 |
| ---------------------- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- |
| Sidero Provider (v0.5) ||||||||||
| Sidero Provider (v0.6) | | | | | |||||
| | v1.19 | v1.20 | v1.21 | v1.22 | v1.23 | v1.24 | v1.25 | v1.26 | v1.27 | v1.28 |
| ---------------------- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- |
| Sidero Provider (v0.5) |||||||||| |
| Sidero Provider (v0.6) | | | | | ||||||

This provider's versions are compatible with the following versions of Talos:

| | v0.12 | v0.13 | v0.14 | v1.0 | v1.1 | v1.2 | v1.3 | v1.4 |
| ---------------------- | ------ | ----- | ----- | ----- | ----- | ----- | ----- | ----- |
| Sidero Provider (v0.5) | ✓ (+) | ✓ (+) |||||| |
| Sidero Provider (v0.6) | | | ||||||
| | v0.12 | v0.13 | v0.14 | v1.0 | v1.1 | v1.2 | v1.3 | v1.4 | v1.5 |
| ---------------------- | ------ | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- |
| Sidero Provider (v0.5) | ✓ (+) | ✓ (+) |||||| | |
| Sidero Provider (v0.6) | | | |||||||

> (+): Some Sidero 0.5 features (SideroLink) are only available with Talos v0.14+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func (r *MetalMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
Expand All @@ -23,22 +24,22 @@ func (r *MetalMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &MetalMachineTemplate{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (r *MetalMachineTemplate) ValidateCreate() error {
return nil
func (r *MetalMachineTemplate) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (r *MetalMachineTemplate) ValidateUpdate(oldRaw runtime.Object) error {
func (r *MetalMachineTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
old := oldRaw.(*MetalMachineTemplate)

if !cmp.Equal(r.Spec, old.Spec) {
return apierrors.NewBadRequest("MetalMachineTemplate.Spec is immutable")
return nil, apierrors.NewBadRequest("MetalMachineTemplate.Spec is immutable")
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (r *MetalMachineTemplate) ValidateDelete() error {
return nil
func (r *MetalMachineTemplate) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: metalclusters.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: metalmachines.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: metalmachinetemplates.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: serverbindings.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
1 change: 0 additions & 1 deletion app/caps-controller-manager/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
1 change: 0 additions & 1 deletion app/caps-controller-manager/config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

infrav1 "github.com/siderolabs/sidero/app/caps-controller-manager/api/v1alpha3"
"github.com/siderolabs/sidero/app/caps-controller-manager/pkg/constants"
Expand Down Expand Up @@ -278,10 +277,10 @@ func (r *MetalMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
return err
}

mapRequests := func(a client.Object) []reconcile.Request {
mapRequests := func(ctx context.Context, a client.Object) []reconcile.Request {
serverBinding := &infrav1.ServerBinding{}

if err := r.Get(context.Background(), types.NamespacedName{Namespace: a.GetNamespace(), Name: a.GetName()}, serverBinding); err != nil {
if err := r.Get(ctx, types.NamespacedName{Namespace: a.GetNamespace(), Name: a.GetName()}, serverBinding); err != nil {
return nil
}

Expand All @@ -299,7 +298,7 @@ func (r *MetalMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
WithOptions(options).
For(&infrav1.MetalMachine{}).
Watches(
&source.Kind{Type: &infrav1.ServerBinding{}},
&infrav1.ServerBinding{},
handler.EnqueueRequestsFromMapFunc(mapRequests),
).
Complete(r)
Expand Down
2 changes: 1 addition & 1 deletion app/caps-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func main() {
// Set up a ClusterCacheTracker to provide to controllers
// requiring a connection to a remote cluster
tracker, err := remote.NewClusterCacheTracker(mgr, remote.ClusterCacheTrackerOptions{
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
ClientUncachedObjects: []client.Object{},
})
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions app/sidero-controller-manager/api/v1alpha1/server_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

siderotypes "github.com/siderolabs/sidero/app/sidero-controller-manager/pkg/types"
)
Expand All @@ -40,18 +41,18 @@ func (r *Server) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &Server{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (r *Server) ValidateCreate() error {
return r.validate()
func (r *Server) ValidateCreate() (admission.Warnings, error) {
return nil, r.validate()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (r *Server) ValidateUpdate(old runtime.Object) error {
return r.validate()
func (r *Server) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
return nil, r.validate()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (r *Server) ValidateDelete() error {
return nil
func (r *Server) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

func (r *Server) validate() error {
Expand Down
13 changes: 7 additions & 6 deletions app/sidero-controller-manager/api/v1alpha2/server_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

siderotypes "github.com/siderolabs/sidero/app/sidero-controller-manager/pkg/types"
)
Expand Down Expand Up @@ -46,18 +47,18 @@ func (r *Server) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &Server{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (r *Server) ValidateCreate() error {
return r.validate()
func (r *Server) ValidateCreate() (admission.Warnings, error) {
return nil, r.validate()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (r *Server) ValidateUpdate(old runtime.Object) error {
return r.validate()
func (r *Server) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
return nil, r.validate()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (r *Server) ValidateDelete() error {
return nil
func (r *Server) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

func (r *Server) validate() error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: environments.metal.sidero.dev
spec:
group: metal.sidero.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: serverclasses.metal.sidero.dev
spec:
group: metal.sidero.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: servers.metal.sidero.dev
spec:
group: metal.sidero.dev
Expand Down
1 change: 0 additions & 1 deletion app/sidero-controller-manager/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

infrav1 "github.com/siderolabs/sidero/app/caps-controller-manager/api/v1alpha3"
metalv1 "github.com/siderolabs/sidero/app/sidero-controller-manager/api/v1alpha2"
Expand Down Expand Up @@ -326,7 +325,7 @@ func (r *ServerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manage
return err
}

mapRequests := func(a client.Object) []reconcile.Request {
mapRequests := func(_ context.Context, a client.Object) []reconcile.Request {
// servers and serverbindings always have matching names
return []reconcile.Request{
{
Expand All @@ -342,7 +341,7 @@ func (r *ServerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manage
WithOptions(options).
For(&metalv1.Server{}).
Watches(
&source.Kind{Type: &infrav1.ServerBinding{}},
&infrav1.ServerBinding{},
handler.EnqueueRequestsFromMapFunc(mapRequests),
).
Complete(r)
Expand Down
Loading

0 comments on commit baaece8

Please sign in to comment.