Skip to content

Commit 1a4543c

Browse files
authored
Upgrade dependencies and Makefile improvements - Chunk 1 (#256)
* fix(cve): CVE-2025-22869 golang.org/x/crypto * chore: Add convience make targets for easier development * chore(deps): Update golang.org/x/net v0.39.0 * chore: Add more convinience Makefile functions for local dev * chore(deps): Upgrade to github.com/containerd/containerd v1.7.27 * chore: Restore original kustomization.yaml
1 parent 81f6da5 commit 1a4543c

File tree

7 files changed

+146
-65
lines changed

7 files changed

+146
-65
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ instana-agent-operator
6464
backend.cfg
6565

6666
e2e/.env
67+
.tmp

Makefile

+73-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ else
6868
CONTAINER_CMD = podman
6969
endif
7070

71+
NAMESPACE ?= instana-agent
72+
73+
INSTANA_AGENT_CLUSTER_WIDE_RESOURCES := \
74+
"crd/agents.instana.io" \
75+
"clusterrole/leader-election-role" \
76+
"clusterrole/instana-agent-clusterrole" \
77+
"clusterrolebinding/leader-election-rolebinding" \
78+
"clusterrolebinding/instana-agent-clusterrolebinding"
79+
7180
all: build
7281

7382

@@ -102,7 +111,7 @@ test: gen-mocks manifests generate fmt vet lint envtest ## Run tests but ignore
102111
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test $(PACKAGES) -coverprofile=coverage.out
103112

104113
.PHONY: e2e
105-
e2e:
114+
e2e: ## Run end-to-end tests
106115
go test -timeout=20m -count=1 -failfast -v github.com/instana/instana-agent-operator/e2e
107116

108117
##@ Build
@@ -130,6 +139,30 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~
130139
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
131140
kubectl delete -k config/crd
132141

142+
purge: ## Full purge of the agent in the cluster
143+
@echo "=== Removing finalizers from agent CR, if present ==="
144+
@echo "Checking if agent CR is present in namespace $(NAMESPACE)..."
145+
@if kubectl get agents.instana.io instana-agent -n $(NAMESPACE) >/dev/null 2>&1; then \
146+
echo "Found, removing finalizers..."; \
147+
kubectl patch agents.instana.io instana-agent -p '{"metadata":{"finalizers":null}}' --type=merge -n $(NAMESPACE); \
148+
else \
149+
echo "CR not present"; \
150+
fi
151+
@echo "=== Cleaning up cluster wide resources, if present ==="
152+
@for resource in $(INSTANA_AGENT_CLUSTER_WIDE_RESOURCES); do \
153+
resource_type=$$(echo $$resource | cut -d'/' -f1); \
154+
resource_name=$$(echo $$resource | cut -d'/' -f2); \
155+
if kubectl get $$resource_type $$resource_name > /dev/null 2>&1; then \
156+
echo "Deleting $$resource..."; \
157+
kubectl delete $$resource_type $$resource_name; \
158+
else \
159+
echo "Resource $$resource does not exist, skipping..."; \
160+
fi; \
161+
done
162+
@echo "Cleanup complete!"
163+
@echo "=== Removing instana-agent namespace, if present ==="
164+
kubectl delete ns $(NAMESPACE) --wait || true
165+
133166
deploy: manifests kustomize ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config
134167
cd config/manager && $(KUSTOMIZE) edit set image instana/instana-agent-operator=${IMG}
135168
$(KUSTOMIZE) build config/default | kubectl apply -f -
@@ -232,6 +265,45 @@ rm -rf $$TMP_DIR ;\
232265
}
233266
endef
234267

