Ambassador Labs

Code, ship, and run apps for Kubernetes faster and easier than ever — powered by Ambassador’s…

Follow publication

GETTING EDGY

Getting Edgy: What is Kubectl?

Kelsey Evans
Ambassador Labs
Published in
2 min readJan 7, 2020

Kubectl is a command line tool used to run commands against Kubernetes clusters. It does this by authenticating with the Master Node of your cluster and making API calls to do a variety of management actions. If you’re just getting started with Kubernetes, prepare to be spending a lot of time with kubectl!

How to Use kubectl

The format of a kubectl command looks like this:

kubectl[command][type][name][flags] 
  • [command]: specifies the action you want to perform like create, delete, get, apply
  • [type]: any Kubernetes resource, whether automatically provided by Kubernetes (like a service or a pod) or created by you with a Custom Resource Definition
  • [name]: the name you have given the resource — if you omit the name, kubectl will return every resource specified by the type
  • [flags]: specify any additional global or command specific options such as the output format

An example of a command using the full command format is

kubectl get pods hello-world -o yaml

which will make a call to the kubernetes api and output the configuration of a pod named hello-world in yaml format.

Since the name is optional, some commands you will commonly execute will completely omit it such as

kubectl apply -f hello-world.yaml

which will apply a configuration defined in the hello-world.yaml file.

Learn More

Other useful tools:

Subscribe to the Ambassador YouTube Channel to get updates about new weekly videos!

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Ambassador Labs

Code, ship, and run apps for Kubernetes faster and easier than ever — powered by Ambassador’s industry-leading developer experience.

No responses yet

Write a response