Skip to content

Commit

Permalink
Adding get cluster id call and bumping go version on dockerfile (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
evyatarmeged committed Apr 25, 2024
1 parent b30cba2 commit d15ce8f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build/kafka-watcher.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as buildenv
FROM --platform=$BUILDPLATFORM golang:1.22.1-alpine as buildenv
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
WORKDIR /src
Expand Down
2 changes: 1 addition & 1 deletion build/mapper.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as buildenv
FROM --platform=$BUILDPLATFORM golang:1.22.1-alpine as buildenv
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
WORKDIR /src
Expand Down
4 changes: 2 additions & 2 deletions build/sniffer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 golang:1.21-alpine as buildenv
FROM --platform=linux/amd64 golang:1.22.1-alpine as buildenv
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
WORKDIR /src
Expand All @@ -14,7 +14,7 @@ RUN go test ./sniffer/... && echo dep > /dep

# We start from the base image again, only this time it's using the target arch instead of always amd64. This is done to make the build faster.
# Unlike the mapper, it can't be amd64 throughout and use Go's cross-compilation, since the sniffer depends on libpcap (C library).
FROM golang:1.21-alpine as builder
FROM golang:1.22.1-alpine as builder
COPY --from=test /dep /dep
RUN apk add --no-cache ca-certificates git protoc
RUN apk add build-base libpcap-dev
Expand Down
2 changes: 1 addition & 1 deletion helm-charts
Submodule helm-charts updated 27 files
+2 −2 credentials-operator/Chart.yaml
+0 −28 credentials-operator/templates/configmap.yaml
+44 −0 credentials-operator/templates/credentials-operator-aws-mutating-webhook-configuration.yaml
+4 −13 credentials-operator/templates/credentials-operator-azure-mutating-webhook-configuration.yaml
+13 −9 credentials-operator/templates/credentials-operator-deployment.yaml
+35 −0 credentials-operator/templates/credentials-operator-manager-clusterrole.yaml
+29 −0 credentials-operator/templates/extended-config-configmap.yaml
+1 −0 credentials-operator/values.yaml
+2 −2 intents-operator/Chart.yaml
+18 −27 intents-operator/README.md
+87 −0 intents-operator/crds/clientintents-customresourcedefinition.yaml
+2 −0 intents-operator/crds/kafkaserverconfigs-customresourcedefinition.yaml
+79 −0 intents-operator/crds/postgresqlserverconfigs-customresourcedefinition.yaml
+2 −0 intents-operator/crds/protectedservices-customresourcedefinition.yaml
+29 −0 intents-operator/templates/extended-config-configmap.yaml
+15 −15 intents-operator/templates/intents-operator-deployment.yaml
+45 −0 intents-operator/templates/intents-operator-manager-clusterrole.yaml
+0 −38 intents-operator/templates/intents-operator-manager-configmap.yaml
+100 −88 intents-operator/templates/otterize-validating-webhook-configuration.yaml
+2 −0 intents-operator/values.yaml
+2 −2 network-mapper/Chart.yaml
+12 −4 network-mapper/templates/mapper-deployment.yaml
+1 −0 network-mapper/templates/sniffer-daemonset.yaml
+1 −1 network-mapper/templates/visibility-dns-webhook-config.yaml
+1 −0 network-mapper/values.yaml
+1 −1 otterize-kubernetes/Chart.yaml
+19 −11 otterize-kubernetes/README.md
10 changes: 5 additions & 5 deletions src/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 7 additions & 21 deletions src/mapper/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"
"github.com/bombsimon/logrusr/v3"
"github.com/google/uuid"
"github.com/labstack/echo-contrib/echoprometheus"
mutatingwebhookconfiguration "github.com/otterize/intents-operator/src/operator/controllers/mutating_webhook_controller"
"github.com/otterize/intents-operator/src/shared/clusterutils"
"github.com/otterize/intents-operator/src/shared/errors"
"github.com/otterize/intents-operator/src/shared/filters"
"github.com/otterize/intents-operator/src/shared/telemetries/componentinfo"
Expand All @@ -21,11 +21,8 @@ import (
"github.com/otterize/network-mapper/src/mapper/pkg/pod_webhook"
"github.com/otterize/network-mapper/src/shared/echologrus"
"golang.org/x/sync/errgroup"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/metadata"
"net/http"
"os"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
Expand Down Expand Up @@ -56,7 +53,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
clientconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

var (
Expand Down Expand Up @@ -108,8 +104,9 @@ func main() {
if err != nil {
logrus.Panicf("unable to set up overall controller manager: %s", err)
}
signalHandlerCtx := ctrl.SetupSignalHandler()

errgrp, errGroupCtx := errgroup.WithContext(signals.SetupSignalHandler())
errgrp, errGroupCtx := errgroup.WithContext(signalHandlerCtx)

dnsCache := dnscache.NewDNSCache()
dnsPublisher, dnsPublisherEnabled, err := dnsintentspublisher.InitWithManager(errGroupCtx, mgr, dnsCache)
Expand Down Expand Up @@ -139,23 +136,12 @@ func main() {
return nil
})

metadataClient, err := metadata.NewForConfig(clientconfig.GetConfigOrDie())
clusterUID, err := clusterutils.GetOrCreateClusterUID(signalHandlerCtx)
if err != nil {
logrus.WithError(err).Panic("unable to create metadata client")
logrus.WithError(err).Panic("Failed fetching cluster UID")
}
mapping, err := mgr.GetRESTMapper().RESTMapping(schema.GroupKind{Group: "", Kind: "Namespace"}, "v1")
if err != nil {
logrus.WithError(err).Panic("unable to create Kubernetes API REST mapping")
}
kubeSystemUID := ""
kubeSystemNs, err := metadataClient.Resource(mapping.Resource).Get(context.Background(), "kube-system", metav1.GetOptions{})
if err != nil || kubeSystemNs == nil {
logrus.Warningf("failed getting kubesystem UID: %s", err)
kubeSystemUID = fmt.Sprintf("rand-%s", uuid.New().String())
} else {
kubeSystemUID = string(kubeSystemNs.UID)
}
componentinfo.SetGlobalContextId(telemetrysender.Anonymize(kubeSystemUID))

componentinfo.SetGlobalContextId(telemetrysender.Anonymize(clusterUID))

// start API server
mapperServer.GET("/healthz", func(c echo.Context) error {
Expand Down

0 comments on commit d15ce8f

Please sign in to comment.