Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/butlerdotdev/butler-controller
go 1.24.6

require (
github.com/butlerdotdev/butler-api v0.23.0
github.com/butlerdotdev/butler-api v0.24.0
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.36.1
github.com/prometheus/client_golang v1.22.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/butlerdotdev/butler-api v0.23.0 h1:t6NSgZLg5e7t/xE18yfw1sOrAp3vCfQncYsgbLVCzGQ=
github.com/butlerdotdev/butler-api v0.23.0/go.mod h1:q/RjPFM/r2ELq4DqR78OiAxerKBvH5D4nTGsVLKbjqY=
github.com/butlerdotdev/butler-api v0.24.0 h1:37ogSev37Wt4sNcbT1N0QqQ+w0im49+8ONvNMy52hdQ=
github.com/butlerdotdev/butler-api v0.24.0/go.mod h1:q/RjPFM/r2ELq4DqR78OiAxerKBvH5D4nTGsVLKbjqY=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down
14 changes: 14 additions & 0 deletions internal/capi/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,17 @@ func (b *Builder) buildStewardControlPlane(name string) *unstructured.Unstructur
if resources.Scheduler != nil {
spec["scheduler"] = b.componentResourceMap(resources.Scheduler)
}
if resources.Konnectivity != nil {
// Konnectivity is a Steward addon, not a top-level control plane
// component, so its resources go into the addons block. capi-steward
// copies addons onto the TenantControlPlane, which renders them onto
// the konnectivity-server container (addons.konnectivity.server.resources).
addons["konnectivity"] = map[string]interface{}{
"server": map[string]interface{}{
"resources": b.componentResourceMap(resources.Konnectivity),
},
}
}
}

// Add certSANs if specified
Expand Down Expand Up @@ -1196,6 +1207,9 @@ func ResolveControlPlaneResources(tc *butlerv1alpha1.TenantCluster, butlerConfig
if tcResources.Scheduler != nil {
merged.Scheduler = tcResources.Scheduler
}
if tcResources.Konnectivity != nil {
merged.Konnectivity = tcResources.Konnectivity
}
return merged
}

Expand Down
66 changes: 66 additions & 0 deletions internal/capi/builder_konnectivity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2026 The Butler Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package capi

import (
"encoding/json"
"strings"
"testing"

butlerv1alpha1 "github.com/butlerdotdev/butler-api/api/v1alpha1"
"k8s.io/apimachinery/pkg/api/resource"
)

// TestBuildStewardControlPlane_Konnectivity verifies konnectivity resources
// (a Steward addon, not a top-level control plane component) are written into
// the StewardControlPlane addons block only when set, so capi-steward can carry
// them to the TenantControlPlane's konnectivity-server.
func TestBuildStewardControlPlane_Konnectivity(t *testing.T) {
pc := newTestProviderConfig("harvester")
qty := func(s string) *resource.Quantity { q := resource.MustParse(s); return &q }

addonsFor := func(t *testing.T, k *butlerv1alpha1.ComponentResources) map[string]interface{} {
t.Helper()
tc := newTestTenantCluster("cp-konn", "default")
tc.Spec.ControlPlane.Resources = &butlerv1alpha1.ControlPlaneResourcesSpec{Konnectivity: k}
rs, err := NewBuilder(tc, pc, "cp-konn-12345678").Build()
if err != nil {
t.Fatalf("build: %v", err)
}
spec := rs.ControlPlane.Object["spec"].(map[string]interface{})
return spec["addons"].(map[string]interface{})
}

t.Run("omitted keeps konnectivity addon empty", func(t *testing.T) {
konn, _ := addonsFor(t, nil)["konnectivity"].(map[string]interface{})
if len(konn) != 0 {
t.Fatalf("konnectivity addon should be empty when unset, got %v", konn)
}
})

t.Run("explicit maps to addons.konnectivity.server.resources", func(t *testing.T) {
addons := addonsFor(t, &butlerv1alpha1.ComponentResources{
Requests: &butlerv1alpha1.ResourceQuantities{CPU: qty("10m"), Memory: qty("32Mi")},
})
b, _ := json.Marshal(addons["konnectivity"])
s := string(b)
if !strings.Contains(s, `"server"`) || !strings.Contains(s, `"resources"`) ||
!strings.Contains(s, "32Mi") || !strings.Contains(s, "10m") {
t.Fatalf("konnectivity resources not mapped into addons: %s", s)
}
})
}
Loading