Kubernetes as a Service (Managed K8s)
- Every Cloud provider offers k8s as a service
- Azure = AKS
- AWS = EKS
- GCP = GKE
- K8s as a service basically means the master nodes will be managed by cloud provider
- Typical k8s cluster

- K8s as a Service

- Typical k8s cluster
-
Advantages:
- less administration
- nodes can be scaled
- inbuilt support for cloud integrations
-
In this course we will be using
- AKS
- EKS
Setting up basic k8s cluster in Azure (AKS)
- In this setups we configure kubectl on
- dev systems
- build servers

- install kubectl Refer Here or we can use azure cli to set it up
- Install azure cli: Refer Here
- Execute
az login - Refer Here for azure aks
- Create a resource group and continue according to docs Refer Here
Exposing Applications running in cluster to externally as well as internally when scaled
- Every pod gets a unique ip and name.
- Connecting from one pod to other on the basis of name/ip might not be a good idea as pods are controlled by replicasets or other controllers
- K8s has a service which helps us in connecting to pods with similar behaviour but by using labels.
- Each service gets a ip address and this is virtual ip which helps in forwarding traffic to one of the pod based on labels. This ip is called as cluster ip
- Services can be exposed to external world

- Service is similar to layer 4 load balancer
- Refer Here for official docs
Internal Communication using k8s service
- Consider the following
- We have an alpine pod which needs to consume nginx
- but nginx is a replica set and there can be n replicas
- Lets create a nginx-rs


- Create an alpine pod and login into that

- ping nginx-svc by its ip address and try accessing the web page using curl

- access nginx-svc by using name

- now do nslookup based on name

- Look into environment variables in alpine pod (Alpine was created post nginx service creation)

- Look into environment variables in nginx pods (These were created prior to nginx service)

- Refer Here for internal communication manifests
External Communication using k8s service
- Some user external to k8s cluster wants to access nginx

- Kubernetes has the service publishing types Refer Here
- Cluster ip: internal communication
- Node Port: k8s will expose the application on a port on every node in k8s cluster.

- LoadBalancer: This is generally used with managed k8s clusters

- ExternalName: Creates a CNAME record that can be used in your DNS Servers
- We have created a manifest with loadBalancer

- Refer Here for the spec
