Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Kubernetes Guide_ Architecture and Commands

Uploaded by

Sai Charan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Kubernetes Guide_ Architecture and Commands

Uploaded by

Sai Charan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Kubernetes Guide: Architecture and Commands

1. Kubernetes Architecture Overview


Kubernetes is a container orchestration platform that automates deployment,
scaling, and operations of application containers. It consists of the following key
components:

Control Plane Components:

API Server: Frontend of the cluster that handles RESTful API requests.
etcd: Distributed key-value store for configuration and state data.
Controller Manager: Ensures cluster state matches the desired state.
Scheduler: Assigns workloads (pods) to nodes.

Node Components:

Kubelet: Manages individual node and communicates with API Server.


Kube Proxy: Manages networking and enforces cluster policies.
Container Runtime: Runs containers (e.g., Docker, containerd).
2. Basic Kubernetes Commands
Cluster Management Commands:

kubectl cluster-info # Display cluster information

kubectl get nodes # List all nodes in the cluster

kubectl describe node <node-name> # Get detailed node information

kubectl drain <node-name> # Safely remove a node from service

kubectl delete node <node-name> # Delete a node

3. Pod Management Commands


kubectl get pods # List all pods

kubectl describe pod <pod-name> # Get detailed pod information

kubectl delete pod <pod-name> # Delete a pod

kubectl logs <pod-name> # View logs of a pod

kubectl exec -it <pod-name> -- /bin/sh # Access pod shell

4. Deployments and Scaling


kubectl create deployment <name> --image=<image-name> # Create a
deployment

kubectl get deployments # List deployments

kubectl scale deployment <name> --replicas=3 # Scale deployment

kubectl delete deployment <name> # Delete deployment


5. Service Management
kubectl expose deployment <name> --type=NodePort --port=80 # Create a
service

kubectl get services # List all services

kubectl describe service <service-name> # Get service details

kubectl delete service <service-name> # Delete service

6. Namespace and Context Management


kubectl get namespaces # List all namespaces

kubectl create namespace <namespace-name> # Create a namespace

kubectl delete namespace <namespace-name> # Delete a namespace

kubectl config set-context --current --namespace=<namespace-name> # Set


default namespace

7. ConfigMaps and Secrets


kubectl create configmap <config-name> --from-literal=key=value # Create a
ConfigMap

kubectl get configmaps # List ConfigMaps

kubectl describe configmap <config-name> # View details of ConfigMap

kubectl delete configmap <config-name> # Delete ConfigMap

kubectl create secret generic <secret-name> --from-literal=username=admin #


Create a secret

kubectl get secrets # List secrets

kubectl describe secret <secret-name> # View secret details

kubectl delete secret <secret-name> # Delete secret


8. Ingress and Networking
kubectl get ingress # List Ingress resources

kubectl describe ingress <ingress-name> # View Ingress details

kubectl delete ingress <ingress-name> # Delete Ingress resource

9. Storage Management
kubectl get pv # List Persistent Volumes

kubectl get pvc # List Persistent Volume Claims

kubectl delete pvc <pvc-name> # Delete a Persistent Volume Claim

10. Role-Based Access Control (RBAC)


kubectl create role <role-name> --verb=get --resource=pods # Create a role

kubectl get roles # List roles

kubectl create rolebinding <binding-name> --role=<role-name> --user=


<username> # Assign a role

kubectl get rolebindings # List role bindings

11. Troubleshooting and Debugging


kubectl get events # Get recent events in the cluster

kubectl describe pod <pod-name> # View pod details

kubectl logs <pod-name> # Fetch logs from a pod

kubectl exec -it <pod-name> -- /bin/sh # Open shell into a pod


12. Monitoring and Logging
kubectl top pod # View resource usage of pods

kubectl top node # View resource usage of nodes

13. Helm (Kubernetes Package Manager)


helm repo add stable https://charts.helm.sh/stable # Add Helm repository

helm install <release-name> stable/<chart-name> # Install a Helm chart

helm list # List all installed Helm releases

helm delete <release-name> # Uninstall a Helm release

14. Autoscaling in Kubernetes


kubectl autoscale deployment <name> --min=2 --max=5 --cpu-percent=80 #
Enable autoscaling

kubectl get hpa # List Horizontal Pod Autoscalers

kubectl delete hpa <hpa-name> # Delete an HPA

Conclusion
This guide provides a comprehensive overview of Kubernetes architecture and
essential commands needed for managing clusters, workloads, networking,
storage, security, and troubleshooting. Mastering these commands will help you
efficiently work with Kubernetes and automate your containerized applications.

Keep exploring and happy learning!

@CreatedBY:RUTIK NIKAM

You might also like