Understanding Pods, Nodes, Deployments and Services

Pods and nodes are both fundamental concepts in the Kubernetes architecture, but they serve different purposes. A pod is the smallest deployable unit in Kubernetes, representing a single instance of a running process in a cluster. A pod can contain one or more tightly-coupled containers that share the same network namespace and storage volumes. All containers in a pod run on the same node, and they can communicate with each other using local host networking. ...

September 13, 2024 · 12 min

Pod Session Management with Redis

Consider a huge monolith application which is running on a single EC2 and you want to swap it into the microservices architecture. From the infra perspective, you have to setup cluster with a namespace for these microservices and associate pods as applications to run in. Now as pods are running, it how do you manage user sessions? Let’s say if a pod gets deleted somehow, the user will be signed out of the application which you do not want to happen. ...

September 13, 2024 · 2 min

Pod Preemption Priority

pod priority via their yaml - preemptionPolicy: PreemptLowerPriority priority: 0 https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/ Priority class - non-namespaced object that defines a mapping from a priority class name to the integer value of the priority. They are used to prioritize pods to be scheduled before and come with apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority value: 1000000 globalDefault: false description: "This priority class should be used for XYZ service pods only." (preemptionPolicy: PreemptLowerPriority is default) Non-preempting class example - apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: high-priority-nonpreempting value: 1000000 preemptionPolicy: Never globalDefault: false description: "This priority class will not cause other pods to be preempted." Pod with priority-class ...

September 13, 2024 · 3 min

Kubernetes Design Patterns

Multi-container design patterns Sidecar pattern An extra container in your pod to enhance or extend the functionality of the main container. Ambassador pattern A container that proxy the network connection to the main container. Adapter pattern A container that transform output of the main container. Reference - https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns/ The idea for a sidecar container is to add some functionality not present in the main container. Rather than bloating code, which may not be necessary in other deployments, adding a container to handle a function such as logging solves the issue, while remaining decoupled and scalable. Prometheus monitoring and Fluentd logging leverage sidecar containers to collect data. ...

September 13, 2024 · 2 min

Kubernetes Volumes Deep Dive

References https://stackoverflow.com/questions/45511339/kubernetes-minikube-with-local-persistent-storage https://platform9.com/blog/tutorial-dynamic-provisioning-of-persistent-storage-in-kubernetes-with-minikube/ https://stackoverflow.com/questions/66355331/deployment-cannot-find-pvc-on-minikube minikube supports hostPath mount out of box - minikube mount D:/vscode/devops:/usr/volume kubectl api-resources --namespaced=false # returns resources which are cluster-wide kubectl api-resources --namespaced=true # resources which are ns scoped PVCs request from storage classes - https://kubernetes.io/docs/concepts/storage/storage-classes/ PVC are ns scoped so 2 pvc can have same name if in different ns. for minikube generate another storage class as classic uses a specific path Setting up own PV and VPC For creating own pv, pvc you need to create a storage class as well as only then it will use the pv you creted otherwise will create dynamic allocation. ...

September 13, 2024 · 10 min

Deployments and Replicasets

Both Deployments and ReplicaSets are designed to manage stateless applications in Kubernetes. This means that they are not responsible for managing any application state or data storage. Instead, they manage the deployment and scaling of stateless pods that run the application code. In a stateless application, each pod is independent and interchangeable, and can be scaled up or down as needed. The application state is typically stored in a separate data store, such as a database, that is managed independently of the pods. ...

August 25, 2024 · 2 min

AWS SNS using boto3 SDK

Topic in SNS In Amazon Simple Notification Service (SNS), a topic is an access point for allowing subscribers to receive notifications or messages. When you publish a message to a topic, SNS sends the message to all the subscribers of that topic. Sending files as attachments Yes, you can use Amazon Simple Notification Service (SNS) to send a CSV file stored in an Amazon S3 bucket as an attachment in an email notification. Here are the high-level steps to achieve this: ...

August 15, 2024 · 2 min

AWS Roadmap

Devops is mainly three things - Infrastructure Automation Monitoring Infrastructure You need a server for hosting, server is an infrastructure. You need database for backend, database is infrastructure. It refers to the underlying system and hardware responsible for development and delivery. Automation It means automating stuff being done manually to waste less time doing the same stuff. Monitoring It means keeping track of application working, finding problems and bugs and fixing them right away. ...

August 12, 2024 · 2 min

Apache server advanced topics

MaxRequestWorkers MaxRequestWorkers is a configuration directive in the Apache web server that specifies the maximum number of simultaneous connections that the server can handle. It determines the maximum number of child processes or threads that can be spawned by the server to handle incoming requests. The MaxRequestWorkers directive is typically set in the Apache configuration file (httpd.conf) and determines the maximum number of worker processes that Apache can create to serve client requests. Each worker process can handle one client request at a time. When the maximum number of workers is reached, additional requests will be queued, waiting for a worker process to become available. ...

August 8, 2024 · 23 min

MongoDB ReplicaSet Setup Explained

For rstarting up a 3 node cluster with 1 master and 2 slaves follow this https://medium.com/swlh/mongodb-creating-a-3-node-replica-set-cluster-7ca94849b139 First we need a keyfile and appropriate permissions. If the mongod processes were actually running on different machines, then each machine will have a copy of this keyfile. Use OpenSSL to create keyfile - sudo mkdir -p /usr/local/var/mongodb/pki/ openssl rand -base64 741 > /usr/local/var/mongodb/pki/replicaset-keyfile chmod 400 /usr/local/var/mongodb/pki/replicaset-keyfile Create Mongod config files to start mongod processes. Here we will fork the processes to run multiple mongo. ...

July 30, 2024 · 2 min