kubectl exec -it podname -- command
kubectl exec -it simple-webapp-1 -- sh ./root/curl-test.sh
kubectl logs -f my-app-pod my-app-container
Given the Dockefile bellow:
FROM ubuntu
ENTRYPOINT ["sleep"]
CMD ["5"]
Can run like this:
docker run ubuntu-sleeper #runs with default 5 seconds
docker run ubuntu-sleeper 10 #runs with explicit 10 seconds
Translating to a Kubernetes pod definition yaml:
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-pod
spec:
containers:
- name: ubuntu-sleeper
image: ubuntu:latest
command: ["sleep"] #command is docker ENTRYPOINT
args: ["10"] #args is docker CMD
or
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-pod
spec:
containers:
- name: ubuntu-sleeper
image: ubuntu:latest
command:
- sleep
- "10"