Application Design and Build (20%)
Using the RUN/CREATE command for Pods, Deployments, etc.
The run command allows quick creation of the various high-level execution resources in k8s, and provides speed, which we need for the exam. (NOTE: The use of run to handle various resource creations was updated to instead use the create command as of 1.14)
The specific, underlying resource created from a particular create/run command is based on its ‘generator’.
$ kubectl create deployment nginx --image=nginx #deployment
$ kubectl run nginx --image=nginx --restart=Never #pod
$ kubectl create job nginx --image=nginx #job
$ kubectl create cronjob nginx --image=nginx --schedule="* * * * *" #cronJob
The above is helpful in the exam as speed is important. If the question indicates to ‘create a pod’, use the quick syntax to get a pod going.
Multi-Container Pods
This particular section needs additional detail as these concepts are not covered that well via the tasks provided at kubernetes.io. Actually, the best coverage (for sidecars) is in the concepts section under logging architecture.
-
One or more containers running within a pod for enhancing the main container functionality (logger container, git synchronizer container); These are sidecar container
-
One or more containers running within a pod for accessing external applications/servers (Redis cluster, memcache cluster); These are called ambassador container
-
One or more containers running within a pod to allow access to application running within the container (Monitoring container); These are called as adapter containers-
Concepts -> Logging Architecture
Jobs and CronJobs
Job vs CronJob -> A job runs a pod to a number of successful completions. Cron jobs manage jobs that run at specified intervals and/or repeatedly at a specific point in time, thus they have the ‘schedule’ aspect. The below demonstrates quickly creating a cronjob and then a quick edit to add a command, etc.
$ kubectl run crontest --image=busybox --schedule="*/1 * * * *" --restart=OnFailure --dry-run -o yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
labels:
run: crontest
name: crontest
spec:
schedule: '*/1 * * * *'
jobTemplate:
spec:
template:
spec:
containers:
- image: busybox
name: crontest
command: ["date; echo Hello"]
restartPolicy: OnFailure
You can also redirect (> cron.yaml) the above to a file, edit it to add the container command, and then create the cronjob with the kubectl create:
$ kubectl create -f cron.yaml
State Persistence (Volumes)
This is still one of my weaknesses and the whole PV creation is high dependent on the underlying cloud or file storage technique used. For now, the links provided later in the persistence tasks are best for studying this.
Tasks from Kubernetes Doc
Core Concepts and Kubectl
- Tasks -> Accessing Multiple Clusters
- Tasks -> Accessing Cluster with API
- Tasks -> Port Forwarding
- Tasks -> Shell to Running Container (exec)
Multi-Container Pods
Pod Design (Labels, Selectors, Annotations)
- Concepts -> Assign Pods to Nodes - Selectors
- Concepts -> Annotations
- Concepts -> Labels and Selectors
CRON
- Tasks -> Automated Tasks with Cron Jobs
- Tasks -> Parallel Jobs with Expansions
- Tasks -> Course Parallel Processing with a Work Queue
- Tasks -> Fine Parallel Processsing with a Work Queue