Skip to content

Commit

Permalink
Merge branch 'main' into kustomization-fix-role
Browse files Browse the repository at this point in the history
  • Loading branch information
mlavacca authored Apr 2, 2024
2 parents 3c1ba3f + 4e516db commit c19fc90
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,13 @@ debug: webhook-certs-dir manifests generate install _ensure-kong-system-namespac

.PHONY: debug.skaffold
debug.skaffold: _ensure-kong-system-namespace
GOCACHE=$(shell go env GOCACHE) \
TAG=$(TAG)-debug REPO_INFO=$(REPO_INFO) COMMIT=$(COMMIT) \
$(SKAFFOLD) debug --port-forward=pods --profile=debug

.PHONY: debug.skaffold.continuous
debug.skaffold.continuous: _ensure-kong-system-namespace
GOCACHE=$(shell go env GOCACHE) \
TAG=$(TAG)-debug REPO_INFO=$(REPO_INFO) COMMIT=$(COMMIT) \
$(SKAFFOLD) debug --port-forward=pods --profile=debug --auto-build --auto-deploy --auto-sync

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ detailed description of how to thoroughly use this project.
### Prerequisites

In order to build the operator you'll have to have Go installed on your machine.
In order to do so, follow the instructions on its website][go-dev-site].
In order to do so, follow the instructions on its website[go-dev-site].

### Build process

Expand All @@ -56,6 +56,14 @@ After this step has finished successfully you should see the operator's binary `
You can also run it directly via `make run` which will run the operator on your
machine against the cluster that you have configured via your `KUBECONFIG`.

### Adding new CRDs

Whenever you add a new CRD ensure that it is included in project's [`PROJECT`](./PROJECT) file.

This is necessary for creation of a bundle for external hubs like [Operator Hub's community operators][community-operators].

[community-operators]: https://github.com/k8s-operatorhub/community-operators/

## Seeking Help

Please search through the posts on the [discussions page][disc] as it's likely
Expand Down
36 changes: 24 additions & 12 deletions debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

FROM golang:1.22.1 as debug

ARG GOPATH
ARG GOCACHE

ARG TAG
ARG NAME="Kong Gateway Operator"
ARG DESCRIPTION="Kong Gateway Operator debug image"
Expand All @@ -30,15 +33,18 @@ RUN printf "Building for TARGETPLATFORM=${TARGETPLATFORM}" \

WORKDIR /workspace

COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
RUN --mount=type=cache,target=$GOPATH/pkg/mod \
--mount=type=cache,target=$GOCACHE \
go install github.com/go-delve/delve/cmd/[email protected]

COPY Makefile Makefile
COPY third_party/go.mod third_party/go.mod
COPY third_party/go.sum third_party/go.sum
COPY third_party/dlv.go third_party/dlv.go
RUN make dlv
# Use cache mounts to cache Go dependencies and bind mounts to avoid unnecessary
# layers when using COPY instructions for go.mod and go.sum.
# https://docs.docker.com/build/guide/mounts/
RUN --mount=type=cache,target=$GOPATH/pkg/mod \
--mount=type=cache,target=$GOCACHE \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x

COPY main.go main.go
COPY modules/ modules/
Expand All @@ -49,11 +55,17 @@ COPY internal/ internal/
COPY Makefile Makefile
COPY .git/ .git/

RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" \
# Use cache mounts to cache Go dependencies and bind mounts to avoid unnecessary
# layers when using COPY instructions for go.mod and go.sum.
# https://docs.docker.com/build/guide/mounts/
RUN --mount=type=cache,target=$GOPATH/pkg/mod \
--mount=type=cache,target=$GOCACHE \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" \
TAG="${TAG}" COMMIT="${COMMIT}" REPO_INFO="${REPO_INFO}" \
make build.operator.debug && \
mv ./bin/manager /go/bin/manager && \
mv ./bin/dlv /go/bin/dlv
mv ./bin/manager /go/bin/manager

ENTRYPOINT [ "/go/bin/dlv" ]
ENTRYPOINT [ "dlv" ]
CMD [ "--continue", "--accept-multiclient", "--listen=:40000", "--check-go-version=false", "--headless=true", "--api-version=2", "--log=true", "--log-output=debugger,debuglineerr,gdbwire", "exec", "/go/bin/manager", "--" ]

0 comments on commit c19fc90

Please sign in to comment.