Completek8s Classroomnotes 02/Sep/2023

Kubernetes Networking

DNS in k8s

  • Kubernetes comes with DNS implementation by using CoreDNS
  • Kubernetes DNS runs as regular service that is scheduled on the cluster.
  • This configures kubelet running on each node so that containers use the DNS service IP’s to resolve DNS Name.
  • The service exists with name kube-dns in kube-system namespace

Activity: Create a k8s service with 3 nginx pods in deployment

  • Overview
  • Deployment
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

  • Service yaml
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  selector:
    app: nginx
  ports:
    - name: nginx-svc
      protocol: TCP
      port: 80
  • get endoints
  • Get Endpoint slices

Endpoints

  • Endpoints help identify what pods are running for the service, Endpoints are created and managed by services
  • Now lets describe endpoint
apiVersion: v1
kind: Endpoints
metadata:
  name: nginx-svc
subsets:
- addresses:
  - ip: 192.168.0.8
    nodeName: controlplane
    targetRef:
      kind: Pod
      name: nginx-deployment-cbdccf466-6q5f9
      namespace: default
      uid: 9e2da211-7213-40de-921f-7e871690fcac
  - ip: 192.168.1.3
    nodeName: node01
    targetRef:
      kind: Pod
      name: nginx-deployment-cbdccf466-kxc47
      namespace: default
      uid: 69ea9d52-94fa-4bb9-8650-cddefeb947e8
  ports:
  - name: nginx-svc
    port: 80
    protocol: TCP

Services in K8s

  • A Service in k8s is a load balancing abstraction within a cluster.
  • There are four types of services
    • ClusterIP
    • NodePort
    • LoadBalancer
    • ExternalName

Exercises:

  • expose the nginx service using type NodePort (kubeadm)

Internet/External to Service Networking

  • Here we have two perspectives
    • Routing traffic from Pod to Internet (Egress)
    • Routing traffic to Kubernetes (Ingress)
      • Layer 4: Load Balancer
      • Layer 7: Ingress Controller
  • External (Egress)
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Exit mobile version
%%footer%%