Kubernetes Architecture Flashcards
Assuming you have a Dockerfile in the directory you are working in, what is the command to build a container image named ‘myapp’ with a tag of ‘v1.0’?
docker build -t myapp:v1.0 .
What is the command to run a docker container in the background (detached)? The container should be called mycontainer and the image is named myapp. Any traffic sent to port 2224 should be forwarded to port 8888 inside the container.
sudo docker run -p 2224:8888 —name mycontainer -d myapp
What is the command to check out what contexts are available?
kubectl config get-contexts
Switch to a context called dev.
kubectl config use-context dev
Use a command to see all the resources you can create.
kubectl api-resources
Issue the command to see all the namespaces within a cluster
kubectl get namespaces
OR
kubectl get ns
Describe the default namespace.
kubectl describe ns default
OR
kubectl describe namespace default
Type out a manifest to create a namespace called test.
—-
apiVersion: v1
kind: Namespace
metadata:
name: test
Create a new namespace from a file called ns-test.yaml.
kubectl create -f ns-test.yaml
Create a namspace called dev from the CLI.
kubectl create ns dev
Write a resource quota manifest. Give it a name of tiny-rq. Give it 1 cpu and 1Gi of memory.
—-
apiVersion: v1
kind: ResourceQuota
metadata:
name: tiny-rq
spec:
hard:
cpu: “1”
memory: 1Gi
Create a resource quota from a manifest called rq-tiny.yaml in the test namespace
kubectl apply -f rq-tiny.yaml -n test
Delete a resource quota named rq-tiny from the test namespace
kubectl delete resourcequota rq-tiny -n test
Show al the pods in the current namespace and sort them by restart count.
kubectl get pods —sort-by=’.status.containerStatuses[0].restartCount’
Show all the services in the current namespace and sort them by name.
kubectl get services —sort-by=.metadata.name