Skip to content

Commit

Permalink
Add debug to options to branch 1.5.1-0.5 (kubernetes#27)
Browse files Browse the repository at this point in the history
* add debug info

* My empty commit with a message
  • Loading branch information
Alvaro-Campesino authored Feb 15, 2023
1 parent 69eec14 commit 20ecce7
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ deploy:
.PHONY: build
build:
bin/package.sh
bin/docker-build.sh $(name)
bin/docker-build.sh $(name) $(file)
bin/clean.sh


build-debug:
bin/package-debug.sh
bin/docker-build.sh stratio/ingress-nginx-debug Dockerfile.debug
bin/clean.sh

chart:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ See the [Getting Started](https://kubernetes.github.io/ingress-nginx/deploy/) do

## Troubleshooting

You can use the debug image to debug the ingress processes, you will have to expose a port (i.e 40000) in the deployment and from the pod run:
``
$ /dlv -l40000 attach <process_pid>
``
After running this command in the pod, connect your local debugg er to the exposed port.

If you encounter issues, review the [troubleshooting docs](docs/troubleshooting.md),
[file an issue](https://github.com/kubernetes/ingress-nginx/issues), or talk to us on the
[#ingress-nginx channel](https://kubernetes.slack.com/messages/ingress-nginx) on the Kubernetes Slack server.
Expand Down
3 changes: 2 additions & 1 deletion bin/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
BASEDIR="$(realpath "$(dirname "$0")/..")"

name="${1:-stratio/ingress-nginx}"
file="${2:-Dockerfile.stratio}"

cd "$BASEDIR"

docker build --network host -t "${name}:test" -f "rootfs/Dockerfile.stratio" .
docker build --network host -t "${name}:test" -f "rootfs/${file}" .
41 changes: 41 additions & 0 deletions bin/package-debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash -e

BASEDIR="$(realpath "$(dirname "$0")/..")"
GODIR_ROOT="$BASEDIR/cmd"

#### PREPARE
rm -rf "${BASEDIR}/dist"
mkdir "${BASEDIR}/dist"

if [[ -z "$1" ]]; then
VERSION=$(cat $BASEDIR/VERSION)
else
VERSION=$1
fi

export GOPATH="${BASEDIR}/dist"
export HOME="${BASEDIR}/go"

echo "Building and downloading dlv..."
mkdir ${BASEDIR}/dist/delve
git clone https://github.com/go-delve/delve.git ${BASEDIR}/dist/delve
cd ${BASEDIR}/dist/delve/cmd/dlv
CGO_ENABLED=0 go build -ldflags "-s -w -extldflags '-static'" -o "${BASEDIR}/dist/dlv"

cd "$GODIR_ROOT/nginx"
echo "Building ingress-nginx nginx-ingress-controller..."
CGO_ENABLED=0 GOOS=linux /usr/local/go/bin/go build -buildvcs=false -gcflags "all=-N -l" -o "${BASEDIR}/dist/nginx-ingress-controller" ${GODIR_ROOT}/nginx
echo "Cleaning ingress-nginx nginx dependencies..."
/usr/local/go/bin/go clean -modcache

cd "$GODIR_ROOT/dbg"
echo "Building ingress-nginx dbg..."
CGO_ENABLED=0 GOOS=linux /usr/local/go/bin/go build -buildvcs=false -gcflags "-N -l" -o "${BASEDIR}/dist/dbg" ${GODIR_ROOT}/dbg
echo "Cleaning ingress-nginx dbg dependencies..."
/usr/local/go/bin/go clean -modcache

cd "$GODIR_ROOT/waitshutdown"
echo "Building ingress-nginx wait-shutdown..."
CGO_ENABLED=0 GOOS=linux /usr/local/go/bin/go build -buildvcs=false -gcflags "all=-N -l" -o "${BASEDIR}/dist/wait-shutdown" ${GODIR_ROOT}/waitshutdown
echo "Cleaning ingress-nginx waitshutdown dependencies..."
/usr/local/go/bin/go clean -modcache
107 changes: 107 additions & 0 deletions rootfs/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright 2015 The Kubernetes Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



FROM qa.int.stratio.com/ingress-nginx/nginx:81c2afd975a6f9a9847184472286044d7d5296f6@sha256:a71ac64dd8cfd68341ba47dbdc4d8c2cb91325fce669875193ea0319118201b5


WORKDIR /etc/nginx

RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
&& apk upgrade openssl --repository=https://dl-cdn.alpinelinux.org/alpine/v3.14/main \
&& apk add make --repository=https://dl-cdn.alpinelinux.org/alpine/v3.14/main \
diffutils make unzip \
&& apk upgrade libxml2 \
&& apk add --no-cache libc6-compat \
&& apk add gdb \
&& rm -rf /var/cache/apk/*

# JWT manipulation dependencies
ENV LUAROCKS_VERSION 3.8.0
ENV LUAROCKS_SHA ab6612ca9ab87c6984871d2712d05525775e8b50172701a0a1cabddf76de2be7


RUN wget -O /tmp/luarocks.tgz \
https://github.com/luarocks/luarocks/archive/v${LUAROCKS_VERSION}.tar.gz \
&& echo "${LUAROCKS_SHA} */tmp/luarocks.tgz" | sha256sum -c - \
&& tar -C /tmp -xzf /tmp/luarocks.tgz \
&& cd /tmp/luarocks* \
&& ./configure \
&& make install

RUN luarocks install lua-resty-jwt
# End manipulation dependencies



COPY rootfs/etc /etc
RUN chown -R root:root /etc/nginx


COPY rootfs/etc /etc
RUN chown -R www-data:www-data /etc/nginx

COPY dist/dbg /
RUN chown -R www-data:www-data /dbg
COPY dist/nginx-ingress-controller /
RUN chown -R www-data:www-data /nginx-ingress-controller
COPY dist/wait-shutdown /
RUN chown -R www-data:www-data /wait-shutdown
COPY dist/dlv /
RUN chown -R www-data:www-data /dlv

# Fix permission during the build to avoid issues at runtime
# with volumes (custom templates)
RUN bash -xeu -c ' \
writeDirs=( \
/etc/ingress-controller \
/etc/ingress-controller/ssl \
/etc/ingress-controller/auth \
/var/log \
/var/log/nginx \
/tmp/nginx \
); \
for dir in "${writeDirs[@]}"; do \
mkdir -p ${dir}; \
chown -R www-data.www-data ${dir}; \
done'

RUN apk add --no-cache libcap \
&& setcap cap_net_bind_service=+ep /nginx-ingress-controller \
&& setcap -v cap_net_bind_service=+ep /nginx-ingress-controller \
&& setcap cap_net_bind_service=+ep /usr/local/nginx/sbin/nginx \
&& setcap -v cap_net_bind_service=+ep /usr/local/nginx/sbin/nginx \
&& setcap cap_net_bind_service=+ep /usr/bin/dumb-init \
&& setcap -v cap_net_bind_service=+ep /usr/bin/dumb-init \
&& setcap cap_sys_admin,cap_sys_ptrace=+ep /dlv \
&& setcap -v cap_sys_admin,cap_sys_ptrace=+ep /dlv \
&& setcap cap_net_bind_service=+ep /dlv \
&& setcap -v cap_net_bind_service=+ep /dlv \
&& apk del libcap \
&& ln -sf /usr/local/nginx/sbin/nginx /usr/bin/nginx


USER www-data

# Create symlinks to redirect nginx logs to stdout and stderr docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

ENTRYPOINT ["/usr/bin/dumb-init", "--"]


CMD ["/nginx-ingress-controller"]

0 comments on commit 20ecce7

Please sign in to comment.