Skip to content

Commit

Permalink
clustermesh: make status command compatible with external kvstore
Browse files Browse the repository at this point in the history
The clustermesh-apiserver cannot be used in combination with Cilium
running in kvstore mode when the identity allocation mode is kvstore.
In this case, remote clusters shall be configured to directly connect
to the local etcd cluster. Let's extend the `clustermesh status`
command to additionally cover this setup, ignoring the validation of
clustermesh-apiserver specific resources.

Signed-off-by: Marco Iorio <[email protected]>
  • Loading branch information
giorio94 authored and tklauser committed Jan 9, 2024
1 parent 1f5fc51 commit 5f2a3dd
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions clustermesh/clustermesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const (
configNameRoutingMode = "routing-mode"
configNameMaxConnectedClusters = "max-connected-clusters"

configNameIdentityAllocationMode = "identity-allocation-mode"

caSuffix = ".etcd-client-ca.crt"
keySuffix = ".etcd-client.key"
certSuffix = ".etcd-client.crt"
Expand Down Expand Up @@ -465,6 +467,7 @@ type K8sClusterMesh struct {
clusterID string
imageVersion string
clusterArch string
externalKVStore bool
}

type Parameters struct {
Expand Down Expand Up @@ -535,6 +538,8 @@ func (k *K8sClusterMesh) GetClusterConfig(ctx context.Context) error {
return fmt.Errorf("unable to retrieve ConfigMap %q: %w", defaults.ConfigMapName, err)
}

k.externalKVStore = cm.Data[configNameIdentityAllocationMode] != "crd"

clusterID := cm.Data[configNameClusterID]
if clusterID == "" {
clusterID = "0"
Expand Down Expand Up @@ -1461,22 +1466,27 @@ func (k *K8sClusterMesh) Status(ctx context.Context) (*Status, error) {
defer cancel()

s := &Status{}
s.AccessInformation, err = k.statusAccessInformation(ctx, true, false)
if err != nil {
return nil, err
}

k.Log("✅ Service %q of type %q found", defaults.ClusterMeshServiceName, s.AccessInformation.ServiceType)
k.Log("✅ Cluster access information is available:")
for _, ip := range s.AccessInformation.ServiceIPs {
k.Log(" - %s:%d", ip, s.AccessInformation.ServicePort)
}
if k.externalKVStore {
k.Log("✅ Cilium is configured with an external kvstore")
} else {
s.AccessInformation, err = k.statusAccessInformation(ctx, true, false)
if err != nil {
return nil, err
}

err = k.statusDeployment(ctx)
if err != nil {
return nil, err
k.Log("✅ Service %q of type %q found", defaults.ClusterMeshServiceName, s.AccessInformation.ServiceType)
k.Log("✅ Cluster access information is available:")
for _, ip := range s.AccessInformation.ServiceIPs {
k.Log(" - %s:%d", ip, s.AccessInformation.ServicePort)
}

err = k.statusDeployment(ctx)
if err != nil {
return nil, err
}
k.Log("✅ Deployment %s is ready", defaults.ClusterMeshDeploymentName)
}
k.Log("✅ Deployment %s is ready", defaults.ClusterMeshDeploymentName)

s.Connectivity, err = k.statusConnectivity(ctx)

Expand Down

0 comments on commit 5f2a3dd

Please sign in to comment.