[root@centos7 nginx_ingress]# ps -elf | grep ingress-nginx-controller 4 S 101 101984 101964 0 80 0 - 8 SyS_rt 02:36 ? 00:00:00 /usr/bin/dumb-init -- /nginx-ingress-controller --publish-service=ingress-nginx/ingress-nginx-controller --election-id=ingress-controller-leader --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key 4 S 101 102063 101984 2 80 0 - 11642 futex_ 02:36 ? 00:00:03 /nginx-ingress-controller --publish-service=ingress-nginx/ingress-nginx-controller --election-id=ingress-controller-leader --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key 0 S root 110485 80702 0 80 0 - 1730 pipe_w 02:38 pts/0 00:00:00 grep --color=auto ingress-nginx-controller [root@centos7 nginx_ingress]# dlv attach 102063 -bash: dlv: command not found [root@centos7 nginx_ingress]# source ~/go.source [root@centos7 nginx_ingress]# dlv attach 102063 could not attach to pid 102063: could not open debug info [root@centos7 nginx_ingress]#
更改编译选项
build/build.sh
去掉 -w -s 选项
#-trimpath -ldflags="-buildid= -w -s go build -trimpath -ldflags=" -X ${PKG}/version.RELEASE=${TAG} -X ${PKG}/version.COMMIT=${COMMIT_SHA} -X ${PKG}/version.REPO=${REPO_INFO}" -o "rootfs/bin/${ARCH}/nginx-ingress-controller" "${PKG}/cmd/nginx"
root@ubuntu:~/nginx_ingress/ingress-nginx# env DOCKER_IN_DOCKER_ENABLED="true" make build root@ubuntu:~/nginx_ingress/ingress-nginx# ls rootfs/bin/arm64/ -al total 60312 drwxr-xr-x 2 root root 4096 Aug 5 15:06 . drwxr-xr-x 3 root root 4096 Aug 4 20:43 .. -rwxr-xr-x 1 root root 6946816 Aug 5 15:06 dbg -rwxr-xr-x 1 root root 50133530 Aug 5 15:06 nginx-ingress-controller -rwxr-xr-x 1 root root 5111808 Aug 5 15:06 wait-shutdown root@ubuntu:~/nginx_ingress/ingress-nginx#
[root@centos7 nginx_ingress]# ps -elf | grep ingress 4 S 101 40998 40960 0 80 0 - 8 SyS_rt 03:14 ? 00:00:00 /usr/bin/dumb-init -- /nginx-ingress-controller --publish-service=ingress-nginx/ingress-nginx-controller --election-id=ingress-controller-leader --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key 4 S 101 41105 40998 17 80 0 - 11654 futex_ 03:14 ? 00:00:03 /nginx-ingress-controller --publish-service=ingress-nginx/ingress-nginx-controller --election-id=ingress-controller-leader --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key 0 S root 45941 80702 0 80 0 - 1730 pipe_w 03:15 pts/0 00:00:00 grep --color=auto ingress [root@centos7 nginx_ingress]# dlv attach 41105 Type 'help' for list of commands. (dlv) goroutines Goroutine 1 - User: k8s.io/ingress-nginx/cmd/nginx/main.go:186 main.handleSigterm (0xfcf354) [chan receive 450915h28m30.524006049s] Goroutine 2 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [force gc (idle) 450915h28m30.8665417s] Goroutine 3 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC sweep wait] Goroutine 4 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC scavenge wait] Goroutine 5 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [finalizer wait 450915h28m28.156971677s] Goroutine 6 - User: k8s.io/klog/v2@v2.4.0/klog.go:1169 k8s.io/klog/v2.(*loggingT).flushDaemon (0x25eb50) [chan receive] Goroutine 7 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 8 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 9 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 10 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 11 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 12 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 13 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 14 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 15 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 16 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 17 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 18 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 19 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 20 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 21 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 22 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 23 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)] Goroutine 24 - User: runtime/proc.go:305 runtime.gopark (0x44da0) [GC worker (idle)]