268+
.PHONY: namespace
269+
namespace: ## Generate namespace instana-agent on OCP for manual testing
270+
oc new-project instana-agent || true
271+
oc adm policy add-scc-to-user privileged -z instana-agent -n instana-agent
272+
273+
.PHONY: create-cr
274+
create-cr: ## Deploys CR from config/samples/instana_v1_instanaagent_demo.yaml (needs to be created in the workspace first)
275+
kubectl apply -f config/samples/instana_v1_instanaagent_demo.yaml
276+
277+
.PHONY: create-pull-secret
278+
create-pull-secret: ## Creates image pull secret for delivery.instana.io from your local docker config
279+
@echo "Filtering Docker config for delivery.instana.io settings, ensure to login locally first..."
280+
@mkdir -p .tmp
281+
@jq '{auths: {"delivery.instana.io": .auths["delivery.instana.io"]}}' ${HOME}/.docker/config.json > .tmp/filtered-docker-config.json
282+
@echo "Checking if secret delivery-instana-io-pull-secret exists in namespace $(NAMESPACE)..."
283+
@if kubectl get secret delivery-instana-io-pull-secret -n $(NAMESPACE) >/dev/null 2>&1; then \
284+
echo "Updating existing secret delivery-instana-io-pull-secret..."; \
285+
kubectl delete secret delivery-instana-io-pull-secret -n $(NAMESPACE); \
286+
kubectl create secret generic delivery-instana-io-pull-secret \
287+
--from-file=.dockerconfigjson=.tmp/filtered-docker-config.json \
288+
--type=kubernetes.io/dockerconfigjson \
289+
-n $(NAMESPACE); \
290+
else \
291+
echo "Creating new secret delivery-instana-io-pull-secret..."; \
292+
kubectl create secret generic delivery-instana-io-pull-secret \
293+
--from-file=.dockerconfigjson=.tmp/filtered-docker-config.json \
294+
--type=kubernetes.io/dockerconfigjson \
295+
-n $(NAMESPACE); \
296+
fi
297+
@echo "Patching serviceaccount..."
298+
@kubectl patch serviceaccount instana-agent-operator \
299+
-p '{"imagePullSecrets": [{"name": "delivery-instana-io-pull-secret"}]}' \
300+
-n instana-agent
301+
@rm -rf .tmp
302+
@echo "Restarting operator deployment..."
303+
@kubectl delete pods -l app.kubernetes.io/name=instana-agent-operator -n $(NAMESPACE)
304+
305+
.PHONY: dev-run-ocp
306+
dev-run-ocp: namespace install create-cr run ## Creates a full dev deployment on OCP from scratch, also useful after purge
235307

236308
##@ OLM
237309

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,19 @@ Kubernetes cluster. Therefore, follow the below steps:
121121

122122
1. Create a copy of the file `config/samples/instana_v1_instanaagent.yaml`, for the below steps we're assuming `config/samples/instana_v1_instanaagent_demo.yaml`
123123
2. In this file, put correct values for e.g. the Agent `key`, `endpointHost` and `endpointPort`.
124-
3. Build the Operator image: `make docker-build`
124+
3. Overwrite the default image name with a dev build `export IMG=delivery.instana.io/dev-sandbox-docker-all/${USER}/instana-agent-operator:latest` and build the Operator image: `make docker-build`
125125
4. For deploying on Minikube, there's a convenient target `make deploy-minikube`. For any other environment you would
126126
need to first push the Docker image to a valid repository using `make docker-push`, then do the deployment
127-
using `make deploy` to deploy the Operator to the cluster configured for `kubectl`.
128-
5. Deploy the custom resource earlier created using `kubectl apply -f config/samples/instana_v1_instanaagent_demo.yaml`
127+
using `make deploy` to deploy the Operator to the cluster configured for `kubectl`. Note: For non-public registries you might need to create a pull secret first, see `make create-pull-secret` for Instana's Artifactory usage.
128+
5. Deploy the custom resource earlier created using `kubectl apply -f config/samples/instana_v1_instanaagent_demo.yaml` or via `make create-cr`
129129

130130
Now you should have a successful running Operator.
131131
To remove the Operator again, run:
132132
* `kubectl delete -f config/samples/instana_v1_instanaagent_demo.yaml`
133133
* `make undeploy`.
134134

135+
If you want to wipe all cluster-wide resources or a broken installation, use `make purge`.
136+
135137
### Running tests
136138

137139
Unit tests can be executed by running `make test` without adjustments of the local environment.

config/manager/kustomization.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ kind: Kustomization
1313
images:
1414
- name: instana/instana-agent-operator
1515
newName: icr.io/instana/instana-agent-operator
16-
newTag: snapshot
16+
newTag: snapshot

config/rbac/role.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ rules:
7878
- namespaces
7979
- nodes
8080
- nodes/metrics
81+
- nodes/proxy
8182
- nodes/stats
8283
- persistentvolumeclaims
8384
- persistentvolumes

go.mod

