From the course: Kubernetes for Java Developers

Kubernetes concepts and instantiation

From the course: Kubernetes for Java Developers

Start my 1-month free trial

Kubernetes concepts and instantiation

- [Instructor] We learned about the purpose of orchestration and how Kubernetes is one of the open-source solutions that fits there. Let's learn more about it in a bit more detail. First of all, Kubernetes is an ancient Greek word for helmsman, the person who steers the ship. As we explained earlier, Kubernetes is an open-source container orchestration project. Typically, our applications consist of multiple containers and runs on a cluster of machines. Kubernetes helps with managing the cluster of machines and scheduling containers on these machines. These are the two primary requirements amongst many others. Because it's open-source, it can run on your desktop, in the cloud, or on-prem. Kubernetes is a CNCF project. CNCF is a Cloud Native Computing Foundation is a vendor-neutral body that defines how cloud native applications can be built. Kubernetes is one of the projects there and there are many other projects such as Prometheus, Envoy, and containerd. The project is one of the most active open-source projects by the number of stars, forks, comments, and contributors. It is of course available at github.com/kubernetes/kubernetes You work with Kubernetes, you use Kubernetes API objects to describe your cluster's desired state. What applications or other workloads you want to run, what container images they use, the number of replicas, what network and Discord sources you want to make available and more. You set your desired state by creating objects using the Kubernetes API, typically via the command line interface, kubectl, or kube control. These API objects are also called as Kubernetes resources, typically a resource manifest file providing complete description of the object will be passed to the CLI. The CLI will then read the manifest and issue the command to the cluster to create or update these resources. You can also use the Kubernetes API directly to interact with the cluster, and set or modify the desired state. Once you have set your desired state, Kubernetes works to make the cluster's current state match the desired state. To do so, Kubernetes performs a variety of tasks automatically such as starting or restarting containers, scaling the number of replicas of a given application, and more. We'll discuss how Kubernetes achieves this later in the course. Kubernetes provides basic monitoring, logging, and health checking for your containers. So if any of the containers are not meeting the health requirements, then they are automatically abolished. Kubernetes also provides a rich ecosystem of tools, and that's what makes Kubernetes that much more a compelling option. Let's look at some of the Kubernetes resources that we're going to learn about in this course. A Pod is the basic building block of Kubernetes. The smallest and simplest unit in the Kubernetes object model that you create or deploy. A Pod might consist of either a single container or a small number of containers that are tightly coupled and that share resources. Containers in the Pod can communicate to each other using localhost and share the file system as well. These containers form a single cohesive unit of service, for example, a web server serving files with a separate side-car container refreshing the cache. The one-container-per-pod model is the most common Kubernetes use-case. In this case, you can think of a Pod as a wrapper around a single container and Kubernetes manages the Pod rather than the containers directly. Here is how a sample Kubernetes Pod manifest might look like. Let's walk through this. All Kubernetes resources must have apiVersion and kind fields. apiVersion is a strength that identifies the version of the schema the object should have. V1 in our case. Kind is a string that identifies the schema this object should have. Or, the Kubernetes object type. Pod, in our case. Metadata is a required field for all Kubernetes objects. The only mandatory field in that is name. This field allows a Pod to be uniquely identified amongst others. You can also specify name-space and view-ID. Labels is a map of string keys and values that can be used to organize and categorize objects. In our case, app colon greeting is a label attached to this Pod. Spec stands for specification and defines the desired state of an object. Containers define the list of containers belonging to the Pod. This is a static list and cannot be updated at run-time. We will use two fields in our case. Name gives the unique name to a container in the Pod. Image is the name of the docker image. This is the image of our Java application that was built earlier.

Contents