Reference - Kubernetes Commands

 

 Kubernetes Cluster 

Master Node Worker Node
Kube API Server kubelet
etcd  
node controller  
replica controller Container Runtime - Docker

MiniKube 

Download and install Oracle VM Virtualbox

Download kubectl.exe and minikube.exe

Execute: minikube start

downlaod minikube ISO image and configure it automatically for Oracle VM Virtualbox 

[ if issues or errors, you can run " minikube delete" ]

 

Minikube
kubelet
Kube API Server
etcd
node-controller
replica controller
Container Runtime - Docker

 


Pod Template:

apiVersion:
kind:
metadata:

spec:

Sample Pod Template 1:

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
    - name: nginx
      image: nginx

 

Sample Pod Template 2: 

apiVersion: v1
kind: Pod
metadata:
  name: postgres
  labels:
    tier: db-tier
spec:
  containers:
    - name: postgres
      image: postgres

Version: 

kubectl version

 

Get:

# List all pods in ps output format.
  kubectl get pods

# List all pods in ps output format with more information (such as node name).
  kubectl get pods -o wide

# List a single replication controller with specified NAME in ps output format.
  kubectl get replicationcontroller web

# List deployments in JSON output format, in the "v1" version of the "apps" API group:
  kubectl get deployments.v1.apps -o json

# List a single pod in JSON output format.
  kubectl get -o json pod web-pod-13je7

# List a pod identified by type and name specified in "pod.yaml" in JSON output format.
  kubectl get -f pod.yaml -o json

# Return only the phase value of the specified pod.
  kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}

# List all replication controllers and services together in ps output format.
  kubectl get rc,services

# List one or more resources by their type and names.
  kubectl get rc/web service/frontend pods/web-pod-13je7


Deploy a nginx docker container by creating a pod - Download from Docker Hub Repostory.

kubectl run nginx --image nginx

$ kubectl run nginx --image=nginx
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/nginx created

kubectl run nginx --image=nginx --generator=run-pod/v1 #correct way to create a new container from command line. 

kubectl get nodes
kubectl get pods # there should not be any pods for new config
kubectl run nginx --image nginx
kubectl get pods # nginx pod will now display
kubectl describe pods
kubectl get pods -o wide

kubectl delete pods <pod name>

Create: 

kubectl create --save-config
kubectl create -f myfile.yaml

Apply: 

$ kubectl apply -f pod01.yaml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
pod/redis configured

Describe:

kubectl describe nodes
kubectl describe pods
kubectl describe pods <pod-name-id>

Delete: 

kubectl delete pods pod-name-id
kubectl delete pods <pod> --grace-period=0 --force

Error: 

master $ kubectl run nginx --image=nginx
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/nginx created
master $

 


 

kubectl version
kubectl get nodes
kubectl get nodes -o wide
kubectl describe nodes

kubectl get pods
kubectl get pods -o wide
kubectl describe pods
kubectl describe pods <pod-name-id>


kubectl delete pods <pod-name-id>

 


 

Links:

Install Kubernetes offline: 

https://www.centlinux.com/2019/04/install-kubernetes-k8s-offline-on-centos-7.html

Kubernetes Cheatsheet: 

Kubectl:

https://kubernetes.io/docs/reference/kubectl/cheatsheet/

https://kubernetes.io/docs/reference/kubectl/overview/

 

https://training.linuxfoundation.org/wp-content/uploads/2020/01/Important-Tips-CKA-CKAD-01.28.2020.pdf

 

Exam Info: https://medium.com/@pmvk/tips-to-crack-certified-kubernetes-administrator-cka-exam-c949c7a9bea1

Free Course - https://www.udacity.com/course/scalable-microservices-with-kubernetes--ud615

Training: https://www.udemy.com/course/learn-devops-the-complete-kubernetes-course/

Training: https://www.edx.org/course/introduction-to-kubernetes

Documentation: https://kubernetes.io/docs/home/

Playground: 

https://www.katacoda.com/courses/kubernetes/playground
https://www.katacoda.com/courses/kubernetes
https://labs.play-with-k8s.com/

Docs:
Network:
https://ahmet.im/blog/kubernetes-network-policy/

Authentication:
https://brancz.com/2017/10/16/kubernetes-auth-x509-client-certificates/
https://jenciso.github.io/personal/manage-tls-certificates-for-kubernetes-users/

https://medium.com/@betz.mark/herding-pods-taints-tolerations-and-affinity-in-kubernetes-2279cef1f982

Security:
https://docs.bitnami.com/kubernetes/how-to/secure-kubernetes-cluster-psp/

Scheduler:
https://sysdig.com/blog/kubernetes-scheduler/

Kubernetes Concepts: 

https://kubernetes.io/docs/concepts/

Pod Overview: 

https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/

 


Get good understanding of tools such as: openssl, cfssl, systemd, etcdctl (for managing etcd)

Exercise: 
https://github.com/kelseyhightower/kubernetes-the-hard-way

Exam: 
24 problems and the exam duration is 3 hours.

 

 

 

Add comment


Security code
Refresh

Category: