Commit 23bb49cb authored by Nguyễn Văn Vũ's avatar Nguyễn Văn Vũ

Week9 - Install ingress-nginx and config load-balancing

parent c0d76144
# Run the kubectl command to create a namespace:
kubectl create namespace ingress-nginx
# Run the command to add the helm repository for the nginx Controller:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
# Run the command to update the helm repository data:
helm repo update
# Run the command to install the Controller:
helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress \
--set controller.ingressClassResource.name=nginx
# Use this command to get the IP address:
watch kubectl -n ingress get svc
# Create self-signed certificate
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=172.16.0.16.nip.io"
# Create Kubernetes Secret from certificate
kubectl create secret tls 172.16.0.16.nip.io --cert=tls.crt --key=tls.key
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
run: my-nginx
replicas: 2
template:
metadata:
labels:
run: my-nginx
spec:
containers:
- name: my-nginx
image: nginx
ports:
- containerPort: 80
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-nginx
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: 172.16.0.16.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-nginx
port:
number: 80
apiVersion: v1
kind: Service
metadata:
name: my-nginx
labels:
run: my-nginx
spec:
ports:
- port: 80
protocol: TCP
selector:
run: my-nginx
kind: ConfigMap
apiVersion: v1
metadata:
name: ingress-nginx-controller
namespace: ingress-nginx
data:
use-proxy-protocol: "true"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment