How to Use Kubectl for Cluster Management | listing resources | using kubectl explain

Essentials of Managing Kubernetes Contexts

Get information about our current cluster context. Ensure we are login to correct cluster.

Note: * mark on cluster which we are on in output of the command

kubectl config get-contexts

Change our context if needed by specify name

kubectl config use-context <name>

Get information about the API server for our current context

kubectl cluster-info

Get the list of resources available in cluster

kubectl api-resources | more

Explain to see the structure of a resource

kubectl explain pods | more

Explain more or closely

kubectl explain pod.spec | more
kueectl explain pod.spec.containers | more

Creating a pod with YAML file

kubectl apply -f pod.yaml

Pod.yaml is a file for creating pod:

apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: my-app
annotations:
my-label: my-label
spec:
containers:
- name: my-container
image: my-image
ports:
- name: my-port
protocol: TCP
containerPort: 80
- name: my-container
image: my-image
ports:
- name: my-port
protocol: TCP
containerPort: 80

Get a list of currently running pods

kubectl get pods

Delete the pod

kubectl delete pod <podname>

This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply