Loading

Quipoin Menu

Learn • Practice • Grow

kubernetes / Kubectl Basics
tutorial

Kubectl Basics

kubectl is the command‑line tool used to interact with your Kubernetes cluster. It’s how you deploy applications, inspect resources, and troubleshoot issues. Mastering basic kubectl commands is essential.

Checking kubectl Installation

Minikube automatically installs kubectl. Verify it’s available:
kubectl version --client

Common kubectl Commands

  • Get resources: kubectl get nodes, kubectl get pods, kubectl get deployments.
  • Describe details: kubectl describe pod pod-name shows detailed status.
  • Create resources: kubectl create -f file.yaml or kubectl apply -f file.yaml.
  • Delete resources: kubectl delete pod pod-name or kubectl delete -f file.yaml.
  • View logs: kubectl logs pod-name.
  • Run a command in a pod: kubectl exec -it pod-name -- /bin/sh.

Example: Running a Simple Pod

Create a pod with an Nginx container:
kubectl run nginx --image=nginx --restart=Never
Check the pod status:
kubectl get pods
Get details:
kubectl describe pod nginx
Delete the pod:
kubectl delete pod nginx

Using YAML Files

Most Kubernetes resources are defined in YAML files. For example, save this as nginx-pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
Then apply it:
kubectl apply -f nginx-pod.yaml


Two Minute Drill
  • kubectl get – list resources.
  • kubectl describe – show detailed info.
  • kubectl apply -f file.yaml – create/update resources from YAML.
  • kubectl delete – remove resources.
  • kubectl logs – view container logs.

Need more clarification?

Drop us an email at career@quipoinfotech.com