From b39b20021e0d01ce7812b03aed3a3eb0d20f8158 Mon Sep 17 00:00:00 2001 From: Madhu RAJAGOPAL Date: Thu, 21 Nov 2024 10:23:00 +1300 Subject: [PATCH 1/2] feat: Create container image of utility tools not avialable in production containers * The container can then be attached to a target container ephermerally for troubleshooting the target container * These tools include curl, netcat, iproute2, iperf, bash * The Makefile currently creates an image for linux/amd64 systems --- Makefile | 3 +++ nginx-debugger/Dockerfile | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 nginx-debugger/Dockerfile diff --git a/Makefile b/Makefile index c478dd0..bbd4469 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ build: go build -o cmd/kubectl-nginx_supportpkg +debugger: + docker buildx build --platform linux/amd64 -t nginx-debugger -f nginx-debugger/Dockerfile . + install: build sudo cp cmd/kubectl-nginx_supportpkg /usr/local/bin \ No newline at end of file diff --git a/nginx-debugger/Dockerfile b/nginx-debugger/Dockerfile new file mode 100644 index 0000000..d535a65 --- /dev/null +++ b/nginx-debugger/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:latest + +RUN apk --update add bind-tools curl netcat-openbsd iproute2 iperf bash && rm -rf /var/cache/apk/* \ + && ln -s /usr/bin/iperf /usr/local/bin/iperf \ + && ls -altrh /usr/local/bin/iperf + +ADD https://github.com/coredns/coredns/releases/download/v1.11.4/coredns_1.11.4_linux_amd64.tgz /coredns.tgz +RUN tar -xzvf /coredns.tgz && rm -f /coredns.tgz + +CMD ["bash"] \ No newline at end of file From fed2bf3c078cde66ff2032f91dac2411ae29009d Mon Sep 17 00:00:00 2001 From: Madhu RAJAGOPAL Date: Thu, 27 Mar 2025 15:33:26 +1300 Subject: [PATCH 2/2] feat: introduce NGINX API stats script --- Makefile | 4 +++- nginx-debugger/Dockerfile | 10 +++++++--- nginx-debugger/api_stats.sh | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 nginx-debugger/api_stats.sh diff --git a/Makefile b/Makefile index bbd4469..0e1086e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ build: go build -o cmd/kubectl-nginx_supportpkg debugger: - docker buildx build --platform linux/amd64 -t nginx-debugger -f nginx-debugger/Dockerfile . + docker buildx build --build-context project=nginx-debugger --platform linux/amd64 -t nginx-debugger -f nginx-debugger/Dockerfile . +# docker tag nginx-debugger:latest mrajagopal/f5-utils:latest +# docker push mrajagopal/f5-utils:latest install: build sudo cp cmd/kubectl-nginx_supportpkg /usr/local/bin \ No newline at end of file diff --git a/nginx-debugger/Dockerfile b/nginx-debugger/Dockerfile index d535a65..2bb28b1 100644 --- a/nginx-debugger/Dockerfile +++ b/nginx-debugger/Dockerfile @@ -1,10 +1,14 @@ FROM alpine:latest +COPY --chmod=744 --from=project api_stats.sh /root/api_stats.sh -RUN apk --update add bind-tools curl netcat-openbsd iproute2 iperf bash && rm -rf /var/cache/apk/* \ +RUN apk --update add bind-tools curl netcat-openbsd iproute2 iperf tcpdump tshark bash jq \ + && rm -rf /var/cache/apk/* \ && ln -s /usr/bin/iperf /usr/local/bin/iperf \ && ls -altrh /usr/local/bin/iperf -ADD https://github.com/coredns/coredns/releases/download/v1.11.4/coredns_1.11.4_linux_amd64.tgz /coredns.tgz -RUN tar -xzvf /coredns.tgz && rm -f /coredns.tgz +# Setting User and Home +USER root +WORKDIR /root +ENV HOSTNAME=nginx-utils CMD ["bash"] \ No newline at end of file diff --git a/nginx-debugger/api_stats.sh b/nginx-debugger/api_stats.sh new file mode 100644 index 0000000..9bf3fc5 --- /dev/null +++ b/nginx-debugger/api_stats.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +for i in /api/8/processes /api/8/connections /api/8/slabs /api/8/http/requests /api/8/http/server_zones /api/8/http/location_zones /api/8/http/caches /api/8/http/upstreams /api/8/http/keyvals; do + echo "**** $i ****" ; + curl -s "127.0.0.1:8080/$i" | jq .; + echo ""; +done \ No newline at end of file