{"id":190,"date":"2022-07-26T09:52:54","date_gmt":"2022-07-26T06:52:54","guid":{"rendered":"https:\/\/akhmees.info\/en\/?p=190"},"modified":"2022-07-26T09:52:54","modified_gmt":"2022-07-26T06:52:54","slug":"kubernetes-crash-course-from-techworld-with-nana","status":"publish","type":"post","link":"https:\/\/akhmees.info\/en\/2022\/07\/26\/kubernetes-crash-course-from-techworld-with-nana\/","title":{"rendered":"Kubernetes Crash Course From TechWorld with Nana"},"content":{"rendered":"<p><a href=\"https:\/\/www.youtube.com\/watch?v=s_o8dwzRlu4&amp;list=PLrE72rlGNTZ0Bo4q0Futm2pe_cDoeomRY&amp;index=1&amp;t=3222s\">Source<\/a><\/p>\n<h2>Misc<\/h2>\n<p><strong>- K8s:<\/strong> Full blown Kubernetes.  3 x K8s masters, 3 x etcd, 2 x Ingress plus your worker nodes<\/p>\n<ul>\n<li>\n<p><strong>K3s:<\/strong>  Designed to be a single binary of less than 40MB that completely implements the Kubernetes API. In order to achieve this, they removed a lot of extra drivers that didn't need to be part of the core and are easily replaced with add-ons.<\/p>\n<h2>Intro<\/h2>\n<ul>\n<li>Kubrenebts is OSS orchestration tool<\/li>\n<li>Developed by Google<\/li>\n<li>Help you manage containerized applications <\/li>\n<li>How Kubernetes can help you?\n<ul>\n<li>Move from Monolithic to Microservices\n<ul>\n<li>Apps divided to microservices<\/li>\n<\/ul>\n<\/li>\n<li>Manage those containers (that could be 100 or more)<\/li>\n<\/ul>\n<\/li>\n<li>What features Kubernetes offers ?\n<ul>\n<li>HA<\/li>\n<li>Scalability<\/li>\n<li>DR - backup and restore<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Kubernetes Architecture<\/h2>\n<figure id=\"attachment_192\" aria-describedby=\"caption-attachment-192\" style=\"width: 976px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.JPS_.240.png\" alt=\"\" width=\"976\" height=\"815\" class=\"size-full wp-image-192\" srcset=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.JPS_.240.png 976w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.JPS_.240-300x251.png 300w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.JPS_.240-768x641.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><figcaption id=\"caption-attachment-192\" class=\"wp-caption-text\">K8 Architecture<\/figcaption><\/figure>\n<ul>\n<li>Kubelet: agent that the cluster use to communicate. <\/li>\n<li>Master node:\n<ul>\n<li>Important K8s processes that are running here to manage the cluster\n<ul>\n<li>API server:\n<ul>\n<li>Entry point to K8s cluster\n<ul>\n<li>Different clients talks to. like UI or CLI<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Controller Manager:\n<ul>\n<li>Keep tracks of what happening in the cluster, if an application die and needs to be restarted etc.<\/li>\n<\/ul>\n<\/li>\n<li>Scheduler:\n<ul>\n<li>Intelligent scheduler to Pods, and decide which node the Pod should be scheduled depending on utilization<\/li>\n<\/ul>\n<\/li>\n<li>ETCD\n<ul>\n<li>K8 backing store (key\/value): Hold all the data on the cluster (Pods status etc ) - so recovery usually starts with this storage.<\/li>\n<\/ul>\n<\/li>\n<li>Virtual network <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Kubernetes Main Component<\/h2>\n<figure id=\"attachment_195\" aria-describedby=\"caption-attachment-195\" style=\"width: 1553px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.2022.29.png\" alt=\"\" width=\"1553\" height=\"1170\" class=\"size-full wp-image-195\" srcset=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.2022.29.png 1553w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.2022.29-300x226.png 300w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.2022.29-1024x771.png 1024w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.2022.29-768x579.png 768w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Paper.2022.29-1536x1157.png 1536w\" sizes=\"auto, (max-width: 1553px) 100vw, 1553px\" \/><figcaption id=\"caption-attachment-195\" class=\"wp-caption-text\">## Kubernetes Main Component<\/figcaption><\/figure>\n<figure id=\"attachment_196\" aria-describedby=\"caption-attachment-196\" style=\"width: 478px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-17-at-2.17.06-PM.png\" alt=\"\" width=\"478\" height=\"592\" class=\"size-full wp-image-196\" srcset=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-17-at-2.17.06-PM.png 478w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-17-at-2.17.06-PM-242x300.png 242w\" sizes=\"auto, (max-width: 478px) 100vw, 478px\" \/><figcaption id=\"caption-attachment-196\" class=\"wp-caption-text\">Pod close look<\/figcaption><\/figure>\n<ul>\n<li>\n<p>Pod:  <em>the square in blue<\/em><\/p>\n<ul>\n<li>Smallest unit in Kubernetes.<\/li>\n<li>A layer on top of Container, so regardless of container technology - Kubrenetes abstract that away that from you.<\/li>\n<li>Usually 1 Application per Pod<\/li>\n<li>Each Pod get an IP (internal IP)<\/li>\n<li>Pod: are ephemeral , so when Pod dies because  he applications inside  it dies, another Pod get created and get a new ip address<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Service:<\/p>\n<ul>\n<li>DNS name.<\/li>\n<li>It acts as load balancer between Pods.<\/li>\n<li>Permeant ip than can be attached to the Pod<\/li>\n<li>Lifecycle of <em>Pod<\/em> and <em>Service<\/em> are not connected. <\/li>\n<li>Type of service:\n<ul>\n<li>External : <a href=\"https:\/\/node-ip:port\">https:\/\/node-ip:port<\/a> (for web server, for testing).<\/li>\n<li>Internal: https:\/\/ db-service-ip:port (for backend services).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Ingress<\/p>\n<ul>\n<li>Requests get received here, and then <em>Ingress<\/em> forward it to Service.<\/li>\n<li>Kubernetes traffic gateway<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>ConfigMap<\/p>\n<ul>\n<li>External config for your application.<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Secrets<\/p>\n<ul>\n<li>User stores secret data in Base64 format. <\/li>\n<li>This doesn't make things secure by default, where you need 3rd party tools. (like Vault?)<\/li>\n<li>Certificates get stored here as well. <\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Volumes<\/p>\n<ul>\n<li>The component which attach storage to Pods, whether a local storage or remote storage (Cloud,  etc. )<\/li>\n<li>K8 doesn't manage data persistence, it's on you to backup it etc.<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Deployment<\/p>\n<ul>\n<li>Used for StateLess Apps<\/li>\n<li>Blueprint for &quot;my-app&quot; podcs<\/li>\n<li>A layer of abstractions of Pods (where you don't work with Pods directly)<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Statefulset<\/p>\n<ul>\n<li>Used for STATEFUL apps or Databases (<em>but if it's 1 replica, it's okay to use deployment<\/em>)\n<ul>\n<li>Examples:\n<ul>\n<li>Mongodb<\/li>\n<li>Elastic<\/li>\n<li>MySQL<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>You create those services using <em>Statefulsets<\/em> and not <em>Deployments<\/em>. <\/li>\n<li>Will take care of replicating the Pods<\/li>\n<li>Not easy to deploy stateful apps in K8<\/li>\n<li>Sometimes you have put the database outside of K8<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Kubernetes Configuration<\/h2>\n<ul>\n<li>API server is the gateway for the clients<\/li>\n<li>Request is either in JSON or YAML<\/li>\n<\/ul>\n<h3>3 important parts in Kubrenetes configuration file<\/h3>\n<ol>\n<li><strong>Metadata:<\/strong> what we are creating, Service or xxxx)<\/li>\n<li><strong>Specification:<\/strong> What is the specification of the container? (how many replica, what's the desired state)<\/li>\n<li>Status: Automatically generated and added by Kubernetes. The cluster information and containers state gets stored in etcd. <\/li>\n<\/ol>\n<h4>YAML Configuration File<\/h4>\n<ul>\n<li>Syntax: Strict indentation. <\/li>\n<\/ul>\n<h2>Demo time<\/h2>\n<h3>Demo architecture<\/h3>\n<figure id=\"attachment_197\" aria-describedby=\"caption-attachment-197\" style=\"width: 2838px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM.png\" alt=\"\" width=\"2838\" height=\"1566\" class=\"size-full wp-image-197\" srcset=\"https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM.png 2838w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM-300x166.png 300w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM-1024x565.png 1024w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM-768x424.png 768w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM-1536x848.png 1536w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM-2048x1130.png 2048w, https:\/\/akhmees.info\/en\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-06-20-at-7.24.20-AM-1568x865.png 1568w\" sizes=\"auto, (max-width: 2838px) 100vw, 2838px\" \/><figcaption id=\"caption-attachment-197\" class=\"wp-caption-text\">K8 Demo architecture<\/figcaption><\/figure>\n<h4>Notes while deploying the demo:<\/h4>\n<ul>\n<li>Pods has it own spec section. <\/li>\n<li>It's common to put Deployment and <strong>Service<\/strong> in the same file.<\/li>\n<li>Labels\n<ul>\n<li>Labels are external identifiers than can be attached to K8 containers<\/li>\n<li>For Pods, <em>Labels<\/em> are required. <\/li>\n<li>Label Selectors:\n<ul>\n<li>Identify a set of resources<\/li>\n<li>Match all Pods with labels &quot;app:nginx&quot; \u2192 knows which Pods are part of this deployment<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Service\n<ul>\n<li>Target port should always forward to Container port<\/li>\n<li>You need to make the service accessible from outside, and this happen with Node port.<\/li>\n<li>There's a range for NodePort that's already defined in Kubernetes, you cannot just use any port. <\/li>\n<\/ul>\n<\/li>\n<li><strong>Before deploying<\/strong>\n<ul>\n<li>ConfigMAP &amp; Secrets needs to exists before running deployments<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>Issues I ran into while deploying the demo<\/h4>\n<ul>\n<li>ImagePullBackOff<br \/>\n<a href=\"https:\/\/www.tutorialworks.com\/kubernetes-imagepullbackoff\/\">https:\/\/www.tutorialworks.com\/kubernetes-imagepullbackoff\/<\/a> <\/li>\n<li>Restart a deployment<\/li>\n<\/ul>\n<h3>Useful commands<\/h3>\n<ul>\n<li>kubectl get all<\/li>\n<li>kubectl get node -o wide<\/li>\n<li>kubectl describe <em>component name<\/em> (i.e: pods ) id<\/li>\n<li>kubectl rollout restart <em>name<\/em><\/li>\n<li>kubectl apply -f webapp.yaml  (when you change configuration file)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Source Misc &#8211; K8s: Full blown Kubernetes. 3 x K8s masters, 3 x etcd, 2 x Ingress plus your worker nodes K3s: Designed to be a single binary of less than 40MB that completely implements the Kubernetes API. In order to achieve this, they removed a lot of extra drivers that didn&#8217;t need to be &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/akhmees.info\/en\/2022\/07\/26\/kubernetes-crash-course-from-techworld-with-nana\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Kubernetes Crash Course From TechWorld with Nana&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[36],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-k8","entry"],"_links":{"self":[{"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":7,"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/posts\/190\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/akhmees.info\/en\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}