Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
kubectl: Command-Line Kubernetes in a Nutshell

You're reading from   kubectl: Command-Line Kubernetes in a Nutshell Deploy, manage, and debug container workloads using the Kubernetes CLI

Arrow left icon
Product type Paperback
Published in Nov 2020
Publisher Packt
ISBN-13 9781800561878
Length 136 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Rimantas Mocevicius Rimantas Mocevicius
Author Profile Icon Rimantas Mocevicius
Rimantas Mocevicius
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Section 1: Getting Started with kubectl
2. Chapter 1: Introducing and Installing kubectl FREE CHAPTER 3. Section 2: Kubernetes Cluster and Node Management
4. Chapter 2: Getting Information about a Cluster 5. Chapter 3: Working with Nodes 6. Section 3: Application Management
7. Chapter 4: Creating and Deploying Applications 8. Chapter 5: Updating and Deleting Applications 9. Chapter 6: Debugging an Application 10. Section 4: Extending kubectl
11. Chapter 7: Working with kubectl Plugins 12. Chapter 8: Introducing Kustomize for Kubernetes 13. Chapter 9: Introducing Helm for Kubernetes 14. Chapter 10: kubectl Best Practices and Docker Commands 15. Other Books You May Enjoy

kubectl commands

To get a list of supported kubectl commands, run this:

$ kubectl --help

kubectl commands are grouped by category. Let's look at each category.

Basic commands

The following are basic kubectl commands:

  • create: Create a resource from a file or from stdin; for example, create a Kubernetes deployment from the file.
  • expose: Take a service, deployment, or pod and expose it as a new Kubernetes Service.
  • run: Run a particular image on the cluster.
  • set: Set specific features on objects—for example, set environment variables, update a Docker image in a pod template, and so on.
  • explain: Get the documentation of resources—for example, the documentation on deployments.
  • get: Display one or many resources. For example, you can get a list of running pods or the YAML output of a pod.
  • edit: Edit a resource—for example, edit a deployment.
  • delete: Delete resources by filenames, stdin, resources, and names, or by resources and label selectors.

Deploy commands

The following are kubectl deploy commands:

  • rollout: Manage the rollout of a resource.
  • scale: Set a new size for a deployment, ReplicaSet, or StatefulSet.
  • autoscale: Auto-scale a deployment, ReplicaSet, or StatefulSet.

Cluster management commands

The following are the kubectl cluster management commands:

  • certificate: Modify certificate resources.
  • cluster-info: Display cluster information.
  • top: Display resource (CPU/memory/storage) usage.
  • cordon: Mark a node as unschedulable.
  • uncordon: Mark a node as schedulable.
  • drain: Drain a node in preparation for maintenance.
  • taint: Update the taints on one or more nodes.

Troubleshooting and debugging commands

The following are the kubectl troubleshooting and debugging commands:

  • describe: Show the details of a specific resource or group of resources.
  • logs: Print the logs for a container in a pod.
  • attach: Attach to a running container.
  • exec: Execute a command in a container.
  • port-forward: Forward one or more local ports to a pod.
  • proxy: Run a proxy to the Kubernetes API server.
  • cp: Copy files and directories to and from containers.
  • auth: Inspect authorization.

Advanced commands

The following are the kubectl advanced commands:

  • diff: Show difference of live version against a would-be applied version.
  • apply: Apply a configuration to a resource by filename or stdin.
  • patch: Update the field(s) of a resource using a strategic merge patch.
  • replace: Replace a resource by filename or stdin.
  • wait: Wait for a specific condition on one or many resources.
  • convert: Convert config files between different API versions.
  • kustomize: Build a kustomization target from a directory or a remote URL.

Settings commands

The following are the settings commands in kubectl:

  • label: Update the labels on a resource.
  • annotate: Update the annotations on a resource.

Other commands

The following are several other commands used in kubectl:

  • alpha: Commands for features in alpha.
  • api-resources: Print the supported API resources on the server.
  • api-versions: Print the supported API versions on the server, in the form of group/version.
  • config: Modify kube-config files.
  • plugin: Provide utilities for interacting with plugins.
  • version: Print the client and server version information.

As you can see from the lists, commands are divided into different groups. We are going to learn about most but not all of these commands in the coming chapters.

At the time of writing, the kubectl version is 1.18; with more recent versions, the commands might have changed.

You have been reading a chapter from
kubectl: Command-Line Kubernetes in a Nutshell
Published in: Nov 2020
Publisher: Packt
ISBN-13: 9781800561878
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image