Skip to content

Instantly share code, notes, and snippets.

@pichuang
Last active July 20, 2023 13:13
Show Gist options
  • Save pichuang/0de5b5172501b3c821e6e905eb38c476 to your computer and use it in GitHub Desktop.
Save pichuang/0de5b5172501b3c821e6e905eb38c476 to your computer and use it in GitHub Desktop.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx \
--create-namespace \
--namespace ingress-basic \
--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz
---
apiVersion: v1
kind: Namespace
metadata:
name: one
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: aks-helloworld-one
namespace: one
spec:
replicas: 1
selector:
matchLabels:
app: aks-helloworld-one
template:
metadata:
labels:
app: aks-helloworld-one
spec:
containers:
- name: aks-helloworld-one
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports:
- containerPort: 80
env:
- name: TITLE
value: "Azure Kubernetes Service (AKS) ONE!!!ONE!!!ONE!!!"
---
apiVersion: v1
kind: Service
metadata:
name: aks-helloworld-one
namespace: one
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: aks-helloworld-one
---
apiVersion: v1
kind: Namespace
metadata:
name: two
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: aks-helloworld-two
namespace: two
spec:
replicas: 1
selector:
matchLabels:
app: aks-helloworld-two
template:
metadata:
labels:
app: aks-helloworld-two
spec:
containers:
- name: aks-helloworld-two
image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
ports:
- containerPort: 80
env:
- name: TITLE
value: "Azure Kubernetes Service (AKS) TWO!!!TWO!!!TWO!!!"
---
apiVersion: v1
kind: Service
metadata:
name: aks-helloworld-two
namespace: two
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: aks-helloworld-two
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world-ingress-one
namespace: one
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /one(/|$)(.*)
pathType: Prefix
backend:
service:
name: aks-helloworld-one
port:
number: 80
- path: /(.*)
pathType: Prefix
backend:
service:
name: aks-helloworld-one
port:
number: 80
---
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world-ingress-two
namespace: two
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /two(/|$)(.*)
pathType: Prefix
backend:
service:
name: aks-helloworld-two
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world-ingress-static
namespace: one
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /static/$2
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /static(/|$)(.*)
pathType: Prefix
backend:
service:
name: aks-helloworld-one
port:
number: 80
@pichuang
Copy link
Author

helm uninstall ingress-nginx -n ingress-basic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment