FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Follow publication

23 Advanced kubectl commands

Collection of useful kubectl commands

Kenichi Shibata
FAUN — Developer Community 🐾
7 min readJun 20, 2019

--

Updated: Dec 21, 2020

I’ve personally used these commands to debug in production. I also used GUI methods like k9s and lenses.io.

0. Impersonate a user and group

kubectl get pods --as-group="somecompany:somecompany-teamname" --as="test"

1. Explain a resource

kubectl explain hpaKIND:     HorizontalPodAutoscaler
VERSION: autoscaling/v1
DESCRIPTION:
configuration of a horizontal pod autoscaler.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata <Object>
Standard object metadata. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec <Object>
behaviour of autoscaler. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
status <Object>
current information about the autoscaler.
kubectl explain svc

2. Get nodes region and zone

kubectl get nodes --label-columns failure-domain.beta.kubernetes.io/region,failure-domain.beta.kubernetes.io/zoneNAME                                        STATUS   ROLES    AGE     VERSION               REGION      ZONE
ip-11-0-109-70.eu-west-1.compute.internal Ready <none> 5d21h v1.16.15-eks-ad4801 eu-west-1 eu-west-1b…

--

--

Published in FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Written by Kenichi Shibata

Git Ninja! Linux Nerd. Javascript evangelist. AWS Architect. Software engineer. Kubernetes Mentor and Architect

Responses (1)

Write a response