Please enable JavaScript.
Coggle requires JavaScript to display documents.
Phase 06 — kubectl (Enterprise Linux Administration) - Coggle Diagram
Phase 06 — kubectl (Enterprise Linux Administration)
kubectl
Definition
kubectl stands for Kubernetes Control Command Line Tool.
kubectl is the official command line utility used to communicate with the Kubernetes API Server.
Every kubectl command is sent to the Kubernetes API Server.
The API Server validates the request.
The API Server stores desired state inside etcd.
Controllers continuously compare desired state with current state.
Worker Nodes execute the requested changes.
kubectl never communicates directly with Pods or Worker Nodes.
kubectl is the primary administration tool used by Kubernetes Administrators, DevOps Engineers, Platform Engineers, Cloud Engineers and Site Reliability Engineers.
Architecture
User
Linux Terminal
kubectl
kubeconfig
Kubernetes API Server
Authentication
Authorization
Admission Controllers
etcd Database
Scheduler
Controller Manager
Kubelet
Container Runtime
Pod
Installation
Linux Installation
Ubuntu
Debian
RHEL
Rocky Linux
AlmaLinux
CentOS
SUSE
Download Binary
Install Package
Verify Version
Configure PATH Variable
Binary Location
/usr/bin/kubectl
/usr/local/bin/kubectl
which kubectl
whereis kubectl
Configuration
kubeconfig
Purpose
Stores Cluster Information
Stores User Credentials
Stores Contexts
Stores Certificates
Default Location
~/.kube/config
Environment Variable
KUBECONFIG
Multiple kubeconfig Files
Merge kubeconfig Files
kubectl Command Structure
kubectl
Verb
Resource
Resource Name
Flags
Namespace
Output Format
General Syntax
kubectl VERB RESOURCE
kubectl VERB RESOURCE NAME
kubectl VERB RESOURCE NAME FLAGS
kubectl Help
kubectl
kubectl help
kubectl options
kubectl version
kubectl version --client
Cluster Information
kubectl cluster-info
kubectl cluster-info dump
kubectl version
kubectl api-resources
kubectl api-versions
Context Management
kubectl config view
kubectl config get-contexts
kubectl config current-context
kubectl config use-context
kubectl config set-context
kubectl config rename-context
kubectl config delete-context
kubectl config unset
Namespaces
Definition
Purpose
Enterprise Usage
Commands
kubectl get namespaces
kubectl describe namespace
kubectl create namespace
kubectl delete namespace
kubectl config set-context --current --namespace
Resource Types
Pods
Deployments
ReplicaSets
StatefulSets
DaemonSets
Jobs
CronJobs
Services
Endpoints
ConfigMaps
Secrets
PersistentVolumes
PersistentVolumeClaims
StorageClasses
Nodes
Namespaces
ServiceAccounts
Roles
RoleBindings
ClusterRoles
ClusterRoleBindings
NetworkPolicies
Ingress
HorizontalPodAutoscaler
kubectl get
Definition
Purpose
Enterprise Usage
Syntax
Commands
kubectl get pods
kubectl get pod
kubectl get deployments
kubectl get services
kubectl get nodes
kubectl get namespaces
kubectl get configmaps
kubectl get secrets
kubectl get ingress
kubectl get daemonsets
kubectl get statefulsets
kubectl get jobs
kubectl get cronjobs
kubectl get pvc
kubectl get pv
kubectl get storageclass
kubectl get events
kubectl get all
Output Formats
wide
yaml
json
custom-columns
jsonpath
kubectl describe
Definition
Purpose
Enterprise Usage
Syntax
Commands
kubectl describe pod
kubectl describe deployment
kubectl describe service
kubectl describe node
kubectl describe namespace
kubectl describe pvc
kubectl describe pv
kubectl describe ingress
Information Displayed
Labels
Annotations
Events
Conditions
Container Status
Volumes
Environment Variables
Scheduling Details
kubectl logs
Definition
Purpose
Enterprise Troubleshooting
Syntax
Commands
kubectl logs pod
kubectl logs deployment
kubectl logs service
kubectl logs --follow
kubectl logs --tail
kubectl logs --since
kubectl logs --timestamps
kubectl logs --previous
kubectl logs --all-containers
kubectl exec
Definition
Purpose
Interactive Troubleshooting
Syntax
Commands
kubectl exec
kubectl exec -it
kubectl exec -- bash
kubectl exec -- sh
kubectl exec env
kubectl exec ls
kubectl exec cat
kubectl exec ps
kubectl exec top
Resource Creation
kubectl create
kubectl apply
kubectl replace
kubectl patch
kubectl edit
kubectl delete
Manifest Files
Definition
YAML Structure
apiVersion
kind
metadata
spec
status
File Extensions
.yaml
.yml
File Locations
Enterprise Standards
/opt/kubernetes/
/srv/kubernetes/
~/k8s/
manifests/
deployments/
services/
ingress/
configmaps/
secrets/
storage/
monitoring/
logging/
Output Options
yaml
json
name
wide
custom-columns
jsonpath
go-template
Label Management
kubectl label
Add Label
Modify Label
Remove Label
Enterprise Label Strategy
Annotation Management
kubectl annotate
Add Annotation
Update Annotation
Delete Annotation
Scaling
kubectl scale
Deployment Scaling
Replica Scaling
Manual Scaling
Automatic Scaling
Rollout Management
kubectl rollout status
kubectl rollout history
kubectl rollout undo
kubectl rollout restart
Enterprise Rollback Strategy
Debugging
kubectl describe
kubectl logs
kubectl exec
kubectl top
kubectl events
kubectl get events
kubectl port-forward
Node Management
kubectl get nodes
kubectl describe node
kubectl cordon
kubectl uncordon
kubectl drain
kubectl taint
Resource Monitoring
CPU
Memory
Disk
Network
kubectl top node
kubectl top pod
Security
Authentication
Authorization
RBAC
Service Accounts
Secrets
Certificates
Least Privilege
Audit Logs
Enterprise Best Practices
Always use Namespaces
Never modify production directly
Use YAML manifests
Use Git version control
Apply Infrastructure as Code
Follow RBAC
Enable Audit Logging
Monitor Cluster Health
Backup etcd
Validate YAML before deployment
Use Labels consistently
Use Annotations properly
Store Secrets securely
Never expose sensitive credentials
Follow Change Management Process
Common Errors
Connection Refused
Forbidden
Unauthorized
Resource Not Found
CrashLoopBackOff
ImagePullBackOff
Pending Pods
Evicted Pods
Node Not Ready
Out Of Memory
Disk Pressure
Network Policy Blocking
Enterprise Troubleshooting Workflow
Verify kubectl Version
Verify kubeconfig
Verify Context
Verify Namespace
Verify API Server
Verify Node Health
Verify Pod Status
Check Events
Check Logs
Describe Resource
Execute Commands Inside Container
Validate Network
Validate Storage
Validate RBAC
Review Audit Logs
Implement Fix
Verify Resolution
Document Incident
kubectl top
Definition
kubectl
Kubernetes Command Line Tool
Official command-line interface used to communicate with the Kubernetes API Server
Used by administrators, DevOps engineers, SREs, and Platform Engineers
Allows management of clusters, nodes, namespaces, workloads, storage, networking, and security
top
Displays real-time resource usage
Similar to Linux "top" command
Shows current CPU usage
Shows current Memory usage
Does not show processes
Shows Kubernetes object resource consumption
kubectl top
Displays resource usage of Nodes
Displays resource usage of Pods
Used for monitoring
Used for troubleshooting
Used for capacity planning
Used for performance analysis
Used before scaling applications
Used for detecting resource bottlenecks
Enterprise Purpose
Monitor Cluster Health
Detect High CPU Usage
Detect High Memory Usage
Capacity Planning
Resource Optimization
Troubleshooting
Horizontal Pod Autoscaler Validation
Infrastructure Monitoring
Cost Optimization
Production Monitoring
Requirements
Kubernetes Cluster
Running cluster
Worker Nodes
Control Plane
kubectl
Installed
Configured
Connected to cluster
kubeconfig
Default path
~/.kube/config
Purpose
Stores cluster information
Stores user credentials
Stores API Server information
Stores contexts
Metrics Server
Required
Collects CPU usage
Collects Memory usage
Sends metrics to Kubernetes API
Without Metrics Server
kubectl top will not work
Verify
kubectl get deployment metrics-server -n kube-system
Kubernetes API Server
Kubelet
cAdvisor
Metrics Flow
Linux Operating System
Physical CPU
RAM
Processes
Container Runtime
containerd
CRI-O
cAdvisor
Collects container resource metrics
Kubelet
Reads metrics from cAdvisor
Metrics Server
Collects metrics from Kubelet
Kubernetes API
metrics.k8s.io
kubectl top
Displays metrics to administrator
Linux Relation
Linux top command
Shows Processes
Shows CPU
Shows Memory
Shows Load Average
Shows Running Tasks
kubectl top
Shows Kubernetes Objects
Shows Pods
Shows Nodes
Shows CPU
Shows Memory
Does not show Linux processes
CPU
Definition
Central Processing Unit
Executes instructions
Performs calculations
Runs containers
CPU Unit
Core
Thread
Millicore
Millicore
One CPU Core
1000m
Half CPU
500m
Quarter CPU
250m
One Tenth CPU
100m
Examples
50m
250m
500m
750m
1000m
2000m
Memory
Definition
Random Access Memory
Stores running application data
Units
Ki
Mi
Gi
Ti
Examples
64Mi
128Mi
256Mi
512Mi
1Gi
2Gi
8Gi
Node
Definition
Physical Server
Virtual Machine
Cloud Instance
Responsibilities
Runs Pods
Runs kubelet
Runs Container Runtime
Reports metrics
Pod
Definition
Smallest deployable object in Kubernetes
One or more containers
Shared networking
Shared storage
Basic Commands
Show Node Metrics
kubectl top node
Show Pod Metrics
kubectl top pod
Show All Pods
kubectl top pod --all-namespaces
Show Specific Namespace
kubectl top pod -n production
Show Multiple Nodes
kubectl top node
Sort Output
Pipe to Linux sort
Refresh
watch kubectl top pod
Understanding Output
Node Output
NAME
Node Name
CPU(cores)
Current CPU usage
CPU%
Percentage used
MEMORY(bytes)
Current Memory usage
MEMORY%
Percentage used
Pod Output
NAME
Pod Name
CPU
Current CPU consumption
MEMORY
Current Memory consumption
Namespaces
Definition
Logical isolation inside cluster
Examples
default
kube-system
production
development
monitoring
logging
Commands
kubectl top pod -n kube-system
kubectl top pod -n monitoring
Useful Options
--all-namespaces
--containers
--no-headers
--sort-by
--use-protocol-buffers
Monitor Containers
kubectl top pod POD_NAME --containers
Displays
Every container
CPU usage
Memory usage
Enterprise Monitoring Workflow
Check Node Health
Check Cluster Capacity
Identify High CPU Nodes
Identify High Memory Nodes
Check Namespace
Check Pod
Check Individual Container
Compare Historical Metrics
Scale Workloads
Optimize Resources
Troubleshooting
kubectl top returns error
Verify Metrics Server
Verify Kubelet
Verify API Aggregation
Verify RBAC
No Metrics Available
Metrics Server not installed
Metrics Server starting
Network issue
Kubelet issue
High CPU
Infinite loop
Heavy workload
Too many requests
Missing CPU limit
High Memory
Memory leak
Large cache
High traffic
Missing Memory limit
Resource Requests
Definition
Guaranteed resources
CPU Request
Memory Request
Resource Limits
Definition
Maximum resources allowed
CPU Limit
Memory Limit
Relation with Autoscaling
Horizontal Pod Autoscaler
Uses Metrics Server
Reads CPU
Reads Memory
Automatically increases Pods
Automatically decreases Pods
Verify
kubectl get hpa
kubectl describe hpa
Enterprise Investigation
Step 1
kubectl top node
Step 2
kubectl top pod --all-namespaces
Step 3
kubectl describe pod POD_NAME
Step 4
kubectl logs POD_NAME
Step 5
kubectl describe node NODE_NAME
Step 6
kubectl get events
Step 7
Review Requests and Limits
Step 8
Scale Deployment if required
Related kubectl Commands
kubectl get nodes
kubectl get pods
kubectl describe node
kubectl describe pod
kubectl logs
kubectl exec
kubectl get hpa
kubectl describe hpa
kubectl get events
kubectl top node
kubectl top pod
Linux Commands Used Together
top
htop
free -h
vmstat
iostat
mpstat
sar
uptime
ps
pidstat
Important File Paths
~/.kube/config
kubectl configuration file
/etc/kubernetes/
Kubernetes control plane configuration
/var/lib/kubelet/
kubelet data
/var/lib/containerd/
container runtime data
/var/log/
Linux log directory
/var/log/pods/
Pod logs on node
/var/log/containers/
Container log links
Enterprise Best Practices
Install Metrics Server in every cluster
Always configure CPU Requests
Always configure Memory Requests
Always configure CPU Limits
Always configure Memory Limits
Monitor Nodes regularly
Monitor Pods regularly
Use Namespaces for isolation
Monitor with Prometheus and Grafana
Use Horizontal Pod Autoscaler
Investigate abnormal CPU spikes
Investigate abnormal Memory spikes
Perform capacity planning
Continuously optimize workloads
Combine kubectl top with describe, logs, events, and Linux performance tools for complete troubleshooting
Kubectl (Kubernetes Command Line Tool)
Definition
kubectl is the official command-line interface used to communicate with the Kubernetes API Server.
Every kubectl command sends an API request to the Kubernetes Control Plane.
kubectl never talks directly to Pods or Nodes.
It communicates with the Kubernetes API Server.
How kubectl Works
User executes kubectl command.
kubectl reads kubeconfig file.
Default kubeconfig location
~/.kube/config
kubectl authenticates to Kubernetes API Server.
API Server validates user permissions using RBAC.
API Server stores desired state inside etcd.
Controllers continuously compare desired state with actual state.
Kubelet on each worker node performs required actions.
Common Enterprise kubectl Syntax
kubectl COMMAND TYPE NAME OPTIONS
kubectl COMMAND -f filename.yaml
kubectl COMMAND --namespace production
kubectl COMMAND --context cluster1
kubectl COMMAND --kubeconfig ~/.kube/config
Common Resource Types
Pod
Deployment
ReplicaSet
StatefulSet
DaemonSet
Service
Ingress
ConfigMap
Secret
Namespace
Node
PersistentVolume
PersistentVolumeClaim
Job
CronJob
kubectl apply
Definition
Creates resources if they do not exist.
Updates resources if they already exist.
Declarative management.
Kubernetes compares YAML desired state with current cluster state.
Enterprise Purpose
Infrastructure as Code
GitOps
CI/CD deployment
Version controlled configuration
Repeatable deployments
How Apply Works
Read YAML file.
Send manifest to API Server.
Compare desired configuration.
Create missing resources.
Update changed resources.
Store last applied configuration annotation.
Command Syntax
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f namespace.yaml
kubectl apply -f directory/
kubectl apply -R -f manifests/
kubectl apply -k overlays/production
Options
-f
Manifest file
-R
Recursive directory
-k
Kustomize
--dry-run=client
Validate locally
--dry-run=server
Validate with API Server
-o yaml
Output YAML
Manifest Locations
/home/admin/k8s/
/opt/kubernetes/manifests/
Git Repository
CI/CD Pipeline
Enterprise Workflow
Developer updates YAML
Git Commit
Pipeline validation
kubectl apply
API Server
Deployment Controller
ReplicaSet
Pods Updated
kubectl delete
Definition
Removes Kubernetes resources from the cluster.
Resource deletion is requested through API Server.
Enterprise Uses
Remove old applications
Delete failed deployments
Remove obsolete ConfigMaps
Delete temporary Pods
Environment cleanup
Delete Process
Send delete request.
API Server marks object for deletion.
Finalizers execute if configured.
Resource removed.
Controllers reconcile desired state.
Command Syntax
kubectl delete pod nginx
kubectl delete deployment webapp
kubectl delete service nginx
kubectl delete namespace testing
kubectl delete -f deployment.yaml
kubectl delete all --all
Options
-f
Delete using YAML
--force
Force deletion
--grace-period=0
Immediate termination
--wait=false
Do not wait
--all
Delete all resources
-l
Delete by label
Enterprise Precautions
Check dependencies
Check Persistent Volumes
Backup before deletion
Verify namespace
Verify labels
Avoid deleting production accidentally
kubectl edit
Definition
Opens live Kubernetes object in local editor.
Edits object directly inside cluster.
How It Works
Downloads object.
Opens editor.
User modifies configuration.
Saves changes.
API Server validates.
Resource updated.
Default Editors
vi
vim
nano
Editor Variable
EDITOR
VISUAL
Command Syntax
kubectl edit deployment nginx
kubectl edit service nginx
kubectl edit configmap app-config
kubectl edit pod nginx
Enterprise Usage
Emergency production fixes
Temporary troubleshooting
Configuration corrections
Not Recommended For
GitOps
Version-controlled environments
Large production changes
Reason
Changes bypass Git history.
kubectl patch
Definition
Updates only selected fields of an existing object.
Does not replace entire YAML.
Enterprise Benefits
Faster updates
Minimal changes
Automation friendly
Scripting
Patch Types
Strategic Merge Patch
Merge Patch
JSON Patch
Command Examples
kubectl patch deployment nginx -p '{"spec":{"replicas":5}}'
kubectl patch service nginx -p '{"spec":{"type":"NodePort"}}'
kubectl patch node worker1 -p '{"spec":{"unschedulable":true}}'
Common Enterprise Uses
Increase replicas
Update image
Modify labels
Add annotations
Change Service type
Patch Advantages
Faster than edit
Smaller payload
Automation scripts
No full manifest required
kubectl cordon
Definition
Marks a node as Unschedulable.
New Pods cannot be scheduled.
Existing Pods continue running.
Enterprise Purpose
Server maintenance
Hardware replacement
Kernel update
Security patching
Storage maintenance
Command
kubectl cordon worker01
Result
Node status becomes SchedulingDisabled.
Running workloads continue.
New Pods go elsewhere.
Verify
kubectl get nodes
Enterprise Workflow
Cordon node.
Drain workloads.
Perform maintenance.
Uncordon node.
kubectl drain
Definition
Safely removes workloads from a node before maintenance.
Difference from Cordon
Cordon
Block new Pods only.
Drain
Block new Pods.
Evict existing Pods.
Drain Process
Node cordoned.
Evict Pods.
Respect PodDisruptionBudget.
Ignore DaemonSets if specified.
Delete emptyDir if requested.
Node ready for maintenance.
Command
kubectl drain worker01 --ignore-daemonsets
kubectl drain worker01 --ignore-daemonsets --delete-emptydir-data
kubectl drain worker01 --force
Important Options
--ignore-daemonsets
--delete-emptydir-data
--force
--grace-period
--timeout
Enterprise Maintenance Workflow
Check workloads.
Cordon node.
Drain node.
Update operating system.
Reboot server.
Check kubelet.
Uncordon node.
After Maintenance
kubectl uncordon worker01
kubectl top
Definition
Displays real-time CPU and Memory usage.
Uses Metrics Server.
Similar to Linux top command.
Shows Kubernetes resource consumption.
Requirements
Metrics Server installed.
Kubelet metrics available.
RBAC permissions.
Command Syntax
kubectl top node
kubectl top pod
kubectl top pod -A
kubectl top node --sort-by=cpu
kubectl top node --sort-by=memory
Output Fields
Node Name
CPU Usage
CPU Percentage
Memory Usage
Memory Percentage
Enterprise Uses
Capacity planning
Resource optimization
Troubleshooting
Performance monitoring
Autoscaling verification
Limitations
Not historical.
Not long-term monitoring.
Requires Metrics Server.
Enterprise Monitoring Stack
kubectl top
Metrics Server
Prometheus
Grafana
Alertmanager
Enterprise Best Practices
Always use YAML with kubectl apply.
Store manifests in Git.
Avoid kubectl edit in production.
Use kubectl patch for small automated updates.
Always cordon before draining.
Never drain control-plane nodes without planning.
Verify workloads before delete.
Monitor CPU and Memory using kubectl top.
Implement RBAC.
Use Namespaces.
Use Labels and Selectors.
Validate manifests before apply.
Use GitOps for production.
Take backups before deleting critical resources.
Review audit logs after administrative changes.
Related Linux Knowledge
kubeconfig Path
~/.kube/config
Kubernetes Static Pod Path
/etc/kubernetes/manifests/
Kubelet Configuration
/var/lib/kubelet/
Systemd Service
systemctl status kubelet
Log Files
journalctl -u kubelet
journalctl -xe
Common Verification Commands
kubectl get nodes
kubectl get pods -A
kubectl describe node worker01
kubectl describe pod podname
kubectl logs podname
kubectl events
kubectl api-resources
kubectl api-versions
kubectl cluster-info
kubectl version
Architecture
Administrator
Executes kubectl command
kubeconfig
Stores cluster information
Stores user credentials
Stores certificates
Stores contexts
Default location
~/.kube/config
Kubernetes API Server
Receives requests
Authenticates user
Authorizes request
Validates request
Stores changes in etcd
Sends instructions to Controllers and Kubelets
Enterprise Usage
Cluster administration
Application deployment
Scaling
Troubleshooting
Monitoring
Rolling updates
Disaster recovery
Security management
kubectl uncordon
Definition
Makes a Kubernetes Node schedulable again.
Allows new Pods to be placed on the node.
Opposite of kubectl cordon.
Related Concepts
Node
Physical server
Virtual Machine
Cloud Instance
Scheduling
Process of placing Pods onto Nodes.
Scheduler
Kubernetes component responsible for selecting Nodes.
Workflow
Node Active
Administrator performs maintenance
kubectl cordon
kubectl drain
Maintenance completed
kubectl uncordon
Scheduler starts placing Pods again
Syntax
kubectl uncordon NODE_NAME
Example
kubectl uncordon worker01
Verify
kubectl get nodes
SchedulingDisabled should disappear
Enterprise Use Cases
Kernel updates
Hardware replacement
Storage upgrades
Security patching
Hypervisor maintenance
Best Practices
Always drain before maintenance
Verify workloads
Monitor node health before uncordon
Confirm Ready status
kubectl rollout
Definition
Manages application deployments and updates.
Controls rolling updates and rollbacks.
Rolling Update
Updates Pods gradually.
Avoids application downtime.
Replaces old Pods with new Pods.
Rollout Components
Deployment
ReplicaSet
Pods
Common Commands
kubectl rollout status deployment nginx
kubectl rollout history deployment nginx
kubectl rollout undo deployment nginx
kubectl rollout restart deployment nginx
kubectl rollout pause deployment nginx
kubectl rollout resume deployment nginx
Status
Shows update progress
Shows successful deployment
Detects failures
History
Lists deployment revisions
Useful for auditing
Undo
Rollback to previous revision
Restore stable version
Restart
Restart Pods without changing YAML
Pause
Temporarily stop deployment changes
Resume
Continue paused deployment
Enterprise Scenario
Deploy Version 2
Monitor health
Error detected
Rollback immediately
Benefits
High Availability
Zero Downtime
Controlled deployment
Easy rollback
kubectl scale
Definition
Changes the number of running Pod replicas.
Used to increase or decrease application capacity.
Scaling Types
Manual Scaling
Automatic Scaling
Horizontal Pod Autoscaler
Vertical Pod Autoscaler
Cluster Autoscaler
Replica
Copy of a Pod
Commands
kubectl scale deployment nginx --replicas=5
kubectl scale replicaset web-rs --replicas=10
kubectl scale statefulset mysql --replicas=3
Verify
kubectl get deployments
kubectl get pods
Enterprise Use Cases
High traffic
Seasonal demand
Disaster recovery
Resource optimization
Best Practices
Monitor CPU
Monitor Memory
Use HPA
Set Resource Limits
kubectl explain
Definition
Displays official Kubernetes documentation directly in the terminal.
Helps administrators understand YAML fields.
Purpose
Learn resource definitions
Discover supported fields
Avoid YAML mistakes
Syntax
kubectl explain deployment
kubectl explain deployment.spec
kubectl explain deployment.spec.template
kubectl explain pod.spec.containers
Recursive Documentation
deployment
spec
template
spec
containers
Options
--recursive
Example
kubectl explain deployment --recursive
Enterprise Benefits
Faster YAML development
No Internet required
Reduces configuration errors
kubectl api-resources
Definition
Lists every Kubernetes resource supported by the cluster.
Resource
Kubernetes object managed by the API Server.
Examples
Pods
Deployments
Services
Nodes
ConfigMaps
Secrets
StatefulSets
DaemonSets
Jobs
CronJobs
PersistentVolumes
PersistentVolumeClaims
Namespaces
Ingress
Command
kubectl api-resources
Useful Columns
NAME
SHORTNAMES
APIVERSION
NAMESPACED
KIND
Enterprise Usage
Automation
API discovery
Cluster auditing
Scripting
kubectl api-versions
Definition
Lists every API version supported by the Kubernetes API Server.
Purpose
Shows available APIs.
Helps determine supported YAML apiVersion.
Command
kubectl api-versions
Examples
v1
apps/v1
batch/v1
autoscaling/v2
networking.k8s.io/v1
storage.k8s.io/v1
rbac.authorization.k8s.io/v1
Why Important
YAML manifests require correct apiVersion.
Deprecated APIs fail.
Enterprise Usage
Upgrade planning
Compatibility checks
Migration projects
kubectl top
Definition
Displays real-time CPU and Memory usage.
Similar to Linux top command.
Uses Kubernetes Metrics API.
Requirements
Metrics Server installed
Metrics API enabled
Architecture
Pod
Kubelet
Metrics Server
API Server
kubectl top
Commands
kubectl top node
kubectl top pod
kubectl top pod --all-namespaces
kubectl top pod nginx
kubectl top node worker01
CPU
Measured in millicores
Example
100m
500m
1000m equals one CPU core
Memory
Measured in MiB
Example
256Mi
1Gi
Enterprise Monitoring
Capacity planning
Performance tuning
Resource optimization
Detect resource bottlenecks
Verify autoscaling
Troubleshooting
High CPU
Infinite loop
Heavy processing
Traffic spike
High Memory
Memory leak
Large cache
Large workload
Low Resources
Idle application
Overprovisioned resources
Best Practices
Combine with
kubectl describe
kubectl logs
kubectl get events
Configure Resource Requests
Configure Resource Limits
Monitor with Prometheus
Visualize with Grafana
Enterprise Kubernetes Workflow
Check Cluster
kubectl get nodes
kubectl get pods -A
Monitor Usage
kubectl top node
kubectl top pod
Inspect Resources
kubectl api-resources
kubectl api-versions
Understand Objects
kubectl explain deployment
kubectl explain pod.spec.containers
Scale Application
kubectl scale deployment web --replicas=5
Deploy Update
kubectl rollout restart deployment web
kubectl rollout status deployment web
Rollback if Needed
kubectl rollout undo deployment web
Node Maintenance
kubectl cordon worker01
kubectl drain worker01 --ignore-daemonsets --delete-emptydir-data
Perform maintenance
kubectl uncordon worker01
Related Kubernetes Components
Control Plane
API Server
Scheduler
Controller Manager
etcd
Worker Node
kubelet
kube-proxy
Container Runtime
Workloads
Pod
ReplicaSet
Deployment
StatefulSet
DaemonSet
Job
CronJob
Networking
Service
Ingress
Network Policy
Storage
Persistent Volume
Persistent Volume Claim
Storage Class
Security
RBAC
Service Account
Secret
ConfigMap
Admission Controller