Skip to content

Commit

Permalink
Fixing bugs with namespaced clusters (#111)
Browse files Browse the repository at this point in the history
Fixes a few bugs with namespaced clusters, specifically:
- The agent config still used a hardcoded value for the config secret
  mount
- The kubeconfig generation still used the old "cluster namespace" as
  the destination
In addition, changes the headless service name to not have two "-".
  • Loading branch information
MbolotSuse authored Sep 5, 2024
1 parent 9faab4f commit 56da259
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/cluster/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (a *Agent) podSpec(image, name string, args []string, statefulSet bool, aff
Name: "config",
VolumeSource: v1.VolumeSource{
Secret: &v1.SecretVolumeSource{
SecretName: name + "-config",
SecretName: util.AgentConfigName(a.cluster),
Items: []v1.KeyToPath{
{
Key: "config.yaml",
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/cluster/server/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1"
"github.com/rancher/k3k/pkg/controller/util"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/retry"
Expand Down Expand Up @@ -60,7 +61,7 @@ func Generate(ctx context.Context, cluster *v1alpha1.Cluster, ip string) (*v1.Se
},
ObjectMeta: metav1.ObjectMeta{
Name: cluster.Name + "-bootstrap",
Namespace: "k3k-" + cluster.Name,
Namespace: util.ClusterNamespace(cluster),
},
Data: map[string][]byte{
"bootstrap": bootstrapData,
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/cluster/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *Server) StatefulServerService(cluster *v1alpha1.Cluster) *v1.Service {
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: cluster.Name + "-" + name + "-headless",
Name: cluster.Name + "-" + name + "headless",
Namespace: util.ClusterNamespace(cluster),
},
Spec: v1.ServiceSpec{
Expand Down

0 comments on commit 56da259

Please sign in to comment.