Completek8s Classroomnotes 03/Sep/2023

Kubernetes Networking contd…

Internet/External to Service Networking (contd)

  • Routing traffic to Kubernetes (Ingress)
    • Layer 4: Load Balancer
    • Layer 7: Ingress Controller

Layer 4 Load Balancer

  • When we create a k8s service, we can specify the type LoadBalancer. The implementation of Load Balancer is given by cloud controller which knows how to create a load balancer for your service

Preview

Kubernetes Service

Node Port

  • This service provides a simple way for external software to route traffic to pods
  • Nodeport service exposes a fixed port on all nodes, which routes to applicable pods.
  • nodePort (.spec.ports[].nodePort) field specify the port to be opened all all nodes for the corresponding port on Pods
  • While creating the service if we leave nodePort field empty k8s will automatically selects a unique port 30000-32767
  • nginx deployment
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
  • Lets use nginx with nodePort
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
    - name: nginx-svc
      protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30000

Preview

  • We will try LoadBalancer and ExternalName in future sessions
  • Note: K8s doesnot have an inbuilt layer 7 load balancer, so we need to understand ingress and ingress controller.

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube