Kubernetes Cheat Sheet Github



GitHub - kubeopsskills/kubernetes-cheatsheet: This is Kubernetes Cheatsheet based on Kubernetes API 1.19 version. :book: Kubernetes CheatSheets In A4. Contribute to dennyzhang/cheatsheet-kubernetes-A4 development by creating an account on GitHub. 📖 Kubernetes CheatSheets In A4. Normal FailedBinding 7s (x5 over 1m) persistentvolume-controller no persistent volumes available for this claim and no storage class is set #+ENDEXAMPLE. DONE kubernetes start a container for testing: kubectl run -i -tty ubuntu -image=ubuntu:16.04 -restart=Never - bash -il CLOSED: 2017-12-31 Sun 11:26. DONE #A ReplicaSet is the next-generation.

© Provided by TechRepublic Image: iStock/123dartist

As containers have become more important to businesses across the globe, it was necessary to create a system that would allow containers to scale out to meet the needs of enterprise-level deployments. That's where Kubernetes comes into play.

© 123dartist, Getty Images/iStockphoto

Black cubes grid background

Unlike Docker, Kubernetes is a very robust ecosystem. Instead of deploying a single container, Kubernetes enables you to deploy multiple containers to multiple hosts, making it ideal for larger deployments and load balancing.

This smart person's guide is an easy way to get up to speed on Kubernetes. We'll update this guide periodically when news about Kubernetes is released.

SEE: Kubernetes security guide (free PDF) (TechRepublic)

Kubernetes Cheat Sheet Pdf

Executive summary

  • What is Kubernetes? Kubernetes is an open source project that enables the management of large-scale container and pod deployment.
  • Why does Kubernetes matter? Containerized applications are being used by most of the major enterprise companies as a way to roll out large-scale, highly-available, load-balanced clusters of apps and services. If this is something your business is looking to do, Kubernetes might be the right tool for you.
  • Who does Kubernetes affect? Kubernetes affects companies that want to roll out massive containerized applications, as well as clients, customers, consumers...anyone that would benefit from highly-available services. Kubernetes also helps developers build distributed applications and makes it much easier for IT operators to manage scalable infrastructure for applications.
  • When is Kubernetes happening? Kubernetes was first announced in mid-2014 and was first released on July 21, 2015.
  • How do I start using Kubernetes? Install the system on a supported platform such as Red Hat, SUSE, CentOS, Fedora Server, Ubuntu Server, etc., and you'll have access to kubernetes, kubernetes-client, kubernetes-master, kubernetes-node, and more.

SEE: All of TechRepublic's cheat sheets and smart person's guides

What is Kubernetes?

Kubernetes is an open source system that allows you to run containers across multiple hosts, effectively offering the co-location of containers, service discovery, and replication control. It was originally called K8s and was designed by Google and donated to the Cloud Native Computing Foundation.

The primary functions of Kubernetes are:

  • schedule, start, manage, and scale containers across multiple hosts; and
  • add a higher-level API to define how containers are logically grouped to define container pools and handle load balancing.

Its features include the following:

  • Automated scheduling: Allows you to deploy containers and services at scheduled times.
  • Self-healing capabilities: When a container or pod falls out of its desired state, Kubernetes can attempt to automatically resolve the problem.
  • Automated rollouts and rollback: Add automated rollouts and rollbacks to create a CI/CD pipeline.
  • Horizontal scaling and load balancing: Scale your deployments as needed.
  • Environment consistency for development: Your testing and production infrastructures are loosely coupled to each individual component and can act as a separate unit to the cluster.
  • Deploy containers and manage rollout control: With this complex system you can describe your containers and/or pods and define how many you want in a single deployment. Kubernetes will not only manage the running of those containers or pods (even across multiple hosts), but it will also handle deploying changes (e.g., updating images, changing variables, etc.) to your containers.
  • Resource Bin packing allows you to declare minimum and maximum computer resources (CPU and memory) for all containers.
  • Built-in service discovery: Automatic exposure of containers to the internet or other containers in the Kubernetes cluster.
  • Autoscaling: Kubernetes automatically load balances traffic across matching containers.
  • Heterogeneous clusters: Kubernetes allows you to build a cluster with a mixture of virtual machines, on-premises servers, or bare metal in your company data center.
  • Persistent storage support is available to Kubernetes, with support for Amazon Web Services EBS, Google Cloud Platform persistent disks, and more. Vendors, including Red Hat, Dell EMC, and NetApp, provide persistent storage for Kubernetes.
  • High availability, such as multi-master and cluster federation, allowing the linking of clusters together for load balancing.

Kubernetes allows you to easily:

  • deploy containerized applications quickly and predictably;
  • scale containerized applications on the fly;
  • seamlessly roll out new features to your containerized applications; and
  • optimize your hardware specifically for your containerized applications.

