A repository containing a basic working set up of the NGINX Ingress Controller.
Tested working on k3s, and assumes
kubectlandhelminstalled.
Run install k3s script
curl -sfL https://get.k3s.io | sh -Create a k3s config file to disable traefik
# /etc/rancher/k3s/config.yaml
disable:
- traefikRestart k3s
sudo systemctl restart k3s.servicehelm repo add nginx-stable https://helm.nginx.com/stable
helm repo update nginx-stablehelm install nginx-ingress nginx-stable/nginx-ingress -n nginx-ingress --create-namespaceGrab the nginx ingress controller service IP provided by servicelb
kubectl get svc -n nginx-ingressAdd it to /etc/hosts
# /etc/hosts
<nginx-ingress-ip> test.localApply these mainfests
# nginx-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-nginx
namespace: nginx-ingress
spec:
replicas: 1
selector:
matchLabels:
app: test-nginx
template:
metadata:
labels:
app: test-nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80# nginx-service.yml
apiVersion: v1
kind: Service
metadata:
name: test-nginx
namespace: nginx-ingress
spec:
selector:
app: test-nginx
type: ClusterIP
ports:
- protocol: TCP
port: 80
targetPort: 80# nginx-ingress.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-nginx-ingress
namespace: nginx-ingress
spec:
ingressClassName: nginx
rules:
- host: test.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: test-nginx
port:
number: 80kubectl apply -f nginx-deployment.yaml
kubectl apply -f nginx-service.yaml
kubectl apply -f nginx-ingress.yaml(ins)❯ curl -k http://test.local
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>