Skip to content

Instantly share code, notes, and snippets.

View iamabhishek-dubey's full-sized avatar
🎯
Focusing

Abhishek Dubey iamabhishek-dubey

🎯
Focusing
View GitHub Profile

K8s | Ingress Lab

Problem Statement:-

In this lab, we will use ingress to map our internal services to the domain and use a fanout to access our backend. We will have below rules in our ingress:

  • -ems.k8slearning.io -> Frontend
  • -ems.k8slearning.io/attendance -> Attendance service
  • -ems.k8slearning.io/gateway -> Gateway service

By the end of this lab, you will have ingress in place to manage external access.

K8s | PVC Lab

Problem Statement:-

In this lab we will add persistent volume to our MySQL service and will try to recreate without worrying too much on which node it will get created:

By the end of this lab, you have a fully functional durable Attendance functionality.

What you will not have is various advanced features such as:

  • Autoscaling
image:
repository: quay.io/cortexproject/cortex
tag: v1.6.0
pullPolicy: IfNotPresent
clusterDomain: cluster.local
tags:
blocks-storage-memcached: false
ingress:
enabled: false
annotations:

K8s | Volume Lab

Problem Statement:-

In this lab we will add volume to our MySQL service and externalize the connectivity details of Attendance & Gateway MS:

  • MySQL: Should use hostPath for volume mounting
  • Attendance: Should use the secret for MySQL connectivity
  • Gateway: Should use ConfigMap for Attendance connectivity
  • ES: Use emptyDir

K8s | Deployment Lab

Problem Statement:-

In this lab we will deploy a few of our microservices in the Kubernetes cluster using Kubernetes Deployment:

  • MySQL
  • Attendance
  • Gateway
  • Frontend

K8s | Service Lab

Problem Statement:-

In this lab we will create services on top of our deployed microservices so that they can talk to each other and making our webserver MS publically accessible:

Expose Internally

  • MySQL
  • Attendance

K8s | Replicaset Lab

Problem Statement:-

In this lab we will try to see the failover/recovery capability of replicaset:

  • Delete the previously created pods of MySQL & attendance
  • Create a replica set of MySQL having 1 replica
    • Pass database name as an env variable
    • Provide port 3306 as a container port
  • Create a replica set of attendance having 2 replica

K8s | Pod Lab

Problem Statement:-

In this lab, we will run MySQL and attendance MS in our k8s cluster using the pod resource of Kubernetes

By the end of this lab you will be able to run your MS using the first resource or kind of k8s i.e Pod.

What you will not have is auto-recovery of your MS if the pod crashes due to any reason you have to manually create the pod again.

<h1 id="k8s-kubectl-lab">K8s | Kubectl Lab</h1>
<p>Let&#39;s try to run an elasticsearch container on Kubernetes.</p>
<h2 id="installation">Installation</h2>
<p>Kubectl is a command-line tool for controlling Kubernetes clusters.</p>
<h3 id="linux">Linux</h3>
<p>Download the latest release with the command:</p>
<pre><code class="lang-shell">curl -LO https:<span class="hljs-regexp">//</span>storage.googleapis.com<span class="hljs-regexp">/kubernetes-release/</span>release<span class="hljs-regexp">/`curl -s https:/</span><span class="hljs-regexp">/storage.googleapis.com/</span>kubernetes-release<span class="hljs-regexp">/release/</span>stable.txt`<span class="hljs-regexp">/bin/</span>linux<span class="hljs-regexp">/amd64/</span>kubectl
</code></pre>
<p>Make the kubectl binary executable.</p>
<pre><code class="lang-shell"><span class="hljs-keyword">chmod</span> +<span class="hljs-keyword">x</span> ./kubectl
<h1 id="k8s-minikube">K8s | Minikube</h1>
<p>Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.</p>
<p>Make sure you have VirtualBox installed.
(Download &amp; Install VirtualBox) : <a href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a></p>
<h3 id="linux">Linux</h3>
<p>Download Minikube:</p>
<pre><code class="lang-shell">curl -Lo minikube https:<span class="hljs-regexp">//</span>storage.googleapis.com<span class="hljs-regexp">/minikube/</span>releases<span class="hljs-regexp">/latest/mi</span>nikube-linux-amd64 &amp;&amp; chmod +x minikube
</code></pre>
<p>Install Minikube:</p>
<pre><code class="lang-shell">sudo mkdir -p <span class="hljs-regexp">/usr/</span>local<span class="hljs-regexp">/bin/</span>