From 7deb202c2d32fbedf15c5b18b40c60197c3cb24d Mon Sep 17 00:00:00 2001 From: Simon Bordeyne <13538749+sbordeyne@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:20:20 +0200 Subject: [PATCH] plugins: add a plugin to start an alpine:latest container in current context/namespace (#3265) * plugins: add a plugin to start an alpine:latest container in current context/namespace * start-alpine: Update plugins README * add: plugins root key to address lint issues, kubectl annotation for default container * removed label that disables istio's sidecar injection pattern --------- Co-authored-by: Simon Bordeyne Co-authored-by: Fernand Galiana --- plugins/README.md | 1 + plugins/start-alpine.yaml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 plugins/start-alpine.yaml diff --git a/plugins/README.md b/plugins/README.md index f75816de..c489b31c 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -24,6 +24,7 @@ Following is an example of some plugin files in this directory. Other files are | szero.yaml | Temporarily scale down/up all deployments, statefulsets, and daemonsets | namespaces | Shift-d/u | [szero](https://github.com/jadolg/szero) | | trace-dns.yaml | Trace DNS resolution using Inspektor Gadget (4) | containers/pods/nodes | Shift-d | | | vector-dev-top.yaml | Run `vector top` in vector.dev container | pods/container | h | [vector top](https://vector.dev/highlights/2020-12-23-vector-top/) | +| start-alpine.yaml | Starts a deployment for the `alpine:latest` docker image in the current namespace/context | deployments/pods | Ctrl-T | | [1]: https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container [2]: https://github.com/nicolaka/netshoot diff --git a/plugins/start-alpine.yaml b/plugins/start-alpine.yaml new file mode 100644 index 00000000..59efe685 --- /dev/null +++ b/plugins/start-alpine.yaml @@ -0,0 +1,14 @@ +plugins: + start-alpine-pod: + shortCut: Ctrl-T + confirm: true + description: "Start an alpine:latest pod in current context/namespace" + scopes: + - pods + - deployments + command: bash + background: true + args: + - -c + - | + echo '{"apiVersion": "apps/v1", "kind": "Deployment", "metadata": {"name": "alpine", "labels": {"app": "alpine", "debug": "1"}}, "spec": {"selector": {"matchLabels": {"app": "alpine"}}, "replicas": 1, "template": {"metadata": {"labels": {"app": "alpine", "debug": "1"}, "annotations": {"kubectl.kubernetes.io/default-container": "alpine"}}, "spec": {"containers": [{"name": "alpine", "image": "alpine:latest", "imagePullPolicy": "Always", "securityContext": {"runAsUser": 0, "runAsGroup": 0}, "stdin": true, "tty": true, "stdinOnce": true, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "resources": {"requests": {"cpu": "100m", "memory": "100Mi"}, "limits": {"cpu": "100m", "memory": "100Mi"}}}], "restartPolicy": "Always"}}}}' | kubectl apply -f - --context $CONTEXT --namespace $NAMESPACE