Skip to content

Commit

Permalink
Switch K8s tests to Wolfi by default and make it configurable (#41222) (
Browse files Browse the repository at this point in the history
#41237)

By default we test Wolfi-based images but there is now an environment
variable `IMAGE_MODIFIER` that can be used for specifying different
image prefixes when calling the make target.

Also, now the test verifies the actual container readiness and deletes
resources after itself.

(cherry picked from commit 3492089)

# Conflicts:
#	deploy/kubernetes/auditbeat-kubernetes.yaml
#	deploy/kubernetes/filebeat-kubernetes.yaml
#	deploy/kubernetes/heartbeat-kubernetes.yaml
#	deploy/kubernetes/metricbeat-kubernetes.yaml

Co-authored-by: Denis <[email protected]>
  • Loading branch information
mergify[bot] and rdner authored Oct 15, 2024
1 parent 546238a commit 9812222
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 12 deletions.
15 changes: 11 additions & 4 deletions deploy/kubernetes/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
ALL=filebeat metricbeat auditbeat heartbeat
IMAGE_MODIFIER?="-wolfi"
BEAT_VERSION=$(shell head -n 1 ../../libbeat/docs/version.asciidoc | cut -c 17- )

.PHONY: all $(ALL)

all: $(ALL)

test: all
for FILE in $(shell ls *-kubernetes.yaml); do \
BEAT=$$(echo $$FILE | cut -d \- -f 1); \
@for BEAT in $(ALL); do \
echo; \
echo "$$BEAT"; \
FILE="$$BEAT-kubernetes.yaml"; \
kubectl create -f $$FILE; \
echo "Testing $$BEAT container for readiness..."; \
kubectl wait pods -n kube-system -l k8s-app=$$BEAT --for=condition=Ready --timeout=90s; \
echo "Deleting $$BEAT..."; \
kubectl delete -f $$FILE; \
done

clean:
@for f in $(ALL); do rm -f "$$f-kubernetes.yaml"; done

$(ALL):
@echo "Generating $@-kubernetes.yaml"
@echo "Generating $@-kubernetes.yaml for version ${BEAT_VERSION} and image modifier '${IMAGE_MODIFIER}'"
@rm -f $@-kubernetes.yaml
@for f in service-account role role-binding configmap deployment daemonset ; do \
if [ -f "$@/$@-$$f.yaml" ]; then \
echo "file: $@/$@-$$f.yaml"; \
sed "s/%VERSION%/${BEAT_VERSION}/g" $@/$@-$$f.yaml >> $@-kubernetes.yaml; \
cat $@/$@-$$f.yaml | sed "s/%VERSION%/${BEAT_VERSION}/g" | sed "s/%IMAGE_MODIFIER%/${IMAGE_MODIFIER}/g" >> $@-kubernetes.yaml; \
echo --- >> $@-kubernetes.yaml; \
fi \
done
2 changes: 1 addition & 1 deletion deploy/kubernetes/auditbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: auditbeat
image: docker.elastic.co/beats/auditbeat:8.16.0
image: docker.elastic.co/beats/auditbeat-wolfi:8.16.0
args: [
"-c", "/etc/auditbeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: auditbeat
image: docker.elastic.co/beats/auditbeat:%VERSION%
image: docker.elastic.co/beats/auditbeat%IMAGE_MODIFIER%:%VERSION%
args: [
"-c", "/etc/auditbeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/filebeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: filebeat
image: docker.elastic.co/beats/filebeat:8.16.0
image: docker.elastic.co/beats/filebeat-wolfi:8.16.0
args: [
"-c", "/etc/filebeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/filebeat/filebeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: filebeat
image: docker.elastic.co/beats/filebeat:%VERSION%
image: docker.elastic.co/beats/filebeat%IMAGE_MODIFIER%:%VERSION%
args: [
"-c", "/etc/filebeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/heartbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: heartbeat
image: docker.elastic.co/beats/heartbeat:8.16.0
image: docker.elastic.co/beats/heartbeat-wolfi:8.16.0
args: [
"-c", "/etc/heartbeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/heartbeat/heartbeat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: heartbeat
image: docker.elastic.co/beats/heartbeat:%VERSION%
image: docker.elastic.co/beats/heartbeat%IMAGE_MODIFIER%:%VERSION%
args: [
"-c", "/etc/heartbeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/metricbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: metricbeat
image: docker.elastic.co/beats/metricbeat:8.16.0
image: docker.elastic.co/beats/metricbeat-wolfi:8.16.0
args: [
"-c", "/etc/metricbeat.yml",
"-e",
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/metricbeat/metricbeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: metricbeat
image: docker.elastic.co/beats/metricbeat:%VERSION%
image: docker.elastic.co/beats/metricbeat%IMAGE_MODIFIER%:%VERSION%
args: [
"-c", "/etc/metricbeat.yml",
"-e",
Expand Down

0 comments on commit 9812222

Please sign in to comment.