Skip to main content

Posts

Introduction and Contents

In this module, you'll gain an understanding of the microservice architectural pattern and the problems it solves. You'll see how you can use Docker to implement the microservice architectural pattern with an ASP.NET web API and Kubernetes as the container orchestrator. What is Microservice Architecture What is an image Dockerfile Push a microservice to Dockerhub Role of Containers Container Management and Orchestration dotnet run vs dotnet publish CI/CD Microservices Orchestration Docker compose Kubernetes What is a Cluster in Kubernetes What is a Pod in Kubernetes Containers and Pods Services in K8s Workloads  - This is to k8s official documentation, can read about everything K8s there Connect to a kubernetes cluster Service Accounts Terraform What is a node in Kubernetes Kubectl Networking in Kubernetes Minikube  *References  https://learn.microsoft.com/en-us/training/paths/create-microservices-with-dotnet/?source=learn https://jamesdefabia.github.io/
Recent posts

Services in K8s

In Kubernetes, a Service is a method for exposing a network application that is running as one or more  Pods  in your cluster. The set of Pods targeted by a Service is usually determined by a  selector  that you define. For example, consider a stateless image-processing backend which is running with 3 replicas. Those replicas are fungible—frontends do not care which backend they use. While the actual Pods that compose the backend set may change, the frontend clients should not need to be aware of that, nor should they need to keep track of the set of backends themselves.  The Service abstraction enables this decoupling. Here is an example of a service of type NodePort which exposes a port(Nodeport) of a Node in the kubernetes cluster and also describes which port on the pod would the calls be forwarded to (targetPort) - *A nodePort is a temporary solution to expose the applications to the internet, usually done for testing purposes, other types of services e.g. ...

Conatiners and Pods

  A pod can have multiple containers All containers inside a Pod share the same network stack, which includes the following IP Address Network interfaces Routing tables Ports Every pod has a unique IP address and all containers inside a pod have the same IP address as that of the pod and that is why the containers inside the same pod are able to talk to each other using localhost If two containers within the same Pod attempt to bind to the same port, it will result in a conflict Here is an example from a yaml file where the "containerPort"s are the ports which tell kubernetes that the respective applicaton is running inside the container on this port, so when someone wants to access this application, they will have to make a call to the same port number on the Pod and then the Pod will forward the request to the same port number on the container, by default the ports on the pod are mapped to the same port numbers in contianers  spec: containers: - name: eggpla...

Connect to a kubernetes cluster

When we say "connect to a Kubernetes cluster," we are referring to the process of establishing a connection from your local development environment or another system to a Kubernetes cluster. Kubernetes is a container orchestration platform that allows you to automate the deployment, scaling, and management of containerized applications. Connecting to a Kubernetes cluster involves interacting with the Kubernetes API server, which is the central control point for managing the cluster. The Kubernetes API server, often referred to simply as the "API server," is a component of the Kubernetes control plane. It is a central component that exposes the Kubernetes API, which is used for managing the entire cluster. The API server acts as the front-end for the Kubernetes control plane and is responsible for processing RESTful API requests, validating them, and then updating the corresponding objects in the cluster, such as pods, services, and deployments. API server exists in ...

Terraform

It is an Infrastructure as Code tool Normally, if one has to configure VMs or other resources on the cloud, they have to go to the cloud provider's website and click a lot to get things done as supposed, terraform can do all of that provided you tell it precisely what to do in a .tf file e.g. which cloud provider you are using(GCP, Azure etc), which resource to configure with what specifications. One writes the file in hashicorp language (kinda like JSON) Free and Open source One has to install the CLI terraform init terraform apply  (to make the changes to cloud) terraform destroy

GKE onboarding and best practices

GKE Docs: https://cloud.google.com/kubernetes-engine/docs/ Create a cluster in GKE Autopilot mode In Autopilot mode, Google manages most of the infrastructure and provides a more managed K8s experience than GKE Standard mod Create an Autopilot cluster by specifying a name and region. After the cluster is created, you can deploy your workload through Kubernetes and Google will take care of the rest, including:    Nodes:  Automated node provisioning, scaling, and maintenance    Networking:  VPC-native traffic routing for public or private clusters    Security:  Shielded GKE Nodes and Workload Identity    Telemetry:  Cloud Operations logging and monitoring When creating a cluster, Google cloud asks for Network configurations for the cluster Public clusters:  Choose a public cluster to configure access from public networks to the cluster's workloads. Routes aren't created automatically. You cannot change this setting after t...