☁️Orchestrating the Cloud with Kubernetes ☁️
What is Kubernetes?
Kubernetes is an open source project (available on kubernetes.io)
Kubernetes is a portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.
Major Learnings :
1)Provision a complete Kubernetes cluster using Kubernetes Engine.
2)Deploy and manage Docker containers using kubectl.
3)Break an application into microservices using Kubernetes' Deployments and Services.
Tasks and steps:
* Cluster: a cluster is a group of data that has members that are more similar to each other than they are to other groups.
- set the zone in cloud shell environment
- start up a cluster using "gcloud container clusters create io"
- copy the required source code to cloud shell using "gsutil cp -r url"
★Now lets get started with Kubernetes:
-The easiest way to get started with Kubernetes is to use the kubectl create command
- Use the kubectl get pods command to view the running nginx container
- Once the nginx container has a Running status you can expose it outside of Kubernetes using the kubectl expose command.
-List our services now using the kubectl get services command
- Add the External IP to this command to hit the Nginx container remotely
★Pods:
At the core of Kubernetes is the Pod. Pods represent and hold a collection of one or more containers. Generally, if you have multiple containers with a hard dependency on each other, you package the containers inside a single pod.
Pods can be created using pod configuration files
- Using cat command in cloud shell display the yaml file content
- Create monolith pod using "kubectl " command
- Examine your pods. Use the kubectl get pods command to list all pods running in the default namespace
-Once the pod is running, use kubectl describe command to get more information about the monolith pod
Interacting with Pods
By default, pods are allocated a private IP address and cannot be reached outside of the cluster. Use the kubectl port-forward command to map a local port to a port inside the monolith pod.
- Use kubectl port-forward command and "kubectl port-forward monolith 10080:80" in 2nd terminal to set up port-forwarding, then in 1st terminal strat talking to your pod using curl command.
-Use the kubectl logs command to view the logs for the monolith Pod.
-Use the kubectl exec command to run an interactive shell inside the Monolith Pod. This can come in handy when you want to troubleshoot from within a container
-once you have a shell into the monolith container you can test external connectivity using the ping command.
★Services
Services provide stable endpoints for Pods.The level of access a service provides to a set of pods depends on the Service's type. Currently there are three types:
-ClusterIP (internal) -- the default type means that this Service is only visible inside of the cluster
-NodePort gives each node in the cluster an externally accessible IP
-LoadBalancer adds a load balancer from the cloud provider which forwards traffic from the service to Nodes within it.
• Creating a service:
-Explore the monolith service configuration file using "cat services/monolith.yaml"
- Use "kubectl create" command to create the monolith service from the monolith service configuration file
★ Deploying applications with Kubernetes
The main benefit of Deployments is in abstracting away the low level details of managing Pods. Behind the scenes Deployments use Replica Sets to manage starting and stopping the Pods.
-Get started by examining the auth deployment configuration file
-Create your deployment object using "kubectl create"
-Use "kubectl create" command to create the auth service
-Now do the same thing to create and expose the hello deployment
-And one more time to create and expose the frontend Deployment.
-Interact with the frontend by grabbing its External IP and then curling using "kubectl get services frontend"
THE END --
Subscribe to my newsletter
Read articles from Khushi Pal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Khushi Pal
Khushi Pal
Hi, I'm Khushi 👋 👩💻 CS AI EngineeringUndergrad 💻 I'm currently Documenting my journey with - #100DaysOfCode 👀 Learning DevOps, Web development, Java & C language. I'm good with python 🐍 💙 #WomenInTech Taking help & helping 🥂