Data Center Must-Reads

Kubernetes, at its minimum, can schedule and run containerized applications on clusters of physical machines or virtual machines or a combination of physical and virtual machines; this allows developers to leave behind the traditional method of working with physical and virtual machines. Although this can be achieved with the simpler Docker Swarm, Kubernetes allows the deployment of much larger clusters, which can include containers and/or pods. In other words, create your containers and then deploy them over a massive, load balanced cluster with Kubernetes.

Kubernetes consists of the following components.

  • Pods: Containers are placed into pods to be managed by Kubernetes.
  • Labels and selectors: Key-value pairs used to identify and group resources within Kubernetes.
  • Controllers: A reconciliation loop that drives actual cluster state toward the desired cluster state.
  • Services: A way to identify elements used by applications (name-resolution, caching, etc.).
  • Kubernetes control plane: Main controlling unit of the cluster that manages workload and directs communication across the system.
  • etcd: Persistent, lightweight, distributed key-value data store.
  • API server: Serves the Kubernetes API using JSON over HTTP.
  • Scheduler: Pluggable component that selects which node a pod should run on based on resource availability.
  • Controller manager: The process that runs the Kubernetes controllers such as DaemonSet and Replication.
  • Kublet: Responsible for the running state of each node (starting, stopping, and maintaining application containers).
  • Kube-proxy: The implementation of a network proxy and load balancer that supports the service abstraction.
  • cAdvisor: An agent that monitors and gathers resource usage.
  • Container runtime: As of the upcoming 1.22 release, Kubernetes support for Docker will be deprecated. Once this happens, Kubernetes will allows runtimes that use the Container Runtime Interface(CRI), such as containerd.

Additional resources

  • How Red Hat aims to make Kubernetes boring...and successful (TechRepublic)
  • Special report: Riding the DevOps revolution (free PDF) (TechRepublic)
  • Microsoft Azure's Kubernetes support demonstrates growing importance of containers (TechRepublic)
  • VMware goes all in on containers with Kubernetes as a Service (TechRepublic)
  • Why Kubernetes could be crowned king of container management (TechRepublic)
  • Enterprise container DevOps steps up its game with Kubernetes 1.6 (ZDNet)

Why does Kubernetes matter?

Containers are a powerful and flexible way to safely and reliably deploy applications and microservices to extend and expand your company's services. When the need grows beyond a standard Docker deployment or you need to deploy/manage multiple containerized applications from different systems (such as Docker), you need a way to deploy and control such systems.

With the help of Docker Swarm, you can deploy containerized applications over a cluster, but you're limited to Docker-only containers and to only using the architecture security, registry of Docker, Inc. With Kubernetes, those containers can come from a number of sources (Docker, Windows Server Containers, etc.), making Kubernetes incredibly flexible and significantly more complex.

Additional resources

  • Containers, DevOps, IT automation seen as antidotes to complexity (ZDNet)
  • How to establish strong microservice security using SSL, TLS and API gateways (TechRepublic)
  • Docker: The smart person's guide (TechRepublic)
  • 3 hybrid cloud alternatives to AWS CloudFormation (TechRepublic)
  • Why your traditional virtualization vendor can't help you with containers (TechRepublic)
  • Kubernetes orchestrator now available on Microsoft's Azure Container Service (ZDNet)

Who does Kubernetes affect?

Kubernetes affects any company that needs to deploy massive rollouts of containerized applications and services; this means anyone involved with the deployment should be familiar with the Kubernetes tools and Docker. And considering Kubernetes is a rather complex system, administrators will need to do a fair amount of homework in order to successfully implement the technology.

The effect of Kubernetes goes well beyond those that administer the system--customers, clients, staff, and consumers...no one is immune to the effect of containerized applications. When we're talking about business and enterprise-level deployments, Kubernetes takes center stage.

Developers are also affected by Kubernetes. As of 2020, Kubernetes had over 43,000 contributors from across varying industries, with over 43 branches and over 96,000 commits on GitHub. Kubernetes also has more developers working on it than Docker Swarm, Mesos, and Cloud Foundry Diego combined.

Additional resources

  • Why Red Hat makes more money on Docker than Docker does (TechRepublic)
  • 5 data center-ready Linux distributions (TechRepublic)
  • Special report: The cloud v. data center decision (free PDF) (TechRepublic)
  • eBay builds its own tool to integrate Kubernetes and OpenStack (ZDNet)

When is Kubernetes happening?

Kubernetes was created by Joe Beda, Brendan Burns, and Craig McLuckie, who were soon joined by other Google engineers, and was first announced by Google in mid-2014. The original name for Kubernetes was Seven Of Nine (from Star Trek Borg fame). Once the Google lawyers swayed the original developers away from the original name, they agreed upon the name Kubernetes.

