Skip to content

Commit 08925bb

Browse files
committed
chore: Add image-pre-pulling to Makefile
1 parent 1a4543c commit 08925bb

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ else
6969
endif
7070

7171
NAMESPACE ?= instana-agent
72+
NAMESPACE_PREPULLER ?= instana-agent-image-prepuller
7273

7374
INSTANA_AGENT_CLUSTER_WIDE_RESOURCES := \
7475
"crd/agents.instana.io" \
@@ -302,6 +303,36 @@ create-pull-secret: ## Creates image pull secret for delivery.instana.io from yo
302303
@echo "Restarting operator deployment..."
303304
@kubectl delete pods -l app.kubernetes.io/name=instana-agent-operator -n $(NAMESPACE)
304305

306+
.PHONY: pre-pull-images
307+
pre-pull-images: ## Pre-pulls images on the target cluster (useful in slow network situations to run tests reliably)
308+
@if [ "$(INSTANA_API_KEY)" == "" ]; then \
309+
echo "env variable INSTANA_API_KEY is undefined but should contain the agent download key"; \
310+
exit 1; \
311+
fi
312+
oc new-project $(NAMESPACE_PREPULLER) || true
313+
@echo "Creating Docker registry secret..."
314+
@echo "Checking if secret containers-instana-io-pull-secret exists in namespace $(NAMESPACE_PREPULLER)..."
315+
@if kubectl get secret containers-instana-io-pull-secret -n $(NAMESPACE_PREPULLER) >/dev/null 2>&1; then \
316+
echo "Updating existing secret containers-instana-io-pull-secret..."; \
317+
kubectl delete secret containers-instana-io-pull-secret -n $(NAMESPACE_PREPULLER); \
318+
fi
319+
@kubectl create secret docker-registry containers-instana-io-pull-secret \
320+
--docker-server=containers.instana.io \
321+
--docker-username="_" \
322+
--docker-password=$${INSTANA_API_KEY} \
323+
-n $(NAMESPACE_PREPULLER)
324+
@echo "Start instana-agent-image-prepuller daemonset..."
325+
@echo "Checking if daemonset instana-agent-image-prepuller exists in namespace $(NAMESPACE_PREPULLER)..."
326+
@if kubectl get ds instana-agent-image-prepuller -n $(NAMESPACE_PREPULLER) >/dev/null 2>&1; then \
327+
echo "Updating existing secret containers-instana-io-pull-secret..."; \
328+
kubectl delete ds instana-agent-image-prepuller -n $(NAMESPACE_PREPULLER); \
329+
kubectl delete pods -n instana-agent-image-prepuller -l name=instana-agent-image-prepuller --force --grace-period=0; \
330+
fi
331+
@kubectl apply -f ci/scripts/instana-agent-image-prepuller.yaml -n $(NAMESPACE_PREPULLER)
332+
@echo "Waiting for the instana-agent-prepuller daemonset"
333+
@kubectl rollout status ds/instana-agent-image-prepuller -n $(NAMESPACE_PREPULLER) --timeout=900s
334+
# if pods should be deleted without waiting for the pull to stop: kubectl delete pods -n instana-agent-image-prepuller -l name=instana-agent-image-prepuller --force --grace-period=0 && kubectl delete ns instana-agent-image-prepuller
335+
305336
.PHONY: dev-run-ocp
306337
dev-run-ocp: namespace install create-cr run ## Creates a full dev deployment on OCP from scratch, also useful after purge
307338

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: instana-agent-image-prepuller
5+
spec:
6+
selector:
7+
matchLabels:
8+
name: instana-agent-image-prepuller
9+
template:
10+
metadata:
11+
labels:
12+
name: instana-agent-image-prepuller
13+
spec:
14+
imagePullSecrets:
15+
- name: containers-instana-io-pull-secret
16+
containers:
17+
- name: wait-container
18+
image: icr.io/instana/instana-agent-operator:latest
19+
command: ["/bin/sh", "-c", "echo 'All images pre-pulled successfully'; sleep 600"]
20+
imagePullPolicy: IfNotPresent
21+
securityContext:
22+
allowPrivilegeEscalation: false
23+
capabilities:
24+
drop: ["ALL"]
25+
runAsNonRoot: true
26+
seccompProfile:
27+
type: RuntimeDefault
28+
initContainers:
29+
- name: pull-operator
30+
image: icr.io/instana/instana-agent-operator:latest
31+
command: ["/bin/sh", "-c", "echo 'Pulled operator image'"]
32+
imagePullPolicy: Always
33+
securityContext:
34+
allowPrivilegeEscalation: false
35+
capabilities:
36+
drop: ["ALL"]
37+
runAsNonRoot: true
38+
seccompProfile:
39+
type: RuntimeDefault
40+
- name: pull-dynamic-agent
41+
image: icr.io/instana/agent:latest
42+
command: ["/bin/sh", "-c", "echo 'Pulled dynamic agent image'"]
43+
imagePullPolicy: Always
44+
securityContext:
45+
allowPrivilegeEscalation: false
46+
capabilities:
47+
drop: ["ALL"]
48+
runAsNonRoot: true
49+
seccompProfile:
50+
type: RuntimeDefault
51+
- name: pull-k8sensor
52+
image: icr.io/instana/k8sensor:latest
53+
command: ["/ko-app/k8sensor", "--help"]
54+
imagePullPolicy: Always
55+
securityContext:
56+
allowPrivilegeEscalation: false
57+
capabilities:
58+
drop: ["ALL"]
59+
runAsNonRoot: true
60+
seccompProfile:
61+
type: RuntimeDefault
62+
- name: pull-static-agent
63+
image: containers.instana.io/instana/release/agent/static:latest
64+
command: ["/bin/sh", "-c", "echo 'Pulled static agent image'"]
65+
imagePullPolicy: Always
66+
securityContext:
67+
allowPrivilegeEscalation: false
68+
capabilities:
69+
drop: ["ALL"]
70+
runAsNonRoot: true
71+
seccompProfile:
72+
type: RuntimeDefault

0 commit comments

Comments
 (0)