Ambassador Pod in Kubernetes ??

Ambassador Pod in Kubernetes ??


What is an Ambassador Container?

The ambassador container is a common pattern in Kubernetes and distributed systems. It acts as a proxy to provide additional functionality without modifying the main application.


Key Features ??

An ambassador container is a sidecar container that runs alongside the main application container in the same Pod, handling:

  • ?? Service discovery
  • ?? Load balancing
  • ?? Protocol translation
  • ??? Traffic routing
  • ?? Logging and monitoring


Why Use an Ambassador Container? ??

1. Decoupling Application Logic from Networking ??

  • Main application container stays focused on business logic
  • Ambassador handles networking concerns: Service discovery Load balancing Request retries

Example Configurations ??

Basic Nginx Ambassador Pod:

apiVersion: v1
kind: Pod
metadata:
  name: ambassador-nginx
  labels:
    app: ambassador-pod
spec:
  containers:
  - name: nginx
    image: nginx:stable
    ports:
    - containerPort: 80        

Ambassador Service:

apiVersion: v1
kind: Service
metadata:
  name: ambassador-service
spec:
  selector:
    app: ambassador-pod
  ports:
  - protocol: TCP
    port: 8081
    targetPort: 80        

Ambassador Pod with HAProxy ??

apiVersion: v1
kind: Pod
metadata:
  name: ambassador-pod
spec:
  containers:
  - name: main-container
    image: radial/busyboxplus:curl
    command: ["sh", "-c", "while true; do curl localhost:8080; sleep 5; done"]
  - name: ambassador-container
    image: haproxy:2.4
    ports:
    - containerPort: 8080
    volumeMounts:
    - name: haproxy-config
      mountPath: /usr/local/etc/haproxy/haproxy.cfg
      subPath: haproxy.cfg
  volumes:
  - name: haproxy-config
    configMap:
      name: haproxy-config        

HAProxy ConfigMap ??

apiVersion: v1
kind: ConfigMap
metadata:
  name: haproxy-config
data:
  haproxy.cfg: |
    frontend ambassador
      bind *:8080
      default_backend ambassador_service_svc
    backend ambassador_service_svc
      server svc ambassador-service:8081        

Useful Commands ??

Check Services:

kubectl get svc        

Apply Configuration:

kubectl apply -f <file.yaml>        

View Resources:

kubectl get po,svc        

Check Service Details:

kubectl describe svc ambassador-service        

View Logs:

kubectl logs ambassador-pod -c main-container        

View ConfigMaps:

kubectl get configmap        



要查看或添加评论,请登录

Hamza Shaukat的更多文章

  • Liveness-Readiness Probe

    Liveness-Readiness Probe

    In Kubernetes, Readiness and Liveness Probes are critical mechanisms for ensuring application reliability and…

  • Namespaces in Kubernetes

    Namespaces in Kubernetes

    Namespaces in Kubernetes are a logical isolation mechanism that helps organize and manage resources within a cluster…

    1 条评论
  • Blue/Green Deployment in Kubernetes ??

    Blue/Green Deployment in Kubernetes ??

    What is Blue/Green Deployment? ???? Blue/Green deployment minimizes downtime and risk by maintaining two identical…

  • Understanding Kubernetes Requests & Limits ????

    Understanding Kubernetes Requests & Limits ????

    ??? What's the Deal with Requests & Limits? Think of your Kubernetes cluster as a bustling city and pods as tenants in…

    6 条评论
  • Replication Controller

    Replication Controller

    Let me explain why Replication Controllers are used in Kubernetes, though it's worth noting that they have largely been…

    1 条评论
  • Multi-container Pod

    Multi-container Pod

    A Pod that contains multiple containers that need to work together and share resources. All containers in a Pod are…

  • Implementation of DevSecOps

    Implementation of DevSecOps

    A #DevSecOps engineer is in charge of ensuring the security of the software development process, which includes…

    1 条评论
  • Different Phases of the DevOps Lifecycle

    Different Phases of the DevOps Lifecycle

    Plan: Professionals determine the commercial need and gather end-user opinions throughout this level. In this step…

    1 条评论
  • What is the Future Scope of DevOps?

    What is the Future Scope of DevOps?

    The future scope of DevOps contains many areas in which it can be collaborated and used in an efficient manner: It can…

  • Five Phases of DevOps

    Five Phases of DevOps

    DevOps can be divided into many phases but majorly it is divided into 5 phases: Continuous Development Continuous…

社区洞察

其他会员也浏览了