Skip to content

Commit

Permalink
Set reporting endpoint in makefile (#5411)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-nx authored Apr 17, 2024
1 parent 4ff496a commit 9655776
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ GIT_TAG = $(shell git tag --sort=-version:refname | head -n1 || echo untagged)
VERSION = $(VER)-SNAPSHOT
PLUS_ARGS = --secret id=nginx-repo.crt,src=nginx-repo.crt --secret id=nginx-repo.key,src=nginx-repo.key

# Additional flags added here can be accessed in main.go.
# e.g. `main.version` maps to `var version` in main.go
GO_LINKER_FLAGS_VARS = -X main.version=${VERSION}
GO_LINKER_FLAGS_OPTIONS = -s -w
GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIONS) $(GO_LINKER_FLAGS_VARS)
DEBUG_GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_VARS)
DEBUG_GO_GC_FLAGS = all=-N -l

# variables that can be overridden by the user
# Variables that can be overridden
PREFIX ?= nginx/nginx-ingress ## The name of the image. For example, nginx/nginx-ingress
TAG ?= $(VERSION:v%=%) ## The tag of the image. For example, 2.0.0
TARGET ?= local ## The target of the build. Possible values: local, container and download
override DOCKER_BUILD_OPTIONS += --build-arg IC_VERSION=$(VERSION) ## The options for the docker build command. For example, --pull
ARCH ?= amd64 ## The architecture of the image or binary. For example: amd64, arm64, ppc64le, s390x. Not all architectures are supported for all targets
GOOS ?= linux ## The OS of the binary. For example linux, darwin
NGINX_AGENT ?= true
NGINX_AGENT ?= true
TELEMETRY_ENDPOINT ?= oss.edge.df.f5.com:443

# Additional flags added here can be accessed in main.go.
# e.g. `main.version` maps to `var version` in main.go
GO_LINKER_FLAGS_VARS = -X main.version=${VERSION} -X main.telemetryEndpoint=${TELEMETRY_ENDPOINT}
GO_LINKER_FLAGS_OPTIONS = -s -w
GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIONS) $(GO_LINKER_FLAGS_VARS)
DEBUG_GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_VARS)
DEBUG_GO_GC_FLAGS = all=-N -l

# final docker build command
DOCKER_CMD = docker build --platform linux/$(strip $(ARCH)) $(strip $(DOCKER_BUILD_OPTIONS)) --target $(strip $(TARGET)) -f build/Dockerfile -t $(strip $(PREFIX)):$(strip $(TAG)) .
Expand Down
4 changes: 3 additions & 1 deletion cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import (

// Injected during build
var (
version string
version string
telemetryEndpoint string
)

const (
Expand Down Expand Up @@ -212,6 +213,7 @@ func main() {
IsIPV6Disabled: *disableIPV6,
WatchNamespaceLabel: *watchNamespaceLabel,
EnableTelemetryReporting: *enableTelemetryReporting,
TelemetryReportingEndpoint: telemetryEndpoint,
NICVersion: version,
DynamicWeightChangesReload: *enableDynamicWeightChangesReload,
}
Expand Down
5 changes: 4 additions & 1 deletion internal/k8s/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ type NewLoadBalancerControllerInput struct {
IsIPV6Disabled bool
WatchNamespaceLabel string
EnableTelemetryReporting bool
TelemetryReportingEndpoint string
NICVersion string
DynamicWeightChangesReload bool
}
Expand Down Expand Up @@ -352,9 +353,11 @@ func NewLoadBalancerController(input NewLoadBalancerControllerInput) *LoadBalanc
// NIC Telemetry Reporting
if input.EnableTelemetryReporting {
exporterCfg := telemetry.ExporterCfg{
Endpoint: "oss.edge.df.f5.com:443",
Endpoint: input.TelemetryReportingEndpoint,
}

glog.V(3).Infof("Telemetry Endpoint: %s", input.TelemetryReportingEndpoint)

exporter, err := telemetry.NewExporter(exporterCfg)
if err != nil {
glog.Fatalf("failed to initialize telemetry exporter: %v", err)
Expand Down

0 comments on commit 9655776

Please sign in to comment.