+19-18
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ require (
66
github.com/Masterminds/goutils v1.1.1
77
github.com/Masterminds/semver/v3 v3.2.1
88
github.com/go-errors/errors v1.4.2
9-
github.com/go-logr/logr v1.4.1
9+
github.com/go-logr/logr v1.4.2
1010
github.com/openshift/client-go v0.0.0-20240906181530-b2f7c4ab0984
1111
github.com/pkg/errors v0.9.1
1212
github.com/stretchr/testify v1.8.4
1313
go.uber.org/mock v0.4.0
14-
golang.org/x/net v0.34.0
14+
golang.org/x/net v0.39.0
1515
gopkg.in/yaml.v3 v3.0.1
1616
helm.sh/helm/v3 v3.15.4
1717
k8s.io/api v0.30.3
@@ -29,17 +29,18 @@ require (
2929
github.com/MakeNowJust/heredoc v1.0.0 // indirect
3030
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
3131
github.com/Masterminds/squirrel v1.5.4 // indirect
32-
github.com/Microsoft/hcsshim v0.11.4 // indirect
3332
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
3433
github.com/beorn7/perks v1.0.1 // indirect
3534
github.com/blang/semver/v4 v4.0.0 // indirect
3635
github.com/cespare/xxhash/v2 v2.2.0 // indirect
3736
github.com/chai2010/gettext-go v1.0.2 // indirect
38-
github.com/containerd/containerd v1.7.12 // indirect
37+
github.com/containerd/containerd v1.7.27 // indirect
38+
github.com/containerd/errdefs v0.3.0 // indirect
3939
github.com/containerd/log v0.1.0 // indirect
40+
github.com/containerd/platforms v0.2.1 // indirect
4041
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
4142
github.com/davecgh/go-spew v1.1.1 // indirect
42-
github.com/distribution/reference v0.5.0 // indirect
43+
github.com/distribution/reference v0.6.0 // indirect
4344
github.com/docker/cli v25.0.1+incompatible // indirect
4445
github.com/docker/distribution v2.8.3+incompatible // indirect
4546
github.com/docker/docker v25.0.6+incompatible // indirect
@@ -81,7 +82,7 @@ require (
8182
github.com/jmoiron/sqlx v1.3.5 // indirect
8283
github.com/josharian/intern v1.0.0 // indirect
8384
github.com/json-iterator/go v1.1.12 // indirect
84-
github.com/klauspost/compress v1.16.0 // indirect
85+
github.com/klauspost/compress v1.16.7 // indirect
8586
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
8687
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
8788
github.com/lib/pq v1.10.9 // indirect
@@ -102,7 +103,7 @@ require (
102103
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
103104
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
104105
github.com/opencontainers/go-digest v1.0.0 // indirect
105-
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
106+
github.com/opencontainers/image-spec v1.1.0 // indirect
106107
github.com/openshift/api v0.0.0-20240906165951-d73f2e11e0be // indirect
107108
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
108109
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -124,25 +125,25 @@ require (
124125
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
125126
github.com/xlab/treeprint v1.2.0 // indirect
126127
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
127-
go.opentelemetry.io/otel v1.19.0 // indirect
128-
go.opentelemetry.io/otel/metric v1.19.0 // indirect
129-
go.opentelemetry.io/otel/trace v1.19.0 // indirect
128+
go.opentelemetry.io/otel v1.21.0 // indirect
129+
go.opentelemetry.io/otel/metric v1.21.0 // indirect
130+
go.opentelemetry.io/otel/trace v1.21.0 // indirect
130131
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
131132
go.uber.org/multierr v1.11.0 // indirect
132133
go.uber.org/zap v1.26.0 // indirect
133-
golang.org/x/crypto v0.32.0 // indirect
134+
golang.org/x/crypto v0.37.0 // indirect
134135
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
135136
golang.org/x/oauth2 v0.17.0 // indirect
136-
golang.org/x/sync v0.10.0 // indirect
137-
golang.org/x/sys v0.29.0 // indirect
138-
golang.org/x/term v0.28.0 // indirect
139-
golang.org/x/text v0.21.0 // indirect
137+
golang.org/x/sync v0.13.0 // indirect
138+
golang.org/x/sys v0.32.0 // indirect
139+
golang.org/x/term v0.31.0 // indirect
140+
golang.org/x/text v0.24.0 // indirect
140141
golang.org/x/time v0.5.0 // indirect
141142
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
142143
google.golang.org/appengine v1.6.8 // indirect
143-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
144-
google.golang.org/grpc v1.58.3 // indirect
145-
google.golang.org/protobuf v1.33.0 // indirect
144+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
145+
google.golang.org/grpc v1.59.0 // indirect
146+
google.golang.org/protobuf v1.35.2 // indirect
146147
gopkg.in/inf.v0 v0.9.1 // indirect
147148
gopkg.in/yaml.v2 v2.4.0 // indirect
148149
k8s.io/apiextensions-apiserver v0.30.3 // indirect

0 commit comments

Comments
 (0)