Step-by-Step Guide: Nginx Ingress Setup on AKS

Hi, I am Vivek, a 26 years old developer from India. I love making apps. You can check my github for some of my open source projects.
Search for a command to run...

Hi, I am Vivek, a 26 years old developer from India. I love making apps. You can check my github for some of my open source projects.
No comments yet. Be the first to comment.
Migrating a production database is often a high-stakes operation. Traditional "dump and restore" methods require significant maintenance windows, leading to service downtime. To solve this, PostgreSQL offers Logical Replication, a native mechanism th...

Ever found yourself in the endless cycle of "delete Docker image, redeploy, repeat" to keep your Dokku apps updated? You’re not alone. If your Dokku-deployed application relies directly on a Docker image (perhaps from Docker Hub or your private regis...

Lately, my internet has been throwing tantrums — not because the connection itself is bad, but because every time the power blinks, my router decides it's time for a little nap. Naturally, the obvious

So, one day I saw my old laptop sitting there, collecting dust like it was auditioning for a role in an apocalypse movie. And then it hit me: "Why not turn it into a server?" There was just one minor hiccup. Its Ethernet port was as dead as my dreams...

Recently I was tasked with setting up kubernetes cluster with an Nginx Ingress. As a newcomer to Kubernetes, I tackled this setup and learned a thing or two along the way. Let me walk you through my experience and share some helpful tips.
The Goal: Set up a Kubernetes Cluster with Nginx Ingress
Here's where things got interesting. After setting up my cluster, I hit a snag: I couldn't get a public IP assigned to my Nginx ingress. All I got was a private IP, which wasn't very useful for my needs.
After some extensive searching (and maybe a few sighs of frustration), I finally found the solution in the Nginx documentation (https://kubernetes.github.io/ingress-nginx/deploy/). What a relief!
Before We Start...
Let's make sure we're on the same page. This guide assumes you've already configured your K8s cluster on kubectl. If you haven't, no problem! Just use az login to access your Azure account and use the connect command from your Azure AKS cluster. It's pretty straightforward.
Here's the command that'll set up your Nginx ingress controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.11.1/deploy/static/provider/cloud/deploy.yaml
Found this gem after going throught the documentation (maybe we should read it sometime) https://kubernetes.github.io/ingress-nginx/deploy/#azure.
Now, let's tackle the next exciting step in our K8s journey: creating a certificate Secret! 🔐.
You'll need to whip up a certificate for your domain. You've got two options here:
Snag a free certificate from Let's Encrypt
Purchase one from a certificate authority (fancy, I know!)
Once you've got your hands on that shiny certificate and key, Run this command:
kubectl create secret tls tls-conf --cert /path/to/fullchain.pem --key /path/to/privkey.pem --namespace your-namespace
Don't forget to swap out the path and namespace with your actual values. This command creates a secret object of type kubernetes.io/tls.
Next up, we're creating an Ingress for your service. Think of it as the bouncer that decides who gets into your Kubernetes club.
Create a file called ingress.yaml and fill it with this yaml goodness:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-name
namespace: your-namespace
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- your-domain.something
secretName: tls-conf
rules:
- host: your-domain.something
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: your-service
port:
number: your-service-port
ingressClassName: nginx
Now, before you apply this yaml, make sure to replace your-namespace, your-domain.something, your-service, and your-service-port with your actual values.
Once you've customized your yaml, apply it using kubectl. Voila! You've just set up an Ingress for your service using the following command.
kubectl apply -f /path/to/ingress.yaml
Replace the /path/to/ingress.yaml with wherever you saved your ingress.yaml.
And that's it you should have your nginx ingress up and running with a public IP assigned to it.
What if you want to tweak some Nginx settings? Maybe you're looking to adjust the client_max_body_size or other fancy parameters? Well, you're in luck!
Head over to the config objects in your Kubernetes dashboard.
Filter by the ingress-nginx namespace.
find and edit th ingress-nginx-controller
Once you're happy with your edits, apply them. A complete list of available configuration options can be found at: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/.