Skip to content

Commit 80854f8

Browse files
authored
✨ Allow spoke kubeconfig edits (#40)
* feat: allow spoke kubeconfig edits * fix: ensure webhook svc endpoints in debug mode * chore: clarify kubeconfig key error message --------- Signed-off-by: Tyler Gillson <[email protected]>
1 parent 64f5607 commit 80854f8

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

fleetconfig-controller/api/v1alpha1/validation.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ import (
2323
// - spec.addOnConfig
2424
// - spec.registrationAuth.*
2525
// - spec.hub.clusterManager.source.*
26+
// - spec.spokes[*].addOns
2627
// - spec.spokes[*].klusterlet.annotations
2728
// - spec.spokes[*].klusterlet.source.*
2829
// - spec.spokes[*].klusterlet.values
29-
// - spec.spokes[*].addOns
30+
// - spec.spokes[*].kubeconfig
3031
func allowFleetConfigUpdate(newObject *FleetConfig, oldObject *FleetConfig) error {
3132

3233
// Hub check
@@ -65,6 +66,8 @@ func allowFleetConfigUpdate(newObject *FleetConfig, oldObject *FleetConfig) erro
6566
newSpokeCopy.Klusterlet.Source = (OCMSource{})
6667
oldSpokeCopy.Klusterlet.Values = nil
6768
newSpokeCopy.Klusterlet.Values = nil
69+
oldSpokeCopy.Kubeconfig = Kubeconfig{}
70+
newSpokeCopy.Kubeconfig = Kubeconfig{}
6871
newSpokeCopy.AddOns = []AddOn{}
6972
oldSpokeCopy.AddOns = []AddOn{}
7073

fleetconfig-controller/config/devspace/manager.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ spec:
66
replicas: 1
77
selector:
88
matchLabels:
9-
app.kubernetes.io/instance: fleetconfig-controller-local
9+
app.kubernetes.io/instance: fleetconfig-controller
1010
app.kubernetes.io/name: fleetconfig-controller
1111
template:
1212
metadata:
1313
labels:
14-
app.kubernetes.io/instance: fleetconfig-controller-local
14+
app.kubernetes.io/instance: fleetconfig-controller
1515
app.kubernetes.io/name: fleetconfig-controller
1616
spec:
1717
serviceAccountName: fleetconfig-controller-manager

fleetconfig-controller/internal/controller/spoke.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"os/exec"
9-
"reflect"
109
"regexp"
1110
"slices"
1211
"strings"
@@ -55,13 +54,14 @@ func handleSpokes(ctx context.Context, kClient client.Client, fc *v1alpha1.Fleet
5554
joinedSpokes := make([]v1alpha1.JoinedSpoke, 0)
5655
for _, js := range fc.Status.JoinedSpokes {
5756
if !slices.ContainsFunc(fc.Spec.Spokes, func(spoke v1alpha1.Spoke) bool {
58-
return spoke.Name == js.Name && reflect.DeepEqual(spoke.Kubeconfig, js.Kubeconfig)
57+
return spoke.Name == js.Name
5958
}) {
6059
err = deregisterSpoke(ctx, kClient, hubKubeconfig, fc, &js)
6160
if err != nil {
6261
fc.SetConditions(true, v1alpha1.NewCondition(
6362
err.Error(), js.UnjoinType(), metav1.ConditionFalse, metav1.ConditionTrue,
6463
))
64+
// if deregistration fails, retain the joined spoke in the status
6565
joinedSpokes = append(joinedSpokes, js)
6666
continue
6767
}

fleetconfig-controller/internal/kube/kube.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func KubeconfigFromSecret(ctx context.Context, kClient client.Client, kubeconfig
110110
}
111111
raw, ok := secret.Data[kubeconfigKey]
112112
if !ok {
113-
return nil, fmt.Errorf("failed to get kubeconfig for ref %s/%s using key %s", secretRef.Namespace, secretRef.Name, kubeconfigKey)
113+
return nil, fmt.Errorf("kubeconfig key '%s' not found in %s/%s secret", kubeconfigKey, secretRef.Namespace, secretRef.Name)
114114
}
115115

116116
return raw, nil

0 commit comments

Comments
 (0)