Cluster architecture
Kubernetes architecture
Kube- API server Primary management Server
ETCD ETCD - Key value format
ETCD in kubernetes
Controller Managers Node-Controllers Takes care of the Node level
Replication-Controllers Replication -Group / Replication Set
Kube scheduler Schedulign application/contaners on nodes, Kube scheduler identifies the right node
Kublet Kublet is the captian of the worker nodes
Kube-Proxy Communication between the worker nodes (Web-Database Alike)
DNS service run in the form of Containers
Docker Cont.D Rkt(Rocket)
Master
Worker nodes
ETCD - Key value format
Kube scheduler identifies the right node
entifies the right node
Wha is ETCD ETCD Cluster
Key-Value Store
RAFT Protocol Nodes
Best practices on number of nodes PODs
Configs
Secrets
ETCD Prot 2379 Accounts
Roles
Commands Bindings
Others
etcdctl set key1 Value1
etcdctl get Key1
Value1
Notes
Adverstised Client URL
apiVersion: v1 pod definition .yml kind filed Version field
kind: pod pod v1
metadata: service v1
name: My-pod ReplicaSet apps/v1
Labels Deploymenapps/v1
app: myapp
type: front-end
spec:
containers:
first item - name: nginx-container
image; nginx
Commands
kubctl get pods
Version field
Commands
PODS
kubectl get pods
kubectl create -f filname.yml
kubectl describe pods name
kubectl get pods -o wide
kubectl run redis1 --image=redis123
kubectl edit pod redis
kubectl -f filename apply
kubectl logs
kubectl exec
kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>
REPLICATIONSET
kubectl get replicaset
kubectl get rs
kubectl get replicaset
kubectl describe replicaset
kubectl describe pods
kubectl delete pod <pod-name>
kubectl explain replicaset | grep VERSION
kubectl delete replicaset <replicaset-name>
kubectl scale rs new-replica-set --replicas=5
kubectl scale rs new-replica-set --replicas=2
DEPLOYMENTS
kubectl explain deployment | head -n1
kubectl get deployments
kubectl apply -f deployment-definition.yaml
kubectl scale deployment hostnames --replicas=3
kubectl create deployment hostnames --image=k8s.gcr.io/serve_hostname
NAMESPACES
kubectl get namespace
kubectl get ns --no-headers | wc -l
kubectl get pods --namespace=research
kubectl -n research get pods --no-headers | wc -l
kubectl run redis --image=redis -n finance
kubectl get pods --all-namespaces | grep blue
kubectl get pods --all-namespaces
SERVICES
kubectl get service
kubectl describe service
Labels
Endpoints:
Type:
IMPERATIVE COMMANDS
kubectl apply -f
kubectl run nginx-pod --image=nginx:alpine
kubectl run redis --image=redis:alpine --dry-run=client -oyaml > redis-pod.yaml
metadata changes ( Label Set)
kubectl expose
kubectl expose pod redis --port=6379 --name redis-service
kubectl create deployment webapp --image=kodekloud/webapp-color --replicas=3
kubectl run custom-nginx --image=nginx --port=8080
kubectl create namespace dev-ns
kubectl create ns dev-ns
kubectl create deployment redis-deploy --image=redis --replicas=2 -n dev-ns
kubectl create deployment redis-deploy --image redis --namespace=dev-ns --dry-run=client -o yaml > deploy.yaml
kubectl scale deployment
kubectl edit deployment
kubectl apply -f deploy.yaml
kubectl run httpd --image=httpd:alpine --port=80 --expose
SCHEDULING - MANUAL SCHEDULING
kubectl create -f nginx.yaml
kubectl get pods --namespace kube-system
kubectl get nodes
LABELS AND SELECTORS
kubectl get pods --selector env=dev
kubectl get pods --selector env=dev --no-headers | wc -l
kubectl get pods --selector bu=finance --no-headers | wc -l
kubectl get pods --selector bu=finance
kubectl get all --selector env=prod
kubectl get all --selector env=prod --no-headers | wc -l
kubectl get all --selector env=prod,bu=finance,tier=frontend
TAINTS AND TOLERATIONS
kubectl get nodes
kubectl describe node node01 | grep -i taints
kubectl taint nodes node01 spray=mortein:NoSchedule
kubectl taint nodes controlplane node-role.kubernetes.io/master:NoSchedule-
Remarks
Name
to see all the details of a pod
for editing the file and updating it
ReplicaSets
Desired
Check errors in events section
Even after deleting the POD (Replicaset ensures that desired POD to be up and will create new POD)
Deployment (d caps)
deploy
how many
just count
how many pod in research namespace
just count
Create a POD in the finance namespace.
find with pod name
type- ClusterIP
targetPort
component=apiserver
To generate the yaml file
tier=db
To generate the yaml file
if there is no scheduler pod present in the kube-system namespace pod won't get genereated
creating taint
Remove Taint
Ready Status Age
current Ready Age
NodePort ExternalIP InternalIP
6443/TCP
provider=kubernetes
then kubectl apply -f
apiVersion: v1
kind: Service
metadata:
name: webapp-service
spec:
type: NodePort
ports:
- targetPort: 8080
port: 8080
nodePort: 30080
selector:
name: simple-webapp
apiVersion: v1
kind: Pod
metadata:
name: bee
spec:
containers:
- image: nginx
name: bee
tolerations:
- key: spray
value: mortein
effect: NoSchedule
operator: Equal
https://kodekloud.com/topic/practice-test-labels-and-selectors-2/
Gmail login