Read more about Pods
Tips and Tricks
For simulated Practice problems visit KillerCoda.
-
Solution
k create ns cygnus
-
Solution
k get ns default -o yaml > default-ns.yaml
-
Solution
k run alpha --image=nginx --restart=Never -n cygnus
-
create a pod with name
theta
and imagenginx
indefault
namespace and writeenv
variables of that pod to filetheta-env.txt
.Solution
k run theta --image=nginx k exec theta -ti -- env > theta-env.txt
-- OR --
k run theta --image=nginx -ti -- env # this will print env variables copy and paste it to theta-env.txt
-
Solution
k run beta --image=nginx --dry-run=client -o yaml > pod.yaml # update pod.yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: beta name: beta spec: containers: - image: nginx name: bore # update name here resources: {} dnsPolicy: ClusterFirst restartPolicy: Always status: {} # create pod using this yaml file k create -f pod.yaml
-
Solution
k set image pod/beta bore=nginx:1.6
-
Solution
k get po -A # flag to get pods from all namespaces
-
create a pod named
neon
and imagenginx
it runsenv
command and gets deleted after returning the environment variables.Solution
k run neon --image=nginx -ti --rm -- env # --rm will delete the pod running env command
-
create a
nginx
pod with namedelta
, expose container port 80 for this pod. Run a temporarybusybox
pod, to makewget
request todelta
pod at\
.Solution
# create delta pod k run delta --image=nginx --port=80 # get ip of the delta pod k get po -o wide # this command will return ip details of the pod # create a temp busybox pod with k run temp --image=busybox -ti --rm -- sh # inside the shell run \# wget -qO- ip:80