Deploy Alpine debug/utility pod

Jbn1233
1 min readJun 10, 2023

--

Alpine is the best choice for this job ,but need some more setting

# debug.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: debug
name: debug
spec:
replicas: 1
selector:
matchLabels:
app: debug
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: debug
spec:
containers:

# sample usefull package:
# apk add curl jq wget openssl bash openssh-client hey bind-tools lynx

- args:
- |-
apk add curl jq openssl bash bind-tools
sleep infinity
command:
- /bin/sh
- -c
image: alpine:3.18
name: alpine
resources:
limits:
memory: 128Mi
cpu: 100m
status: {}

This will used 29 MB disk space and add 45 packages into each container.

Example:

$ kubectl apply -f debug.yaml 
deployment.apps/debug created
$ kubectl exec -it deployments/debug -- bash
debug-555ddf66c7-d956b:/#
debug-555ddf66c7-d956b:/# curl -V
curl 8.1.2 (x86_64-alpine-linux-musl) libcurl/8.1.2 OpenSSL/3.1.1 zlib/1.2.13 brotli/1.0.9 libidn2/2.3.4 nghttp2/1.53.0
Release-Date: 2023-05-30
debug-555ddf66c7-d956b:/# openssl version
OpenSSL 3.1.1 30 May 2023 (Library: OpenSSL 3.1.1 30 May 2023)

Hope that help.

edit1:

version 1.1 use postStart instead

    spec:
containers:
- args:
- sleep infinity
command:
- /bin/sh
- -c
image: ubuntu:22.04
imagePullPolicy: IfNotPresent
lifecycle:
postStart:
exec:
command:
- sh
- -c
- apt update -y ; DEBIAN_FRONTEND=noninteractive apt -y --no-install-recommends
install vim-tiny curl openssl dnsutils ldap-utils 389-ds-base
name: ubuntu

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet