<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Ckad_cheat1</id>
	<title>Ckad cheat1 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Ckad_cheat1"/>
	<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Ckad_cheat1&amp;action=history"/>
	<updated>2026-04-05T17:41:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=Ckad_cheat1&amp;diff=5500&amp;oldid=prev</id>
		<title>Busk: Created page with &quot;``` # Good Links http://www.yamllint.com/ https://youtu.be/02AA5JRFn5w  ######################################### minikube ######################################### minikube s...&quot;</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Ckad_cheat1&amp;diff=5500&amp;oldid=prev"/>
		<updated>2025-02-12T02:42:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;``` # Good Links http://www.yamllint.com/ https://youtu.be/02AA5JRFn5w  ######################################### minikube ######################################### minikube s...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;```&lt;br /&gt;
# Good Links&lt;br /&gt;
http://www.yamllint.com/&lt;br /&gt;
https://youtu.be/02AA5JRFn5w&lt;br /&gt;
&lt;br /&gt;
#########################################&lt;br /&gt;
minikube&lt;br /&gt;
#########################################&lt;br /&gt;
minikube start&lt;br /&gt;
minikube status&lt;br /&gt;
minikube stop&lt;br /&gt;
# To login to minikube VM from cmd prompt&lt;br /&gt;
minikube ssh&lt;br /&gt;
# Credentials for minikube VM: docker / tcuser&lt;br /&gt;
# Below command will give you kubernetes control plane version (server) and kubectl version (client)&lt;br /&gt;
kubectl version&lt;br /&gt;
# To upgrade kubernetes version&lt;br /&gt;
minikube start --kubernetes-version=v1.20.0&lt;br /&gt;
https://github.com/kubernetes/minikube/releases&lt;br /&gt;
https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows&lt;br /&gt;
https://www.youtube.com/watch?v=ppgrKs1FNJE&lt;br /&gt;
&lt;br /&gt;
###############################&lt;br /&gt;
kubectl&lt;br /&gt;
###############################&lt;br /&gt;
&lt;br /&gt;
kubectl &amp;lt;command&amp;gt; --help&lt;br /&gt;
kubectl rollout --help&lt;br /&gt;
kubectl explain object.sub-object&lt;br /&gt;
e.g kubectl explain pod.spec.containers&lt;br /&gt;
e.g kubectl explain deploy &lt;br /&gt;
e.g kubectl explain pod.spec.containers --recursive &lt;br /&gt;
&lt;br /&gt;
alias k=kubectl&lt;br /&gt;
# --dry-run flag can be appended to run or create commands (imperative commands)&lt;br /&gt;
# While using kubectl apply can be harder to debug since it's not as explicit, we often use it instead of kubectl create and kubectl replace.&lt;br /&gt;
&lt;br /&gt;
####################&lt;br /&gt;
Node&lt;br /&gt;
####################&lt;br /&gt;
&lt;br /&gt;
kubectl get no&lt;br /&gt;
kubectl get no -o wide&lt;br /&gt;
kubectl describe no &amp;lt;node-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################&lt;br /&gt;
Pod&lt;br /&gt;
#####################################&lt;br /&gt;
kubectl get po&lt;br /&gt;
kubectl get po -o wide &lt;br /&gt;
kubectl get po &amp;lt;pod name&amp;gt; -o yaml # output in yaml format&lt;br /&gt;
kubectl get po &amp;lt;pod name&amp;gt; -o json # output in json format&lt;br /&gt;
kubectl describe po &amp;lt;pod name&amp;gt;&lt;br /&gt;
kubectl delete po &amp;lt;pod name&amp;gt;&lt;br /&gt;
kubectl delete po --all # deletes all pods&lt;br /&gt;
kubectl apply -f &amp;lt;pod.yaml&amp;gt; -n &amp;lt;namespace-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# If you are not given a pod definition file but a pod, you may extract the definition to a file using the below command.&lt;br /&gt;
# Then edit the file to make the necessary changes, delete and re-create the pod.&lt;br /&gt;
kubectl get po &amp;lt;pod-name&amp;gt; -o yaml &amp;gt; pod.yaml&lt;br /&gt;
vi pod.yaml&lt;br /&gt;
kubectl delete po &amp;lt;pod-name&amp;gt;&lt;br /&gt;
kubectl apply -f pod.yaml&lt;br /&gt;
&lt;br /&gt;
# To edit pod properties&lt;br /&gt;
kubectl edit po &amp;lt;pod-name&amp;gt; # opens in vi editor&lt;br /&gt;
&lt;br /&gt;
kubectl run nginx --image=nginx --dry-run=client -o yaml &amp;gt; pod.yaml&lt;br /&gt;
&lt;br /&gt;
# To execute a command inside a running container in the pod&lt;br /&gt;
&lt;br /&gt;
kubectl exec [POD] -- [COMMAND]&lt;br /&gt;
kubectl exec nginx -- ls /&lt;br /&gt;
kubectl exec -it nginx -- /bin/sh # Interactive mode. Get a shell to the container running in your Pod&lt;br /&gt;
kubectl exec -it web -c nginx -- /bin/bash &lt;br /&gt;
&lt;br /&gt;
# In a multicontainer pod, containers are created and destroyed together. &lt;br /&gt;
&lt;br /&gt;
# Just like containers, initContainers is a property under spec and it has same sub properties like name, image etc.&lt;br /&gt;
&lt;br /&gt;
# Note: kubectl run command creates the pod and not deployment.&lt;br /&gt;
# There is no imperative command like kubectl create po for pod creation.&lt;br /&gt;
&lt;br /&gt;
# name, labels, annotations and namespace are part of metadata.&lt;br /&gt;
# kubectl get po -A  # all pods in all namespaces&lt;br /&gt;
# kubectl get events -A | grep error # all events in all namespaces with errors&lt;br /&gt;
# Pods have a property called restartPolicy whose values can be Always, Never or OnFailure.&lt;br /&gt;
  Default value is Always.&lt;br /&gt;
&lt;br /&gt;
#############################&lt;br /&gt;
commands and arguments&lt;br /&gt;
#############################&lt;br /&gt;
&lt;br /&gt;
# A container only lives as long as the process inside it is alive. If the process inside the container is finished or crashes, the container exits.&lt;br /&gt;
# When you specify the command in JSON array format, the first element in the array should be executable. e.g command: [&amp;quot;sleep&amp;quot;,&amp;quot;4800&amp;quot;]&lt;br /&gt;
# To define a command, include the command field in configuration file.&lt;br /&gt;
# To define arguments for the command, include the args field in configuration file.&lt;br /&gt;
# The command and arguments that you define in the pod configuration file override the default command and arguments provided by the container image.&lt;br /&gt;
# If you define args, but do not define a command, the default command is used with your new arguments.&lt;br /&gt;
# In a docker file, cmd provides default argument to entrypoint instruction.&lt;br /&gt;
# command replaces the image's ENTRYPOINT instruction, the command that is executed to start your container.&lt;br /&gt;
# args replaces the image's CMD instruction. This list of arguments is passed to the command specified in the previous field.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Example1:&lt;br /&gt;
spec:&lt;br /&gt;
  containers:&lt;br /&gt;
  - name: command-demo-container&lt;br /&gt;
    image: debian&lt;br /&gt;
    command: [&amp;quot;printenv&amp;quot;]&lt;br /&gt;
    args: [&amp;quot;HOSTNAME&amp;quot;, &amp;quot;KUBERNETES_PORT&amp;quot;]&lt;br /&gt;
	&lt;br /&gt;
#       command:&lt;br /&gt;
        - &amp;quot;sleep&amp;quot;&lt;br /&gt;
        - &amp;quot;5000&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
