https://github.com/puppetlabs/kubectl-ran
Ephemeral test containers in Kubernetes
https://github.com/puppetlabs/kubectl-ran
Last synced: 5 months ago
JSON representation
Ephemeral test containers in Kubernetes
- Host: GitHub
- URL: https://github.com/puppetlabs/kubectl-ran
- Owner: puppetlabs
- License: apache-2.0
- Created: 2022-02-11T00:46:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-20T16:02:22.000Z (about 3 years ago)
- Last Synced: 2025-01-30T00:23:39.725Z (5 months ago)
- Language: Go
- Size: 96.7 KB
- Stars: 4
- Watchers: 5
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# kubectl-ran
A Kubernetes addon for running an ephemeral container with a "mounted" volume.
Example:
```
mkdir -p ./stuff
echo "Test suite" > ./stuff/in.txt
kubectl ran busybox -e VAR1=Hello -e VAR2=world -v ./stuff:/stuff -- sh -c 'cp /stuff/in.txt /stuff/out.txt && echo "$VAR1 $VAR2" >> /stuff/out.txt'
cat ./stuff/out.txt
```It works by
1. Starting a container with `tail -f /dev/null` in a new pod. You can optionally specify environment variables.
2. Copies any "mounted" volumes into the container.
3. Runs the specified command.
4. Copies the "mounted" volumes back out of the container.
5. Deletes the pod.Requires the image contain `tail` and `tar`.
You can provide a file with `--pod-file pod.yaml` to specify additional options for the pod or add a sidecar, as in
```
spec:
containers:
- name: selenium
image: selenium/standalone-chrome
ports:
- name: selenium
containerPort: 4444
readinessProbe:
httpGet:
path: /
port: 4444
volumeMounts:
- mountPath: /dev/shm
name: dshm
volumes:
- name: dshm
emptyDir:
medium: Memory
```