Managed Kubernetes or Kubernetes as a Service
- Managed Kuberenetes (Kubernetes as a Service) is the offerings from various cloud providers.
- In these Control-Plane is managed by Cloud Service Providers and they charge you hourly for that
- For worker nodes, storage and other resources charges are as usual.
- Popular Kuberentes offerings
- AKS (Azure Kubernetes Services)
- EKS (Elastic Kuberentes Services)
- GKE (Google Kubernetes Engine)
AKS
- Install kubectl in your system
choco install kubernetes-cli
# mac
brew install kubectl
- Creating AKS Cluster
- CLI Refer Here
- Portal Refer Here
Activity: Create a replica set
- Apply the replicaset
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-rs
labels:
app: nginx
purpose: svcdemo
spec:
replicas: 3
minReadySeconds: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginxc
image: nginx:1.25
ports:
- containerPort: 80
protocol: TCP
env:
- name: purpose
value: learning
- name: why
value: dontknow

* Refer Here for the changes that include adding environmental variables in the container

- Lets create the service and expose it using the LoadBalancer. Azure internally takes request from cloud controller manager and creates a Load Balancer and all the necessary rules to expose the nginx service on Azure Load Balancer
- Apply the service

- We get the external ip which represents the ipaddress of the loadbalancer. Now access by using
http://<lb-ip>:<port>

- Refer Here for the changeset
-
Exercise:
- Write a spec to expose jenkins/jenkins which runs on 8080 port using nodePort on Port 30001
- DNS:
- A record
- CName Record
- Service with external name
---
apiVersion: v1
kind: Service
metadata:
name: nginx-svc-external
labels:
app: nginx
purpose: svcdemo
spec:
type: ExternalName
externalName: nginx.qt.com
selector:
app: nginx
Deployments
- Refer Here for the official docs
- Overview

- Deployment is a workload which creates
- Replica Sets: These create
- Pods: Which inturn creates
- Containers: This is where the applcation runs

- Containers: This is where the applcation runs
- Pods: Which inturn creates
- Replica Sets: These create
- Kubernetes Deployments creates Replicaset which can be persisted which helps us in performing rolling updates and rollbacks
- Lets create a basic template for deployment of nopCommerce. The image will be
shaikkhajaibrahim/nopcommerceaug23
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nop-deploy
spec:
minReadySeconds: 5
replicas: 4
selector:
matchLabels:
app: nop
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
app: nop
version: v1.1
spec:
containers:
- name: nop
image: shaikkhajaibrahim/nopcommerceaug23
ports:
- containerPort: 80
protocol: TCP
- Apply the deployment and check the objects

Performing Rolling updates and Rollback using Deployments
-
Lets create a k8s manifest to deploy an application
shaikkhajaibrahim/deploy-sample - Lets create with 10 replicas and a service exposed via loadbalancer
- Refer Here for the changes done
- Apply the deployment and set the current namespace to prod
kubectl config set-context --current --namespace=prod
- Now create service

- Access the application

- Now we have some extra commands

- Annotation: Refer Here
- We will be adding an annotation to add change cause
kubernetes.io/change-cause - apply the deployment Refer Here for changes

- Lets rollback to revision 1

Health Checks in Kubernetes
- Types of HealthChecks

- Probe Types
- Exec
- TCP
- HTTP
- GRPC
- Lets write liveness, readiness probes in the deployment spec
- Probes are written as part of container spec
- Refer Here for a sample
