Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skaffold profile to enable delve #2399

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ define GIT_SHA
endef
endif

ifndef DEBUG_KOTSADM
ifeq ("$(DEBUG_KOTSADM)", "1")
define LDFLAGS
-ldflags "\
-s -w \
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
"
endef
define GCFLAGS
-gcflags="all=-N -l"
endef
else
define LDFLAGS
-ldflags "\
-s -w \
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
"
endef
define GCFLAGS
-gcflags="all=-N -l"
endef
endif
6 changes: 6 additions & 0 deletions hack/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Next, you can build and run all server components in the Kubernetes cluster with
skaffold dev
```

To enable delve run:

```
DEBUG_KOTSADM=1 skaffold dev
```

## Notes:
- Go code will not be rebuilt automatically. Run `make kotsadm` again to make the new binary and restart the pod.
- After installing restic/velero, `kubectl -n velero edit daemonset restic` to change the volume hostPath mount from:
Expand Down
14 changes: 11 additions & 3 deletions hack/dev/Dockerfile.skaffold
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ COPY web/webcontent.go ./web/webcontent.go
COPY web/dist ./web/dist
COPY kotskinds ./kotskinds

RUN DEBUG_KOTSADM="true" make kotsadm
ARG DEBUG_KOTSADM=0

RUN make kotsadm

FROM debian:buster

RUN apt-get update && apt-get install -y --no-install-recommends curl gnupg2 \
&& curl -k https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/PostgreSQL.list \
Expand Down Expand Up @@ -165,5 +168,10 @@ COPY --from=builder /go/src/github.com/replicatedhq/kots/bin/kotsadm .
EXPOSE 40000

# Should be entrypoint
ENTRYPOINT [ "/dlv", "--listen=:40000", "--continue", "--headless=true", "--api-version=2", "--accept-multiclient", "exec"]
CMD ["/kotsadm", "api"]

ARG DEBUG_KOTSADM=0

ENV DEBUG_KOTSADM=${DEBUG_KOTSADM}

ADD hack/dev/entrypoint.sh .
ENTRYPOINT [ "./entrypoint.sh"]
7 changes: 7 additions & 0 deletions hack/dev/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ "$DEBUG_KOTSADM" = "1" ]; then
/dlv --listen=:40000 --continue --headless=true --api-version=2 --accept-multiclient exec /kotsadm api
else
/kotsadm api
fi
10 changes: 9 additions & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ profiles:
kustomize:
paths:
- "./kustomize/overlays/kotsstore"
- name: debug
activation:
- env: DEBUG_KOTSADM=1
patches:
- op: add
path: /build/artifacts/1/docker/buildArgs
value:
DEBUG_KOTSADM: 1
- name: codespace
activation:
- env: USER=codespace
- env: USER=codespace
build:
local:
concurrency: 0
Expand Down