Kubernetes v1.0 was released July 21, 2015 and very quickly wound up in the top 0.01% in stars and number 1 in terms of activity on GitHub. That translates to significant development on the project.

As of December, 2020, the latest release of Kubernetes is 1.18.12 with 27 merged pull requests, 87 open pull requests, 3.3k users watching the project, and 72.3k stars.

Additional resources

  • Mirantis enters the Kubernetes game and ups its OpenStack play (ZDNet)
  • Red Hat steps up its Kubernetes game with OpenShift Container 3.5 (ZDNet)
  • Microsoft to buy Kubernetes container-orchestration vendor Deis (ZDNet)
  • Docker open sources container runtime and management program containerd (ZDNet)

How do I start using Kubernetes?

Kubernetes can be deployed on numerous platforms, including:

  • Any supporting Linux platform, such as Red Hat

For a full list of vendors/platforms supporting Kubernetes deployment, check out this spreadsheet.

You will need to set up:

  • Kubernetes Controller: This is where you direct API calls to services that control the activities of the pods, replication controllers, services, nodes, and other components of the cluster.
  • Kubernetes Node(s): This system provides the run-time environments for the containers.

The Controller and Node can be on the same system, but traditionally they will be separated.

You will also need your containers. The most widely used containers deployed by Kubernetes are from Docker, which makes sense considering docker containers are the most widely used on the planet. And even though Kubernetes has deprecated support for Docker, you can still develop your containers or images with Docker and use them with Kubernetes.

Kubernetes must be installed on the Controller and all nodes. Remember, however, now that Kubernetes is about to deprecate Docker, you must install with a different runtime (such as containerd). For example, on Ubuntu Server 20.04, install Kubernetes and containerd with the following steps:

sudo apt-get update && sudo apt-get install -y apt-transport-https curl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - sudo -s cat Sheet

Additional resources

  • Kubernetes tutorials (Kubernetes)
  • Ebook: IT leader's guide to making DevOps work (TechRepublic Premium)
  • 6 quick Docker tips to make managing your containers easier (TechRepublic)
  • How to install WordPress with Docker (TechRepublic)
  • How to manage Docker containers from the command line (TechRepublic)
  • How to install Docker on Fedora 25 (TechRepublic)
  • How to install and use Portainer for easy Docker container management (TechRepublic)

See also: Kubectl Overview and JsonPath Guide.

This page is an overview of the kubectl command.

Kubectl Autocomplete

BASH

ZSH

Kubectl Context and Configuration

Set which Kubernetes cluster kubectl communicates with and modifies configurationinformation. See Authenticating Across Clusters with kubeconfig documentation fordetailed config file information.

Creating Objects

Kubernetes manifests can be defined in json or yaml. The file extension .yaml,.yml, and .json can be used.

Viewing, Finding Resources

Updating Resources

Patching Resources

Editing Resources

The edit any API resource in an editor.

Scaling Resources

Deleting Resources

Interacting with running Pods

Interacting with Nodes and Cluster

Resource types

List all supported resource types along with their shortnames, API group, whether they are namespaced, and Kind:

Other operations for exploring API resources:

Formatting output

Kubernetes Commands Pdf

To output details to your terminal window in a specific format, you can add either the -o or -output flags to a supported kubectl command.

Output formatDescription
-o=custom-columns=<spec>Print a table using a comma separated list of custom columns
-o=custom-columns-file=<filename>Print a table using the custom columns template in the <filename> file
-o=jsonOutput a JSON formatted API object
-o=jsonpath=<template>Print the fields defined in a jsonpath expression
-o=jsonpath-file=<filename>Print the fields defined by the jsonpath expression in the <filename> file
-o=namePrint only the resource name and nothing else
-o=wideOutput in the plain-text format with any additional information, and for pods, the node name is included
-o=yamlOutput a YAML formatted API object

Kubectl output verbosity and debugging

Kubernetes Cheat Sheet Github Free

Kubectl verbosity is controlled with the -v or --v flags followed by an integer representing the log level. General Kubernetes logging conventions and the associated log levels are described here.

VerbosityDescription
--v=0Generally useful for this to ALWAYS be visible to an operator.
--v=1A reasonable default log level if you don’t want verbosity.
--v=2Useful steady state information about the service and important log messages that may correlate to significant changes in the system. This is the recommended default log level for most systems.
--v=3Extended information about changes.
--v=4Debug level verbosity.
--v=6Display requested resources.
--v=7Display HTTP request headers.
--v=8Display HTTP request contents.
--v=9Display HTTP request contents without truncation of contents.

Kubernetes Cheat Sheet Commands

What's next

Download Kubernetes

  • Learn more about Overview of kubectl.

  • See kubectl options.

  • Also kubectl Usage Conventions to understand how to use it in reusable scripts.