{"id":934,"date":"2019-12-19T07:04:49","date_gmt":"2019-12-19T07:04:49","guid":{"rendered":"https:\/\/blog.amt.in\/?p=934"},"modified":"2019-12-19T07:04:49","modified_gmt":"2019-12-19T07:04:49","slug":"introduction-to-kubernetes","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2019\/12\/19\/introduction-to-kubernetes\/","title":{"rendered":"Introduction to Kubernetes"},"content":{"rendered":"<p>Kubernetes\u00c2\u00a0is an\u00c2\u00a0open-source\u00c2\u00a0container-orchestration\u00c2\u00a0system for automating\u00c2\u00a0 application\u00c2\u00a0 \u00c2\u00a0deployment, scaling, and management.\u00c2\u00a0It was originally designed by Google, and is now maintained by the\u00c2\u00a0Cloud Native Computing Foundation. It aims to provide a &#8220;platform for automating deployment, scaling, and operations of application containers across clusters of hosts&#8221;.\u00c2\u00a0It works with a range of container tools, including\u00c2\u00a0Docker.\u00c2\u00a0Many\u00c2\u00a0cloud\u00c2\u00a0services offer a Kubernetes-based platform or infrastructure as a service (PaaS\u00c2\u00a0or\u00c2\u00a0IaaS) on which Kubernetes can be deployed as a platform-providing service. Many vendors also provide their own branded Kubernetes distributions.<\/p>\n<p>Kubernetes defines a set of building blocks (&#8220;primitives&#8221;), which collectively provide mechanisms that deploy, maintain, and scale applications based on CPU, memory\u00c2\u00a0or custom metrics.<span style=\"font-size: 14.1667px;\">\u00c2\u00a0 \u00c2\u00a0<\/span>Kubernetes is\u00c2\u00a0loosely coupled\u00c2\u00a0and extensible to meet different workloads. This extensibility is provided in large part by the Kubernetes API, which is used by internal components as well as extensions and containers that run on Kubernetes.\u00c2\u00a0The platform exerts its control over compute and storage resources by defining resources as Objects, which can then be managed as such. The key objects are:<\/p>\n<p><span id=\"Pods\" class=\"mw-headline\">Pods:<\/span><\/p>\n<p>A\u00c2\u00a0pod\u00c2\u00a0is a higher level of abstraction grouping containerized components. A pod consists of one or more containers that are guaranteed to be co-located on the host machine and can share resources.\u00c2\u00a0The basic scheduling unit in Kubernetes is a\u00c2\u00a0pod.<\/p>\n<p>The pod name is a reference to a pod of whales, docker as container has the logo as a whale. And the second reference is a pea pod, more than one pea in a pod.<\/p>\n<p>Each pod in Kubernetes is assigned a unique\u00c2\u00a0Pod\u00c2\u00a0IP address\u00c2\u00a0within the cluster, which allows applications to use ports without the risk of conflict.\u00c2\u00a0Within the pod, all containers can reference each other on localhost, but a container within one pod has no way of directly addressing another container within another pod; for that, it has to use the Pod IP Address. An application developer should never use the Pod IP Address though, to reference \/ invoke a capability in another pod, as Pod IP addresses are ephemeral &#8211; the specific pod that they are referencing may be assigned to another Pod IP address on restart. Instead, they should use a reference to a\u00c2\u00a0Service, which holds a reference to the target pod at the specific Pod IP Address.<\/p>\n<p><span id=\"Replica_Sets\" class=\"mw-headline\">Replica Sets:<\/span><\/p>\n<p>Replica Sets\u00c2\u00a0are a grouping mechanism that lets Kubernetes maintain the number of instances that have been declared for a given pod. The definition of a Replica Set uses a selector, whose evaluation will result in identifying all pods that are associated with it.<\/p>\n<p><span id=\"Services\" class=\"mw-headline\">Services:<\/span><\/p>\n<p>A Kubernetes service is a set of pods that work together, such as one tier of a\u00c2\u00a0multi-tier\u00c2\u00a0application. The set of pods that constitute a service are defined by a label selector.\u00c2\u00a0Kubernetes provides two modes of\u00c2\u00a0service discovery, using environmental variables or using Kubernetes DNS.\u00c2\u00a0Service discovery assigns a stable IP address and\u00c2\u00a0DNS name\u00c2\u00a0to the service, and load balances traffic in a\u00c2\u00a0round-robin\u00c2\u00a0manner to network connections of that IP address among the pods matching the selector (even as failures cause the pods to move from machine to machine).<\/p>\n<p><span id=\"Volumes\" class=\"mw-headline\">Volumes:<\/span><\/p>\n<p>Filesystems in the Kubernetes container provide ephemeral storage, by default. This means that a restart of the pod will wipe out any data on such containers, and therefore, this form of storage is quite limiting in anything but trivial applications. A Kubernetes Volume\u00c2\u00a0provides persistent storage that exists for the lifetime of the pod itself. This storage can also be used as shared disk space for containers within the pod. Volumes are mounted at specific mount points within the container, which are defined by the pod configuration, and cannot mount onto other volumes or link to other volumes. The same volume can be mounted at different points in the filesystem tree by different containers.<\/p>\n<p><span id=\"Namespaces\" class=\"mw-headline\">Namespaces:<\/span><\/p>\n<p>Kubernetes provides a partitioning of the resources it manages into non-overlapping sets called namespaces. They are intended for use in environments with many users spread across multiple teams, or projects, or even separating environments like development, test, and production.<\/p>\n<p><span id=\"ConfigMaps_and_Secrets\" class=\"mw-headline\">ConfigMaps and Secrets:<\/span><\/p>\n<p>A common application challenge is deciding where to store and manage configuration information, some of which may contain sensitive data. Configuration data can be anything as fine-grained as individual properties or coarse-grained information like entire configuration files or JSON \/ XML documents. Kubernetes provides two closely related mechanisms to deal with this need: &#8220;configmaps&#8221; and &#8220;secrets&#8221;, both of which allow for configuration changes to be made without requiring an application build. The data from configmaps and secrets will be made available to every single instance of the application to which these objects have been bound via the deployment. A secret and \/ or a configmap is only sent to a node if a pod on that node requires it. Kubernetes will keep it in memory on that node. Once the pod that depends on the secret or configmap is deleted, the in-memory copy of all bound secrets and configmaps are deleted as well. The data is accessible to the pod through one of two ways: a) as environment variables (which will be created by Kubernetes when the pod is started) or b) available on the container filesystem that is visible only from within the pod.<\/p>\n<p><span id=\"StatefulSets\" class=\"mw-headline\">StatefulSets:<\/span><\/p>\n<p>It is very easy to address the scaling of stateless applications: one simply adds more running pods\u00e2\u20ac\u201dwhich is something that Kubernetes does very well. Stateful workloads are much harder, because the state needs to be preserved if a pod is restarted, and if the application is scaled up or down, then the state may need to be redistributed. Databases are an example of stateful workloads. When run in high-availability mode, many databases come with the notion of a primary instance and a secondary instance(s). In this case, the notion of ordering of instances is important. Other applications like Kafka distribute the data amongst their brokers\u00e2\u20ac\u201dso one broker is not the same as another. In this case, the notion of instance uniqueness is important. StatefulSets\u00c2\u00a0are controllers (see\u00c2\u00a0Controller Manager, below) that are provided by Kubernetes that enforce the properties of uniqueness and ordering amongst instances of a pod and can be used to run stateful applications.<\/p>\n<p><span id=\"DaemonSets\" class=\"mw-headline\">DaemonSets:<\/span><\/p>\n<p>Normally, the location where pods are run are determined by the algorithm implemented in the Kubernetes Scheduler. For some use cases, though, there could be a need to run a pod on every single node in the cluster. This is useful for use cases like log collection, and storage services. The ability to do this kind of pod scheduling is implemented by the feature called DaemonSets.<\/p>\n<p>The above is a brief about Kubernetes. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes\u00c2\u00a0is an\u00c2\u00a0open-source\u00c2\u00a0container-orchestration\u00c2\u00a0system for automating\u00c2\u00a0 application\u00c2\u00a0<\/p>\n","protected":false},"author":1,"featured_media":937,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[511,510,509,7],"tags":[514,513,512,18],"class_list":["post-934","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automating-application","category-cloud-native","category-kubernetes","category-techtrends","tag-automating-application","tag-cloud-native","tag-kubernetes","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=934"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/934\/revisions"}],"predecessor-version":[{"id":936,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/934\/revisions\/936"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/937"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}