Fixing bugs with namespaced clusters (#111)

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 "-".
This commit is contained in:
Michael Bolot
2024-09-05 18:15:36 -05:00
committed by GitHub
parent 9faab4f82d
commit 56da25941f
3 changed files with 4 additions and 3 deletions

View File

@@ -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",

View File

@@ -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"
@@ -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,

View File

@@ -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{