Changes between Version 3 and Version 4 of k8snetworking2023


Ignore:
Timestamp:
Dec 7, 2023, 7:47:24 AM (12 months ago)
Author:
deepthi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • k8snetworking2023

    v3 v4  
    144144      protocol: TCP
    145145}}}
     146
     147This service will expose your webapp on a NodePort.
     148
     149• Apply the Service:
     150
     151`kubectl apply -f [your-service-file].yaml`
     152
     153'''Step 2: Set Up Ingress to Route to the NodePort Service'''
     154
     1551. Define an Ingress Resource: Create an Ingress resource that routes traffic to your NodePort service. Here's an example YAML for the Ingress:
     156
     157{{{
     158
     159apiVersion: networking.k8s.io/v1
     160kind: Ingress
     161metadata:
     162  name: webapp-ingress
     163spec:
     164  ingressClassName: nginx
     165  rules:
     166  - host:
     167     http:
     168        paths:
     169        - path: /
     170        pathType: Prefix
     171        backend:
     172            service:
     173               name: webapp-nodeport-service
     174               port:
     175                   number: 80
     176}}}
     177
     178This Ingress resource routes traffic from nginx-ingress controller external IP to the webapp-nodeport-service on port 80.
     179
     180• Apply the Ingress Resource:
     181
     182`kubectl apply -f webapp-ingress.yaml`
     183
     184
     185'''Step 3: Ensure Ingress Controller is Set Up Correctly'''
     186
     187Ensuring that your Ingress Controller is properly set up and accessible from outside the Kubernetes cluster involves several key steps. This setup is crucial for allowing external traffic to reach your services through the Ingress rules you've defined. Here's a breakdown of what this entails:
     188
     1891. Deploying the Ingress Controller
     190
     191• Choose an Ingress Controller: There are several Ingress Controllers available, such as NGINX, Traefik, HAProxy, etc. NGINIX is a popular choice due to its stability and feature set.
     192
     193• Install the Ingress Controller: You need to deploy the Ingress Controller in your Kubernetes cluster. For NGINX, you might use a command like:
     194
     195{{{
     196kubectl apply -f
     197https://raw.githubusercontent.com/kubernetes/ingress-
     198nginx/controller-
     199v1.8.2/deploy/static/provider/cloud/deploy.yaml
     200}}}
     201
     2022. Exposing the Ingress Controller
     203
     204
     205• Service Type: The Ingress Controller itself is exposed via a Kubernetes Service. This Service needs to be accessible from outside the cluster. There are two common ways to do this:
     206- NodePort: The Service is exposed on a high port (e.g., 30000-32767) on each node's IP address. External traffic can reach the Ingress Controller by hitting any node's IP at this port.
     207- LoadBalancer: If your cluster is running in a cloud environment that supports LoadBalancer Services, this is a more straightforward way to expose your Ingress Controller. For our setup lets allow the metalLB setup to lease an external IP address that routes traffic to the Ingress Controller.
     208
     209'''Step 4: DNS Configuration'''
     210
     2111. Configure DNS: Map the DNS record to the external IP address of one of your cluster nodes (if using NodePort for the Ingress Controller) or to the external IP provided by the LoadBalancer (if using LoadBalancer for the Ingress Controller).
     212
     213Read More:
     214[https://spacelift.io/blog/kubernetes-ingress]
     215[https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-ingress-guide-nginx- example.html]
     216