Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-1678: allow agent image configuration #48

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ IMAGE_TAG_BASE ?= quay.io/$(IMAGE_ORG)/$(NAME)
# Image URL to use all building/pushing image targets
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
PULL_POLICY ?=Always
# Agent image URL to deploy
AGENT_IMAGE ?= quay.io/netobserv/netobserv-ebpf-agent:main
OCI_BUILD_OPTS ?=

# Image building tool (docker / podman) - docker is preferred in CI
Expand Down Expand Up @@ -159,6 +161,7 @@ commands: ## Generate either oc or kubectl plugins and add them to build folder
K8S_CLI_BIN=$(K8S_CLI_BIN) \
IMAGE=$(IMAGE) \
PULL_POLICY=$(PULL_POLICY) \
AGENT_IMAGE=$(AGENT_IMAGE) \
VERSION=$(VERSION) \
./scripts/inject.sh

Expand Down
2 changes: 1 addition & 1 deletion commands/netobserv
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ filter=""
# CLI image to use
img="quay.io/netobserv/network-observability-cli:main"

if [ ! -z "$NETOBSERV_COLLECTOR_IMAGE" ]; then
if [ -n "$NETOBSERV_COLLECTOR_IMAGE" ]; then
echo "using custom collector image $NETOBSERV_COLLECTOR_IMAGE"
img="$NETOBSERV_COLLECTOR_IMAGE"
fi
Expand Down
2 changes: 1 addition & 1 deletion res/flow-capture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: netobserv-cli
image: quay.io/netobserv/netobserv-ebpf-agent:main
image: "{{AGENT_IMAGE_URL}}"
imagePullPolicy: Always
securityContext:
privileged: true
Expand Down
2 changes: 1 addition & 1 deletion res/packet-capture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: netobserv-cli
image: quay.io/netobserv/netobserv-ebpf-agent:main
image: "{{AGENT_IMAGE_URL}}"
imagePullPolicy: Always
securityContext:
privileged: true
Expand Down
10 changes: 10 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ set -eu
K8S_CLI_BIN_PATH=$( which oc 2>/dev/null || which kubectl 2>/dev/null )
K8S_CLI_BIN=$( basename "${K8S_CLI_BIN_PATH}" )

# eBPF agent image to use
agentImg="quay.io/netobserv/netobserv-ebpf-agent:main"

if [ -n "$NETOBSERV_AGENT_IMAGE" ]; then
echo "using custom agent image $NETOBSERV_AGENT_IMAGE"
agentImg="$NETOBSERV_AGENT_IMAGE"
fi

function loadYAMLs() {
namespaceYAML='
namespaceYAMLContent
Expand All @@ -29,13 +37,15 @@ function loadYAMLs() {
if [ -f ./res/flow-capture.yml ]; then
flowAgentYAML="$(cat ./res/flow-capture.yml)"
fi
flowAgentYAML="${flowAgentYAML/"{{AGENT_IMAGE_URL}}"/${agentImg}}"

packetAgentYAML='
packetAgentYAMLContent
'
if [ -f ./res/packet-capture.yml ]; then
packetAgentYAML="$(cat ./res/packet-capture.yml)"
fi
packetAgentYAML="${packetAgentYAML/"{{AGENT_IMAGE_URL}}"/${agentImg}}"

collectorServiceYAML='
collectorServiceYAMLContent
Expand Down
7 changes: 7 additions & 0 deletions scripts/inject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ else
sed -i.bak "s/--image-pull-policy=.*/--image-pull-policy='$PULL_POLICY' \\\\/" ./tmp/netobserv
fi

if [ -z "$AGENT_IMAGE" ]; then
echo "eBPF agent image not provided, keeping current one"
else
echo "updating eBPF agent images to $AGENT_IMAGE"
sed -i.bak "s|^agentImg=.*|agentImg=\"$AGENT_IMAGE\"|" ./tmp/functions.sh
fi

if [ -z "$VERSION" ]; then
echo "version not provided, keeping current one"
else
Expand Down
Loading