-
Notifications
You must be signed in to change notification settings - Fork 157
Enable remote debugging with delve #742
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
Merged
k8s-ci-robot
merged 7 commits into
kubernetes-sigs:master
from
mauriciopoppe:delve-remote-debugging
Apr 20, 2021
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
977a57b
enable remote debugging with delve
mauriciopoppe 5c2696b
use GCFLAGS with envvar
mauriciopoppe 765dc41
always set gcflags in Makefile
mauriciopoppe 93b9ec9
Add docs for remote debugging
mauriciopoppe 649538e
Use negation of == in comparison for the overlay name
mauriciopoppe 2c3a835
Add missing _DEV env vars
mauriciopoppe ca3e20f
Renamed noauth-dev to noauth-debug, update image versions
mauriciopoppe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# 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 golang:1.13.15 as builder | ||
WORKDIR /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver | ||
ADD . . | ||
|
||
RUN CGO_ENABLED=0 go get -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv | ||
RUN GCE_PD_CSI_DEBUG=1 make gce-pd-driver | ||
|
||
# MAD HACKS: Build a version first so we can take the scsi_id bin and put it somewhere else in our real build | ||
FROM k8s.gcr.io/build-image/debian-base-amd64:v2.1.3 as base | ||
RUN clean-install udev | ||
|
||
# Start from Kubernetes Debian base | ||
FROM k8s.gcr.io/build-image/debian-base-amd64:v2.1.3 | ||
mauriciopoppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Copy source code too to correlate the binary and the breakpoints | ||
WORKDIR /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver | ||
ADD . . | ||
|
||
COPY --from=builder /go/bin/dlv /go/bin/dlv | ||
|
||
# Install necessary dependencies | ||
RUN clean-install util-linux e2fsprogs mount ca-certificates udev xfsprogs | ||
COPY --from=base /lib/udev/scsi_id /lib/udev_containerized/scsi_id | ||
|
||
# PDCSI driver isn't copied to / because of delve not being able to correlate | ||
# the binary and the source code, instead just run the binary where it was | ||
# compiled, the overlay noauth-dev calls this binary | ||
ENTRYPOINT ["/go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
deploy/kubernetes/overlays/noauth-dev/controller-overlay.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
kind: Deployment | ||
mauriciopoppe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
apiVersion: apps/v1 | ||
metadata: | ||
name: csi-gce-pd-controller | ||
annotations: | ||
# https://kubernetes.io/docs/tutorials/clusters/apparmor/ | ||
container.apparmor.security.beta.kubernetes.io/gce-pd-driver: unconfined | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: gce-pd-driver | ||
imagePullPolicy: Always | ||
command: ["/go/bin/dlv"] | ||
args: | ||
- "--listen=:2345" | ||
- "--headless=true" | ||
- "--api-version=2" | ||
# https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_exec.md#options | ||
- "--accept-multiclient" | ||
- "--continue" | ||
- "--log" | ||
- "exec" | ||
- "/go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver" | ||
- "--" | ||
- "--v=5" | ||
- "--endpoint=unix:/csi/csi.sock" | ||
ports: | ||
- containerPort: 2345 | ||
securityContext: | ||
capabilities: | ||
add: | ||
- SYS_PTRACE | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ../../base/ | ||
# Here noauth overlay is using the same image as alpha | ||
transformers: | ||
- ../../images/alpha | ||
patchesStrategicMerge: | ||
- noauth.yaml | ||
- controller-overlay.yaml | ||
namespace: gce-pd-csi-driver | ||
# To change the dev image, add something like the following. | ||
# images: | ||
# - name: gke.gcr.io/gcp-compute-persistent-disk-csi-driver | ||
# newName: gcr.io/mauriciopoppe-gke-dev/gcp-compute-persistent-disk-csi-driver | ||
# newTag: latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: csi-gce-pd-controller | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: gce-pd-driver | ||
env: | ||
- $patch: delete | ||
name: GOOGLE_APPLICATION_CREDENTIALS | ||
value: "/etc/cloud-sa/cloud-sa.json" | ||
volumeMounts: | ||
- $patch: delete | ||
name: cloud-sa-volume | ||
readOnly: true | ||
mountPath: "/etc/cloud-sa" | ||
volumes: | ||
- $patch: delete | ||
name: cloud-sa-volume | ||
secret: | ||
secretName: cloud-sa | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.