Skip to content

Commit c2361c6

Browse files
change debug image to terminate automatically NIS-207911 (#4)
Co-authored-by: Peter Foldberg <pfoldberg@live.dk>
1 parent 6fab359 commit c2361c6

3 files changed

Lines changed: 46 additions & 79 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ RUN pip3 install websocket-client azure-storage-blob azure-identity azure-cli==$
99
RUN npm install -g wscat
1010

1111
USER 10001:30001
12-
ENTRYPOINT ["/bin/bash"]
12+
ENTRYPOINT ["sleep"]
13+
CMD ["1800"]

README.md

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,37 @@
11
# kubernetes-debug-image
22
Debug image for debugging within a kubernetes cluster.
33

4-
5-
# Dockerfile
6-
Example of dockerfile with tools for debugging.\
7-
Tools can be added or removed in ```apt install```.
8-
9-
```
10-
FROM ubuntu:22.04
11-
12-
ARG AZ_CLI_VERSION=2.40.0
13-
14-
RUN useradd -u 10001 scratchuser
15-
RUN groupadd -g 30001 debuggroup
16-
RUN apt update; apt -y install vim netcat-openbsd curl wget bind9-host bind9-dnsutils python3 python3-pip postgresql-client; apt clean
17-
RUN pip3 install azure-storage-blob azure-identity azure-cli==${AZ_CLI_VERSION}
18-
19-
USER 10001:30001
20-
ENTRYPOINT ["tail", "-f", "/dev/null"]
21-
```
22-
234
# Debug deployment
245
Example of yaml file containing the deployment of debugger pods.\
256
Namespace needs to be changed to match the environment it's deployed in.\
267
Currently the image is set to the default debug-image.\
27-
Consider adding egress rules for debugging the network.
28-
8+
Consider adding egress rules for debugging the network. \
9+
Default duration before container terminates is 30 minutes. \
10+
This can be overwritten in the args field on the container. \
11+
The time must be set in seconds.
2912
```
30-
---
31-
apiVersion: apps/v1
32-
kind: Deployment
13+
apiVersion: v1
14+
kind: Pod
3315
metadata:
34-
name: debug-deployment
35-
namespace: your-namespace
16+
name: debug-pod
17+
namespace: <namespace>
18+
labels:
19+
appName: debug
20+
netic.dk/network-rules-egress: app-name
21+
netic.dk/network-component: other-app-name
3622
spec:
37-
replicas: 1
38-
selector:
39-
matchLabels:
40-
appName: debug
41-
template:
42-
metadata:
43-
labels:
44-
appName: debug
45-
netic.dk/network-rules-egress: app-name
46-
netic.dk/network-component: other-app-name
47-
spec:
48-
securityContext:
49-
runAsUser: 10001
50-
runAsGroup: 30001
51-
containers:
52-
- name: debug-pod
53-
image: ghcr.io/neticdk/kubernetes-debug-image:<tag>
54-
command:
55-
- /bin/tail
56-
- -f
57-
- /dev/null
58-
securityContext:
59-
allowPrivilegeEscalation: false
60-
capabilities:
61-
drop:
62-
- "ALL"
23+
securityContext:
24+
runAsUser: 10001
25+
runAsGroup: 30001
26+
containers:
27+
- name: debug-pod
28+
image: ghcr.io/neticdk/kubernetes-debug-image:<tag>
29+
args: ["1800"]
30+
securityContext:
31+
capabilities:
32+
drop:
33+
- "ALL"
34+
allowPrivilegeEscalation: false
6335
```
6436

6537
# Installation

debugger.yaml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
---
2-
apiVersion: apps/v1
3-
kind: Deployment
2+
apiVersion: v1
3+
kind: Pod
44
metadata:
5-
name: debug-deployment
6-
namespace: default
5+
name: debug-pod
6+
namespace: <namespace>
7+
labels:
8+
appName: debug
9+
netic.dk/network-rules-egress: app-name
10+
netic.dk/network-component: other-app-name
711
spec:
8-
replicas: 1
9-
selector:
10-
matchLabels:
11-
appName: debug
12-
template:
13-
metadata:
14-
labels:
15-
appName: debug
16-
netic.dk/network-rules-egress: app-name
17-
netic.dk/network-component: other-app-name
18-
spec:
19-
securityContext:
20-
runAsUser: 10001
21-
runAsGroup: 30001
22-
containers:
23-
- name: debug-pod
24-
image: ghcr.io/neticdk/kubernetes-debug-image:latest
25-
securityContext:
26-
allowPrivilegeEscalation: false
27-
capabilities:
28-
drop:
29-
- "ALL"
12+
securityContext:
13+
runAsUser: 10001
14+
runAsGroup: 30001
15+
containers:
16+
- name: debug-pod
17+
image: ghcr.io/neticdk/kubernetes-debug-image:<tag>
18+
args: ["1800"]
19+
securityContext:
20+
capabilities:
21+
drop:
22+
- "ALL"
23+
allowPrivilegeEscalation: false

0 commit comments

Comments
 (0)