|
1 | 1 | # kubernetes-debug-image |
2 | 2 | Debug image for debugging within a kubernetes cluster. |
3 | 3 |
|
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 | | - |
23 | 4 | # Debug deployment |
24 | 5 | Example of yaml file containing the deployment of debugger pods.\ |
25 | 6 | Namespace needs to be changed to match the environment it's deployed in.\ |
26 | 7 | 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. |
29 | 12 | ``` |
30 | | ---- |
31 | | -apiVersion: apps/v1 |
32 | | -kind: Deployment |
| 13 | +apiVersion: v1 |
| 14 | +kind: Pod |
33 | 15 | 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 |
36 | 22 | 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 |
63 | 35 | ``` |
64 | 36 |
|
65 | 37 | # Installation |
|
0 commit comments