# Example3: To run your command in a shell&lt;br /&gt;
command: [&amp;quot;/bin/sh&amp;quot;]&lt;br /&gt;
args: [&amp;quot;-c&amp;quot;, &amp;quot;while true; do echo hello; sleep 10;done&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
# Example4: &lt;br /&gt;
command: [&amp;quot;sleep&amp;quot;,&amp;quot;5000&amp;quot;]	&lt;br /&gt;
&lt;br /&gt;
# Example7:&lt;br /&gt;
command: [&amp;quot;ls&amp;quot;, &amp;quot;index.html&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Note: Enter the command as is in a shell form. Or in a JSON array format (Preferred). In a JSON array format, the first element should be executable.&lt;br /&gt;
&lt;br /&gt;
# &lt;br /&gt;
cat Dockerfile2&lt;br /&gt;
FROM python:3.6-alpine&lt;br /&gt;
RUN pip install flask&lt;br /&gt;
COPY . /opt/&lt;br /&gt;
EXPOSE 8080&lt;br /&gt;
WORKDIR /opt&lt;br /&gt;
ENTRYPOINT [&amp;quot;python&amp;quot;, &amp;quot;app.py&amp;quot;]&lt;br /&gt;
CMD [&amp;quot;--color&amp;quot;, &amp;quot;red&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
On container startup, the following command would run:&lt;br /&gt;
python app.py --color red&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cat Dockerfile&lt;br /&gt;
FROM python:3.6-alpine&lt;br /&gt;
RUN pip install flask&lt;br /&gt;
COPY . /opt/&lt;br /&gt;
EXPOSE 8080&lt;br /&gt;
WORKDIR /opt&lt;br /&gt;
ENTRYPOINT [&amp;quot;python&amp;quot;, &amp;quot;app.py&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
On container startup, the following command would run:&lt;br /&gt;
python app.py &lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
If you supply a command but no args for a Container, only the supplied command is used. &lt;br /&gt;
The default ENTRYPOINT and the default CMD defined in the Docker image are ignored.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
If you supply a command and args, the default ENTRYPOINT and the default CMD defined in the Docker image are ignored. &lt;br /&gt;
Your command is run with your args.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
If you supply only args for a Container, the default Entrypoint defined in the Docker image is run with the args that you supplied.&lt;br /&gt;
For more details, you can refer to this test:&lt;br /&gt;
https://kodekloud.com/courses/certified-kubernetes-administrator-with-practice-tests-labs/lectures/12038798&lt;br /&gt;
&lt;br /&gt;
###################################&lt;br /&gt;
replicaset&lt;br /&gt;
###################################&lt;br /&gt;
kubectl apply -f &amp;lt;replicaset-definition.yaml&amp;gt;&lt;br /&gt;
kubectl get rs&lt;br /&gt;
kubectl get rs -o wide&lt;br /&gt;
kubectl delete rs &amp;lt;replicaset-name&amp;gt;&lt;br /&gt;
kubectl scale rs &amp;lt;&amp;gt; --replicas=6 &lt;br /&gt;
or&lt;br /&gt;
kubectl edit rs &amp;lt;replicaset-name&amp;gt;&lt;br /&gt;
kubectl describe rs &amp;lt;replicaset-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# There are 2 ways to edit a rs.&lt;br /&gt;
Either delete and re-create the ReplicaSet or &lt;br /&gt;
Update the existing ReplicaSet and then delete all PODs, so new ones with the correct image will be created.&lt;br /&gt;
&lt;br /&gt;
kubectl edit rs &amp;lt;rs-name&amp;gt;&lt;br /&gt;
kubectl delete po &amp;lt;rs-po-name&amp;gt; # Delete all pods under rs.&lt;br /&gt;
&lt;br /&gt;
kubectl get rs &amp;lt;rs-name&amp;gt; -o yaml &amp;gt; rs.yaml&lt;br /&gt;
vi rs.yaml&lt;br /&gt;
kubectl apply -f rs.yaml&lt;br /&gt;
kubectl delete po &amp;lt;rs-po-name&amp;gt; # Delete all pods under rs.&lt;br /&gt;
&lt;br /&gt;
# The value for labels in spec.selector clause and spec.template.metadata should match in replicaset.&lt;br /&gt;
&lt;br /&gt;
# To see all the objects at once in current namespace&lt;br /&gt;
kubectl get all&lt;br /&gt;
&lt;br /&gt;
# Replicaset has a template.&lt;br /&gt;
&lt;br /&gt;
##########################&lt;br /&gt;
Deployments&lt;br /&gt;
##########################&lt;br /&gt;
kubectl create deploy nginx --image=nginx --replicas=2&lt;br /&gt;
kubectl get deploy&lt;br /&gt;
kubectl get deploy -n &amp;lt;namespace-name&amp;gt; &lt;br /&gt;
kubectl get deploy &amp;lt;deployment-name&amp;gt;&lt;br /&gt;
kubectl get deploy &amp;lt;deployment-name&amp;gt; -o yaml | more&lt;br /&gt;
kubectl get deploy -o wide&lt;br /&gt;
kubectl describe deploy &amp;lt;deployment-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
kubectl apply -f deploy.yaml &lt;br /&gt;
kubectl apply -f deploy.yaml --record # to record the change-cause in revision history&lt;br /&gt;
kubectl rollout status deploy &amp;lt;deployment-name&amp;gt;&lt;br /&gt;
kubectl rollout history deploy &amp;lt;deployment-name&amp;gt;&lt;br /&gt;
kubectl rollout history deploy nginx --revision=2 # to get detailed history for a specific revision.&lt;br /&gt;
kubectl rollout undo deploy &amp;lt;deployment-name&amp;gt; &lt;br /&gt;
kubectl rollout undo deploy &amp;lt;deployment-name&amp;gt; --to-revision=1&lt;br /&gt;
#Pause the Deployment to apply multiple fixes and then resume it to start a new rollout.&lt;br /&gt;
#When the deployment is paused, no changes are recorded to revision history.&lt;br /&gt;
kubectl rollout pause deploy &amp;lt;deployment-name&amp;gt; &lt;br /&gt;
kubectl rollout resume deploy &amp;lt;deployment-name&amp;gt;&lt;br /&gt;
kubectl delete deploy &amp;lt;deployment-name&amp;gt;&lt;br /&gt;
# The value for labels in selector clause and pod template should match in deployment.&lt;br /&gt;
kubectl create deploy nginx --image=nginx --dry-run=client -o yaml &amp;gt; deploy.yaml&lt;br /&gt;
kubectl scale deploy &amp;lt;deployment-name&amp;gt; --replicas=3 # To scale up / down a deployment. Not recorded in revision history.&lt;br /&gt;
kubectl create deploy &amp;lt;deployment-name&amp;gt; --image=redis -n &amp;lt;namespace-name&amp;gt;&lt;br /&gt;
# RollingUpdateStrategy in deployment details define upto how many pods can be down/up during the update at a time.&lt;br /&gt;
&lt;br /&gt;
kubectl edit deploy &amp;lt;deployment-name&amp;gt; -n &amp;lt;namespace-name&amp;gt; # to make changes to a running deployment. Another option is to update the yaml file and apply it.&lt;br /&gt;
&lt;br /&gt;
# Properties to remember&lt;br /&gt;
spec.strategy.type==RollingUpdate|Recreate&lt;br /&gt;
spec.strategy.rollingUpdate.maxUnavailable&lt;br /&gt;
spec.strategy.rollingUpdate.maxSurge&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
  strategy:&lt;br /&gt;
    type: RollingUpdate&lt;br /&gt;
    rollingUpdate:&lt;br /&gt;
      maxUnavailable: 0&lt;br /&gt;
      maxSurge: 1&lt;br /&gt;
	  &lt;br /&gt;
# keys follow camel case naming convention. values follow initials in upper case convention.&lt;br /&gt;
&lt;br /&gt;
# Deployment has a template.&lt;br /&gt;
&lt;br /&gt;
# Whenever you create a new deployment or update images in an existing deployment, a rollout is triggered. &lt;br /&gt;
# A new rollout creates a new deployment revision.&lt;br /&gt;
&lt;br /&gt;
# You can locate a problematic deployment in cluster by checking the READY status for deployments. The no of containers running will be less than desired.&lt;br /&gt;
# A deployment automatically creates a replicaset which in turn creates pods.&lt;br /&gt;
&lt;br /&gt;
#########################&lt;br /&gt;
HorizontalPodAutoScaler&lt;br /&gt;
#########################&lt;br /&gt;
&lt;br /&gt;
kubectl get hpa&lt;br /&gt;
kubectl delete hpa &amp;lt;hpa-name&amp;gt;&lt;br /&gt;
kubectl autoscale deploy nginx --min=5 --max=10 --cpu-percent=80&lt;br /&gt;
&lt;br /&gt;
####################&lt;br /&gt;
service&lt;br /&gt;
####################&lt;br /&gt;
kubectl apply -f &amp;lt;svc.yaml&amp;gt;&lt;br /&gt;
kubectl get svc&lt;br /&gt;
kubectl describe svc &amp;lt;service-name&amp;gt; # to get to know about port, target port etc.&lt;br /&gt;
kubectl delete svc &amp;lt;service-name&amp;gt;&lt;br /&gt;
# Copy the label from template section of deployment and paste it under selector section of service.&lt;br /&gt;
# If you are creating a frontend service for enabling external access to users, set the type to NodePort.&lt;br /&gt;
# If you are tasked to create a service to enable the frontend pods to access a backend set of pods, set the type to ClusterIP.&lt;br /&gt;
# In ClusterIP, port refers to port on service aka port exposed by service and targetPort refers to port on pod (container) aka port exposed by container.&lt;br /&gt;
# LoadBalancer service type only works with supported cloud platforms like GCP, AWS, Azure. In an unsupported environment like VirtualBox, it would have the same effect as setting it to NodePort.&lt;br /&gt;
kubectl expose pod redis --port=6379 --name=redis-service --type=ClusterIP --dry-run=client -o yaml &amp;gt; svc.yaml&lt;br /&gt;
kubectl expose pod nginx --port=80 --target-port=8080 --name=nginx-service --type=NodePort --dry-run=client -o yaml &amp;gt; svc.yaml&lt;br /&gt;
kubectl expose deploy &amp;lt;deploy-name&amp;gt; --port=&amp;lt;&amp;gt; &lt;br /&gt;
# Note: We can't set nodePort using imperative command. So for node port services, use yaml instead of command.&lt;br /&gt;
&lt;br /&gt;
# To get endpoints for a service&lt;br /&gt;
kubectl get ep &amp;lt;svc-name&amp;gt; # endpoint is nothing but the Pods to which the service is linked. It contains ip of pod and port.&lt;br /&gt;
kubectl edit svc &amp;lt;svc-name&amp;gt; # to edit a service&lt;br /&gt;
# services, deployments, replicasets and network policy have selector property under spec for selecting pods using labels.&lt;br /&gt;
# There are 3 ports involved - node port, port and target port. node port is port on the node.&lt;br /&gt;
  port is port on service. target port is port on pod. port is mandatory. &lt;br /&gt;
  IP of service is known as Cluster-IP (internal ip).&lt;br /&gt;
  Service can be accessed by pods using Cluster-IP or service name.&lt;br /&gt;
&lt;br /&gt;
################ &lt;br /&gt;
namespace&lt;br /&gt;
################&lt;br /&gt;
kubectl get ns&lt;br /&gt;
kubectl create ns &amp;lt;namespace-name&amp;gt;&lt;br /&gt;
kubectl apply -f &amp;lt;namespace.yaml&amp;gt;&lt;br /&gt;
kubectl get po -n kube-system&lt;br /&gt;
kubectl describe ns &amp;lt;namespace-name&amp;gt;&lt;br /&gt;
kubectl delete ns &amp;lt;namespace-name&amp;gt; &lt;br /&gt;
# To switch to a namespace permanently&lt;br /&gt;
kubectl config set-context $(kubectl config current-context) --namespace=dev&lt;br /&gt;
# To view pods in all namespaces&lt;br /&gt;
kubectl get po -A&lt;br /&gt;
# To create a pod in a specific namespace&lt;br /&gt;
kubectl run redis --image=redis -n &amp;lt;namespace-name&amp;gt; &lt;br /&gt;
kubectl exec -it &amp;lt;pod-name&amp;gt; -n &amp;lt;namespace-name&amp;gt; -- sh&lt;br /&gt;
kubectl get all -A # To check all objects in all namespaces&lt;br /&gt;
kubectl create ns &amp;lt;namespace-name&amp;gt; --dry-run=client -o yaml &lt;br /&gt;
&lt;br /&gt;
######################&lt;br /&gt;
ConfigMap&lt;br /&gt;
######################&lt;br /&gt;
kubectl get cm&lt;br /&gt;
kubectl describe cm &amp;lt;cm-name&amp;gt; # to check key-value pairs in config map&lt;br /&gt;
kubectl create cm &amp;lt;cm-name&amp;gt; --from-file=&amp;lt;path to file&amp;gt; # colon or equals to as delimiter between keys and values&lt;br /&gt;
kubectl create cm &amp;lt;cm-name&amp;gt; --from-file=&amp;lt;directory&amp;gt;&lt;br /&gt;
kubectl create cm &amp;lt;cm-name&amp;gt; --from-literal=&amp;lt;key1&amp;gt;=&amp;lt;value1&amp;gt; --from-literal=&amp;lt;key2&amp;gt;=&amp;lt;value2&amp;gt;&lt;br /&gt;
kubectl apply -f cm.yaml&lt;br /&gt;
&lt;br /&gt;
# Properties to remember:&lt;br /&gt;
configmapkeyref / env, configMapRef / envFrom, volume&lt;br /&gt;
&lt;br /&gt;
# Pods can consume ConfigMaps as environment variables or as configuration files in a volume mounted on one or more of its containers for the application to read.&lt;br /&gt;
  When ConfigMap is created from a file (kubectl create cm &amp;lt;cm name&amp;gt; --from-file= ) and when that ConfigMap is mounted as volume, &lt;br /&gt;
  then the entire file is available at mount point for the pod.&lt;br /&gt;
&lt;br /&gt;
# Injected into the Pod.&lt;br /&gt;
&lt;br /&gt;
######################&lt;br /&gt;
Secrets&lt;br /&gt;
######################&lt;br /&gt;
kubectl get secrets&lt;br /&gt;
kubectl describe secret &amp;lt;secret-name&amp;gt; # This shows the attributes in secret but hides the values.&lt;br /&gt;
kubectl get secret &amp;lt;secret-name&amp;gt; -o yaml # To view the values (encoded).&lt;br /&gt;
# If you enter the pod where secret is injected, you can see decoded values.&lt;br /&gt;
kubectl create secret generic &amp;lt;secret-name&amp;gt; --from-literal=&amp;lt;key1&amp;gt;=&amp;lt;value1&amp;gt; --from-literal=&amp;lt;key2&amp;gt;=&amp;lt;value2&amp;gt;&lt;br /&gt;
kubectl create secret generic &amp;lt;secret-name&amp;gt; --from-file=&amp;lt;path to file&amp;gt; # colon or equals to as delimiter between keys and values&lt;br /&gt;
&lt;br /&gt;
# Properties to remember:&lt;br /&gt;
secretkeyref / env, secretref / envFrom, volume&lt;br /&gt;
&lt;br /&gt;
# A secret can be injected into a pod as file in a volume mounted on one or more of its containers or as container environment variables.&lt;br /&gt;
&lt;br /&gt;
# opaque and service-account-token are secret types.&lt;br /&gt;
&lt;br /&gt;
# For encoding, decoding&lt;br /&gt;
echo -n 'string' | base64&lt;br /&gt;
echo -n 'encoded string' | base64 --decode&lt;br /&gt;
&lt;br /&gt;
# While creating secret with the declarative approach (yaml), you must specify the secret key and value in encoded format.&lt;br /&gt;
# When we create secret using imperative approach, secret keys and values are encoded on their own (and decoded as well).&lt;br /&gt;
&lt;br /&gt;
# Injected into the Pod.&lt;br /&gt;
&lt;br /&gt;
# https://www.udemy.com/course/certified-kubernetes-administrator-with-practice-tests/learn/lecture/14827414#overview&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
######################&lt;br /&gt;
Service Account&lt;br /&gt;
######################&lt;br /&gt;
&lt;br /&gt;
kubectl create sa &amp;lt;sa-name&amp;gt;&lt;br /&gt;
kubectl get sa&lt;br /&gt;
kubectl describe sa &amp;lt;sa-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# To fetch token from service account&lt;br /&gt;
kubectl describe sa &amp;lt;sa-name&amp;gt; # gives secret name&lt;br /&gt;
kubectl describe secret &amp;lt;secret-name&amp;gt; # gives token stored in secret&lt;br /&gt;
&lt;br /&gt;
# Create an nginx pod that uses 'myuser' as a service account&lt;br /&gt;
kubectl run nginx --image=nginx --serviceaccount=myuser --dry-run=client -o yaml &amp;gt; pod.yaml&lt;br /&gt;
kubectl apply -f pod.yaml&lt;br /&gt;
&lt;br /&gt;
# When we use service account inside the pod, the secret for that service account is mounted as volume inside the pod.&lt;br /&gt;
&lt;br /&gt;
# Property to remember: spec -&amp;gt; serviceAccountName # set at pod level&lt;br /&gt;
# Injected into the Pod.&lt;br /&gt;
# For a deployment, can set service account in pod template.&lt;br /&gt;
&lt;br /&gt;
# A user makes a request to API server through kubectl using user account.&lt;br /&gt;
# A process running inside a container makes a request to API server using service account.&lt;br /&gt;
  A service account just like user account has certain permissions.&lt;br /&gt;
&lt;br /&gt;
######################&lt;br /&gt;
Taints (on nodes) and Tolerations (on pods)&lt;br /&gt;
######################&lt;br /&gt;
# To check taints on a node&lt;br /&gt;
kubectl describe no &amp;lt;node01&amp;gt; | grep -i &amp;quot;taint&amp;quot;&lt;br /&gt;
# To create a taint on node01 with key of 'spray', value of 'mortein' and effect of 'NoSchedule'.&lt;br /&gt;
# Taint effect defines what happens to pods that do not tolerate this taint. &lt;br /&gt;
# Values for taint effect are NoSchedule, NoExecute and PreferNoSchedule.&lt;br /&gt;
kubectl taint no node01 spray=mortein:NoSchedule &lt;br /&gt;
# The property tolerations under spec has properties like key, operator, value and effect and their values come inside &amp;quot;&amp;quot;.&lt;br /&gt;
# Remove the taint on master, which currently has the taint effect of NoSchedule&lt;br /&gt;
kubectl taint no master node-role.kubernetes.io/master:NoSchedule-&lt;br /&gt;
# Remove from node 'foo' all the taints with key 'dedicated'&lt;br /&gt;
kubectl taint no foo dedicated-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Logging&lt;br /&gt;
#######################&lt;br /&gt;
# The standard output of a container can be seen using the logs command.&lt;br /&gt;
kubectl logs -f &amp;lt;pod-name&amp;gt; &amp;lt;container-name&amp;gt; # follow the logs &lt;br /&gt;
kubectl logs &amp;lt;pod-name&amp;gt; --previous # dump pod logs for a previous instantiation of a container&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Monitoring&lt;br /&gt;
#######################&lt;br /&gt;
&lt;br /&gt;
kubectl top no&lt;br /&gt;
kubectl top po&lt;br /&gt;
# To get name of pod that is consuming most CPU.&lt;br /&gt;
kubectl top pod --namespace=default | head -2 | tail -1 | cut -d &amp;quot; &amp;quot; -f1&lt;br /&gt;
kubectl top po --sort-by cpu --no-headers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Jobs&lt;br /&gt;
#######################&lt;br /&gt;
kubectl create job busybox --image=busybox -- /bin/sh -c &amp;quot;echo hello;sleep 30;echo world&amp;quot;&lt;br /&gt;
kubectl get jobs&lt;br /&gt;
kubectl logs busybox-qhcnx # pod under job&lt;br /&gt;
kubectl delete job &amp;lt;job-name&amp;gt;&lt;br /&gt;
# In case of pods, default value for restart property is Always and in case of jobs, default value for restart property is Never.&lt;br /&gt;
# Job has pod template. Job has 2 spec sections - one for job and one for pod (in order).&lt;br /&gt;
# A pod created by a job must have its restartPolicy be OnFailure or Never. If the restartPolicy is OnFailure, a failed container will be re-run on the same pod. If the restartPolicy is Never, a failed container will be re-run on a new pod.&lt;br /&gt;
&lt;br /&gt;
# Job properties to remember: completions, backoffLimit, parallelism, activeDeadlineSeconds, restartPolicy.&lt;br /&gt;
# By default, pods in a job are created one after the other (sequence). Second pod is created only after the first one is finished.&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
CronJobs&lt;br /&gt;
#######################&lt;br /&gt;
&lt;br /&gt;
kubectl get cj&lt;br /&gt;
# Create a cron job with image busybox that runs on a schedule and writes to standard output&lt;br /&gt;
kubectl create cj busybox --image=busybox --schedule=&amp;quot;*/1 * * * *&amp;quot; -- /bin/sh -c &amp;quot;date; echo Hello from Kubernetes cluster&amp;quot; &lt;br /&gt;
# In a cronjob, there are 2 templates - one for job and another for pod.&lt;br /&gt;
# In a cronjob, there are 3 spec sections - one for cronjob, one for job and one for pod (in order).&lt;br /&gt;
# Properties to remember: spec -&amp;gt; successfulJobHistoryLimit, spec -&amp;gt; failedJobHistoryLimit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Ingress&lt;br /&gt;
#######################&lt;br /&gt;
kubectl get ingress  # To check details about Ingress Resource&lt;br /&gt;
kubectl describe ingress &amp;lt;&amp;gt;&lt;br /&gt;
kubectl edit ingress &amp;lt;ingress name&amp;gt; &lt;br /&gt;
kubectl apply -f &amp;lt;ingress.yaml&amp;gt;&lt;br /&gt;
# Ingress setup requires an ingress controller (deployment), a node port ingress service (for accessing ingress controller from outside the cluster) and a config map.&lt;br /&gt;
  They all are in same namespace.&lt;br /&gt;
# The ingress resource (type is ingress), application(deployment) and service (for accessing deployment) are in different namespace.&lt;br /&gt;
# In order for the Ingress resource to work, the cluster must have an ingress controller running.&lt;br /&gt;
  Unlike other types of controllers which run as part of the kube-controller-manager binary, Ingress controllers are not started automatically with a cluster.&lt;br /&gt;
  Kubernetes supports AWS, GCE and nginx ingress controllers.&lt;br /&gt;
# Ingress resource defines rules and Ingress controller fulfills those rules.&lt;br /&gt;
&lt;br /&gt;
URL: https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/&lt;br /&gt;
     https://medium.com/@Oskarr3/setting-up-ingress-on-minikube-6ae825e98f82&lt;br /&gt;
	 &lt;br /&gt;
#######################&lt;br /&gt;
Volumes&lt;br /&gt;
#######################&lt;br /&gt;
kubectl get pv&lt;br /&gt;
kubectl get pvc&lt;br /&gt;
kubectl delete pvc &amp;lt;pvc-name&amp;gt;&lt;br /&gt;
kubectl delete pv &amp;lt;pv-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Properties to remember:&lt;br /&gt;
spec -&amp;gt; volumes -&amp;gt; name: &lt;br /&gt;
                   emptyDir: {}&lt;br /&gt;
				   &lt;br /&gt;
spec -&amp;gt; containers -&amp;gt; volumeMounts -&amp;gt; name:&lt;br /&gt;
                                      mountPath: &lt;br /&gt;
									  &lt;br /&gt;
&lt;br /&gt;
spec -&amp;gt; volumes -&amp;gt; name: &lt;br /&gt;
                   hostPath -&amp;gt; type: Directory&lt;br /&gt;
				               path: &lt;br /&gt;
				   &lt;br /&gt;
spec -&amp;gt; containers -&amp;gt; volumeMounts -&amp;gt; name:&lt;br /&gt;
                                      mountPath:	&lt;br /&gt;
&lt;br /&gt;
# pvc is to be injected into the pod. Pods use pvc as volume and pod's containers mount that volume.&lt;br /&gt;
# pvc remains in pending state until it is bound to a pv.&lt;br /&gt;
# storageClassName and accessModes must match between pv and pvc. If no storage class is specified in PV, then there should be no storage class in PVC as well.&lt;br /&gt;
  storage size must also be in range.			&lt;br /&gt;
# persistent volumes have reclaim policy whose values are recycle (data in volume to be purged), retain (data and volume to be retained) and delete (volume to be deleted).&lt;br /&gt;
  reclaim policy is invoked when pvc is deleted. once pvc is deleted, future of pv depends on reclaim policy.&lt;br /&gt;
# property is spec -&amp;gt; persistentVolumeReclaimPolicy.		&lt;br /&gt;
# PVs use labels and PVCs use selectors for selecting the PVs.		&lt;br /&gt;
# PVs are cluster wide and PVCs are namespaced.	  &lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Labels&lt;br /&gt;
#######################&lt;br /&gt;
kubectl get po|deploy|all --show-labels&lt;br /&gt;
kubectl label po nginx env=lab # Add a label to a pod&lt;br /&gt;
kubectl label deploy my-webapp tier=frontend # Add a label to a deployment&lt;br /&gt;
kubectl label no node01 size=large # To label nodes&lt;br /&gt;
&lt;br /&gt;
kubectl label po nginx env- # Remove the label&lt;br /&gt;
kubectl label po nginx env=lab1 --overwrite # to overwrite a label&lt;br /&gt;
# Duplicate keys can't be used in labels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Selectors&lt;br /&gt;
#######################&lt;br /&gt;
kubectl get po --selector=app=App1&lt;br /&gt;
kubectl get po --selector=app!=App1&lt;br /&gt;
kubectl get all --selector=env=prod&lt;br /&gt;
kubectl get po --selector=env=prod,bu=finance,tier=frontend # equivalent of &amp;amp;&amp;amp; in programming languages&lt;br /&gt;
&lt;br /&gt;
######################&lt;br /&gt;
Environment Variables&lt;br /&gt;
#######################&lt;br /&gt;
kubectl run nginx --image=nginx --env=app=web # Create an nginx pod and set an environment variable &lt;br /&gt;
# env and envFrom property is an array.&lt;br /&gt;
# env property takes two properties - name and value. value takes only string and will always come in double quotes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Annotations&lt;br /&gt;
#######################&lt;br /&gt;
kubectl annotate po nginx desc=&amp;quot;Hello World&amp;quot;&lt;br /&gt;
kubectl annotate po nginx author=Avnish&lt;br /&gt;
kubectl annotate po nginx desc- # Remove this annotation from the pod&lt;br /&gt;
# Duplicate keys in annotations are not allowed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Security Context&lt;br /&gt;
#######################&lt;br /&gt;
# Properties to remember: securityContext -&amp;gt; runAsUser and securityContext -&amp;gt; capabilities -&amp;gt; add&lt;br /&gt;
Note: securityContext -&amp;gt; capabilities -&amp;gt; add property takes array as value. For example:	&lt;br /&gt;
add:&lt;br /&gt;
- &amp;quot;NET_ADMIN&amp;quot;&lt;br /&gt;
- &amp;quot;SYS_TIME&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
add: [&amp;quot;NET_ADMIN&amp;quot;, &amp;quot;SYS_TIME&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Note: runAsUser takes only numeric values.&lt;br /&gt;
&lt;br /&gt;
# Can be set at pod level as well as container level. &lt;br /&gt;
If you configure at pod level, the security settings will carry over to all the containers with in the pod.&lt;br /&gt;
If you configure at both pod level and container level, the settings on container will override the settings on pod.&lt;br /&gt;
&lt;br /&gt;
#######################################&lt;br /&gt;
requests and limits | Resource Quotas&lt;br /&gt;
#######################################&lt;br /&gt;
# We can set quotas for the total amount of memory and cpu that can be consumed by all the containers running in a namespace.&lt;br /&gt;
  Quotas are specified using ResourceQuota object.&lt;br /&gt;
# Once ResourceQuota is there, Every Container must have a memory request, memory limit, cpu request, and cpu limit.&lt;br /&gt;
# We can configure default memory requests and limits for a namespace using LimitRange object in namespace. &lt;br /&gt;
  If a Container is created in a namespace that has a default memory limit, and the Container does not specify its own memory limit, then the Container is assigned the default memory limit.&lt;br /&gt;
# We can configure default CPU requests and limits for a namespace using LimitRange object. &lt;br /&gt;
  If a Container is created in a namespace that has a default CPU limit, and the Container does not specify its own CPU limit, then the Container is assigned the default CPU limit.&lt;br /&gt;
# Requests and Limits can be set for each of the containers in the Pod. If not set, they take default values.&lt;br /&gt;
kubectl run nginx --image=nginx --requests=&amp;quot;cpu=100m,memory=256Mi&amp;quot; --limits=&amp;quot;cpu=200m,memory=512Mi&amp;quot;&lt;br /&gt;
# cpu can also be specified as 1,2,0.1 etc. Here 1 count of cpu is equivalent to 1 vCPU in AWS or 1 GCP core. 0.1 count = 100m where m is milli.&lt;br /&gt;
  It can go as low as 1m.&lt;br /&gt;
# minimum usage through requests and maximum usage through limits.&lt;br /&gt;
  Requests are what the container is guaranteed to get. If a container requests a resource, Kubernetes will only schedule it on a node that can give it that resource. &lt;br /&gt;
  Limits, on the other hand, make sure a container never goes above a certain value. The container is only allowed to go up to the limit, and then it is restricted.&lt;br /&gt;
# Resource quota is specified at namespace level. Resource limits (requests and limits) are specified at container level.&lt;br /&gt;
# If a pod tries to exceed resources beyond its specified limit, then in case of cpu, Kubernetes throttles cpu. &lt;br /&gt;
  A container can't use more cpu resources than its limit. But a container can use more memory resources than its limit.&lt;br /&gt;
  If a pod tries to use more memory resources than its limit constantly, pod will be terminated.&lt;br /&gt;
kubectl get quota&lt;br /&gt;
kubectl describe quota -n &amp;lt;namespace-name&amp;gt;&lt;br /&gt;
# Good explaination in Golden book.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#######################	 &lt;br /&gt;
Network Policy&lt;br /&gt;
#######################&lt;br /&gt;
kubectl get netpol&lt;br /&gt;
kubectl describe netpol &amp;lt;name&amp;gt;&lt;br /&gt;
Note: While creating network policy, make sure that not only network policy is applied to the correct object but also that it allows access from (ingress) / to correct object (egress).&lt;br /&gt;
labels and selectors are used.&lt;br /&gt;
An empty podSelector selects all pods in the namespace.&lt;br /&gt;
&lt;br /&gt;
#######################&lt;br /&gt;
Probes&lt;br /&gt;
#######################&lt;br /&gt;
# Set at the level of containers &lt;br /&gt;
# readinessProbe is to check whether the application is ready.&lt;br /&gt;
# livenessProbe is to check whether the application is live (running).&lt;br /&gt;
&lt;br /&gt;
Properties to remember: &lt;br /&gt;
livenessProbe -&amp;gt; httpGet -&amp;gt; port&lt;br /&gt;
                         -&amp;gt; path&lt;br /&gt;
						&lt;br /&gt;
livenessProbe -&amp;gt; exec -&amp;gt; command&lt;br /&gt;
&lt;br /&gt;
livenessprobe -&amp;gt; tcpSocket -&amp;gt; port &lt;br /&gt;
&lt;br /&gt;
livenessProbe -&amp;gt; initialDelaySeconds&lt;br /&gt;
&lt;br /&gt;
livenessProbe -&amp;gt; PeriodSeconds&lt;br /&gt;
&lt;br /&gt;
livenessProbe -&amp;gt; failureThreshold&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
readinessProbe -&amp;gt; httpGet -&amp;gt; port&lt;br /&gt;
                         -&amp;gt; path&lt;br /&gt;
						&lt;br /&gt;
readinessProbe -&amp;gt; exec -&amp;gt; command&lt;br /&gt;
&lt;br /&gt;
readinessprobe -&amp;gt; tcpSocket -&amp;gt; port &lt;br /&gt;
&lt;br /&gt;
readinessProbe -&amp;gt; initialDelaySeconds&lt;br /&gt;
&lt;br /&gt;
readinessProbe -&amp;gt; PeriodSeconds&lt;br /&gt;
&lt;br /&gt;
readinesProbe -&amp;gt; failureThreshold&lt;br /&gt;
&lt;br /&gt;
#############################################################################################################&lt;br /&gt;
Notes:&lt;br /&gt;
1.) securityContext -&amp;gt; runAsUser is available at pod as well as container level.&lt;br /&gt;
    securityContext -&amp;gt; capabilities -&amp;gt; add only available at container level.&lt;br /&gt;
2.) volumeMounts has properties like name, mountPath and readOnly (true|false)&lt;br /&gt;
4.) Deployment doesn't have good example in kubernetes.io, so remember this:&lt;br /&gt;
spec:&lt;br /&gt;
 replicas: 5&lt;br /&gt;
 strategy: &lt;br /&gt;
  type: RollingUpdate&lt;br /&gt;
  rollingUpdate:&lt;br /&gt;
   maxSurge: 7&lt;br /&gt;
   maxUnavailable: 3&lt;br /&gt;
5.) The labels in pod template and selector clause in deployment must match.&lt;br /&gt;
6.) If you are using a port in readiness probe or liveness probe, then that port must be exposed.&lt;br /&gt;
7.) If unit for cpu request is given as 200m then use that (&amp;quot;200m&amp;quot;). If it is given as .2, then use that (&amp;quot;0.2&amp;quot;)&lt;br /&gt;
8.) name in volumes and volumeMounts must be same.&lt;br /&gt;
9.) env is used with configMapKeyRef. In doc, search by configMapKeyRef. name property of env is used as such. Used to import one key from configmap.&lt;br /&gt;
    envFrom is used with configMapRef. In doc, search by configMapRef. Used to import the entire configmap.&lt;br /&gt;
	When configmap is mounted as volume, then no need to think of env or envFrom. Just think of volumes and volumeMounts.&lt;br /&gt;
10.) env is used with secretKeyRef. In doc, search by secreyKeyRef. name property of env is used as such. Used to import one key from secret.&lt;br /&gt;
     envFrom is used with seretRef. In doc, search by secretRef. used to import the entire secret.&lt;br /&gt;
	 When secret is mounted as volume, then no need to think of env or envFrom. Just think of volumes and volumeMounts. &lt;br /&gt;
11.) To check connectivity, you can use curl or netcat.&lt;br /&gt;
nc -v -w 2 -z ip port&lt;br /&gt;
curl http://ip:port&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
```&lt;/div&gt;</summary>
		<author><name>Busk</name></author>
	</entry>
</feed>