Posts

Showing posts from January 20, 2022

Kubernetes objects with practical examples

  1. Pod Example : Suppose you have a simple web application with a single container. Definition : A Pod could be defined as follows: apiVersion: v1 kind: Pod metadata: name: my-web-app spec: containers: - name: web-container image: nginx:latest ports: - containerPort: 80 Explanation : This Pod definition runs an Nginx container, exposing port 80. 2. Service Example : To expose the my-web-app Pod so it can be accessed from other Pods or externally. Definition : A Service could be defined as follows: apiVersion: v1 kind: Service metadata: name: my-web-service spec: selector: app: my-web-app ports: - protocol: TCP port: 80 targetPort: 80 type: LoadBalancer Explanation : This Service targets Pods with the label app: my-web-app and exposes port 80. The LoadBalancer type will provision an external IP address (if supported by the cloud provider). 3. Deployment Example : To deploy multiple re...