Kubernetes Useful Commands

I have been using kubernetes over 3 years and would like to write a blog to provide useful commands

How to get currently running pods?

kubectl get pods (default namespace)

kubectl get pods –all-namespaces

kubectl get pods -o wide , kubectl get pods -all-namespaces -o wide  (This will display more details of the pods)

How to view the pod details ?

kubectl describe pod pod_name (Default namespace)

kubectl describe pod pod_name -n xyz (xyz namespace)

Note: pod_name is the name of the pod

How many nodes do you see in the cluster?

kubectl get nodes
kubectl get nodes –all-namespaces

How to get deployments?

default namespace:
kubectl get deployments

on xyz namspace:

kubectl get deploymenets -n xyz

or

kubectl get deployments –namespace xyz

How to empty the node of all pods/applications and mark it unschedulable? 

kubectl drain node01

If you want the node to be unschedulable and do not want to remove any apps currently running on node then you need to use cordon

kubectl cordon node01

How to configure the node to be scheduled again ?

kubectl uncordon node01

how to see certificate?

kubectl get crt

how to check access?

kubectl auth can-i create deployments

kubectl auth can-i delete nodes

kubectl auth can-i create deployments –as username

kubectl auth can-i delete nodes –as username

How to find roles details? 

kubectl get roles (default namespace)

kubectl get nodes -n xyz ( Particular xyz namespace)

kubectl get roles –all-namespaces (All namespaces)

How to find details of access granted to the role named “developer”?

kubectl describe role developer (default namespace)

kubectl describe role developer -n xyz ( xyz namespace)

How to see which account the role developer assigned to on xyz namespace?

kubectl describe rolebinding weave-net -n xyz

How to find cluster roles?

kubectl get clusterroles

How to find clusterrole bindings?

kubectl get clusterrolebindings

How to check networkpolicies defined in the cluster?

kubectl get networkpolicy

How to check the details of networkpolicy attached to cluster?

kubectl describe networkpolicy

How to see the status of persistence volume claim?

kubectl get persistentvolumeclaim

How to get the status of the persistent volume?

kubectl get pvc

How to verify recliam policy set on persistent volume?

kubectl get pv

How to delete persistent volume claim?

kubectl delete pvc clam_name

Note: claim_name is the name of the persistent volume claim

I will continue to add more in this blog.

Hope you enjoyed the post.

Cheers

Ramasankar Molleti

LinkedIn

 

Published by Ramasankar

Hi. I’m Ramasankar Molleti. I’m a passionate IT professional with over 14 years of experience on providing solutions for customers who are looking on cloud computing, Database Migration, Development, and Big Data. I love learning new technologies and share my knowledge to community. I am currently working as Sr Cloud Architect with focus on Cloud Infrastructure, Big Data. I work with developers to architect, build, and manage cloud infrastructure, and services. I have deeep knowledge and experience on working with various database platforms such as MS SQL Server, PostgeSQL, Oracle, MongoDB, Redshift, Dyanamodb, Amazon Aurora. I worked as Database Engineer, Database Administrator, BI Developer and successfully transit myself into Cloud Architect with focus on Cloud infranstructure and Big Data. I live in USA and put my thoughts down on this blog. If you want to get in touch with me, contact me on my Linkedin here: https://www.linkedin.com/in/ramasankar-molleti-23b13218/ My Certifications: Amazon: AWS Certified Solutions Architect – Professional AWS Certified DevOps Engineer – Professional certificate AWS Certified Big Data – Specialty AWS Certified Security – Specialty certificate AWS Certified Advanced Networking – Specialty certificate AWS Certified Solutions Architect – Associate Microsoft: Microsoft® Certified Solutions Associate: SQL Server 2012/2014 Microsoft Certified Professional Microsoft® Certified IT Professional: Database Administrator 2008 Microsoft® Certified Technology Specialist: SQL Server 2008, Implementation and Maintenance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: