Skip to content

Commit

Permalink
Retrieve and set cluster UUID for context
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoxhaa committed Nov 22, 2024
1 parent 9d15a2c commit af29605
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/icinga-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
promv1 "github.com/prometheus/client_golang/api/prometheus/v1"
"github.com/spf13/pflag"
"golang.org/x/sync/errgroup"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
Expand All @@ -39,6 +40,8 @@ import (
"time"
)

var clusterContextKey = struct{}{}

const expectedSchemaVersion = "0.2.0"

func main() {
Expand Down Expand Up @@ -118,6 +121,16 @@ func main() {

g, ctx := errgroup.WithContext(context.Background())

namespaceName := "kube-system"
ns, err := clientset.CoreV1().Namespaces().Get(ctx, namespaceName, v1.GetOptions{})
if err != nil {
klog.Fatalf("Failed to retrieve namespace '%s': %v. Ensure the cluster is accessible and the namespace exists.", namespaceName, err)
}

clusterUuid := schemav1.EnsureUUID(ns.UID)

ctx = context.WithValue(ctx, clusterContextKey, clusterUuid)

if hasSchema {
var version string

Expand Down

0 comments on commit af29605

Please sign in to comment.