Reputation: 107
Previously, I tried to make it work ingress using NodeIP. How to make My First ingress work on baremetal NodeIP? It did not work too, perhaps the problem is the same as now, that I did not configure it correctly.
I gave up this option and tried MetallLB + Ingress
!What I did in both cases: !I installed DNS via /etc/hosts only on my work machine.
10.0.57.28 cluster.local test.local ingress.example.com dashboard.cluster.local test.cluster.local test.com
Installation metallb With Helm:
helm repo add metallb https://metallb.github.io/metallb
helm install metallb metallb/metallb -f values.yaml
values.yaml
configInline:
address-pools:
- name: default
protocol: layer2
addresses:
- 10.0.57.28-10.0.57.29
Using Helm¶ install Ingress Controller:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx
get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default ingress-nginx-controller LoadBalancer 10.233.3.75 10.0.57.28 80:30963/TCP,443:32376/TCP 19s
make service
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-hello
namespace: dev
spec:
rules:
- host: "test.com"
http:
paths:
- backend:
service:
name: hello-service
port:
number: 80
path: /
pathType: Prefix
Make ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-hello
namespace: dev
spec:
rules:
- host: cluster.local
http:
paths:
- backend:
service:
name: hello-service
port:
number: 80
path: "/hello"
pathType: Prefix
curl -D- http://cluster.local/hello
HTTP/1.1 404 Not Found
Date: Sat, 11 Sep 2021 17:26:27 GMT
Content-Type: text/html
Content-Length: 146
Connection: keep-alive
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
kubectl get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default ingress-nginx-controller LoadBalancer 10.233.3.75 10.0.57.28 80:30963/TCP,443:32376/TCP 25m
default ingress-nginx-controller-admission ClusterIP 10.233.13.161 <none> 443/TCP 25m
default ireg ClusterIP 10.233.34.105 <none> 8080/TCP 8d
default kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 10d
dev hello-node-service NodePort 10.233.3.50 <none> 80:31263/TCP 19h
dev hello-service ClusterIP 10.233.45.159 <none> 80/TCP 2d6h
kube-system coredns ClusterIP 10.233.0.3 <none> 53/UDP,53/TCP,9153/TCP 10d
kube-system metrics-server ClusterIP 10.233.27.232 <none> 443/TCP 34h
kubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.233.29.129 <none> 8000/TCP 10d
kubernetes-dashboard kubernetes-dashboard ClusterIP 10.233.36.25 <none> 443/TCP 10d
Check "hello" pod
service_hello_Node.yml
---
apiVersion: v1
kind: Service
metadata:
name: hello-node-service
namespace: dev
spec:
type: NodePort
selector:
app: hello
ports:
- port: 80
targetPort: 8080
curl -I 10.0.57.35:31263
HTTP/1.1 200 OK
Date: Sat, 11 Sep 2021 17:28:46 GMT
Content-Length: 66
Content-Type: text/plain; charset=utf-8
kubectl describe pod ingress-nginx-controller-fd7bb8d66-mvc9d
Please help me why ingress does not work. Maybe I need to customize the DNS in a particular way?
Service and Ingress in same Namespace. Ingress Controller in different.
I look at the ingress controller logs - there is nothing, is this normal?
kubectl describe pod ingress-nginx-controller-fd7bb8d66-mvc9d
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 19m default-scheduler Successfully assigned default/ingress-nginx-controller-fd7bb8d66-mvc9d to kuber-node-01
Normal Pulled 19m kubelet Container image "k8s.gcr.io/ingress-nginx/controller:v1.0.0@sha256:0851b34f69f69352bf168e6ccf30e1e20714a264ab1ecd1933e4d8c0fc3215c6" already present on machine
Normal Created 19m kubelet Created container controller
Normal Started 19m kubelet Started container controller
Normal RELOAD 19m nginx-ingress-controller NGINX reload triggered due to a change in configuration
kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
default ingress-nginx-controller-fd7bb8d66-mvc9d 1/1 Running 0 22m
default ireg-685d4b86fb-rwjpj 1/1 Running 1 27h
default metallb-controller-748756655f-ss6w7 1/1 Running 0 93m
default metallb-speaker-2tf86 1/1 Running 0 93m
default metallb-speaker-6xht6 1/1 Running 0 93m
default metallb-speaker-9wjrm 1/1 Running 0 93m
default metallb-speaker-b28fv 1/1 Running 0 93m
default metallb-speaker-jdv4z 1/1 Running 0 93m
default metallb-speaker-svwjz 1/1 Running 0 93m
default metallb-speaker-xd22w 1/1 Running 0 93m
dev hello-app-78f957775f-7d7bw 1/1 Running 1 27h
dev hello-app-78f957775f-hj9gb 1/1 Running 1 9h
dev hello-app-78f957775f-wr7b2 1/1 Running 1 9h
kube-system calico-kube-controllers-5b4d7b4594-5qfjc 1/1 Running 1 27h
kube-system calico-node-7mcqc 1/1 Running 1 10d
kube-system calico-node-9trpd 1/1 Running 1 10d
kube-system calico-node-fl55n 1/1 Running 1 10d
kube-system calico-node-g9zxw 1/1 Running 1 10d
kube-system calico-node-j8fqp 1/1 Running 0 10d
kube-system calico-node-jhz72 1/1 Running 0 10d
kube-system calico-node-rrcm4 1/1 Running 0 10d
kube-system coredns-8474476ff8-552fq 1/1 Running 0 27h
kube-system coredns-8474476ff8-h45sp 1/1 Running 0 27h
kube-system dns-autoscaler-7df78bfcfb-xzkg9 1/1 Running 0 27h
kube-system kube-apiserver-kuber-master1 1/1 Running 0 10d
kube-system kube-apiserver-kuber-master2 1/1 Running 0 34h
kube-system kube-apiserver-kuber-master3 1/1 Running 0 34h
kube-system kube-controller-manager-kuber-master1 1/1 Running 0 10d
kube-system kube-controller-manager-kuber-master2 1/1 Running 1 10d
kube-system kube-controller-manager-kuber-master3 1/1 Running 1 10d
kube-system kube-proxy-52566 1/1 Running 1 27h
kube-system kube-proxy-6bwrt 1/1 Running 0 27h
kube-system kube-proxy-fxkv6 1/1 Running 1 27h
kube-system kube-proxy-kmjnf 1/1 Running 1 27h
kube-system kube-proxy-pnbss 1/1 Running 0 27h
kube-system kube-proxy-tf9ck 1/1 Running 1 27h
kube-system kube-proxy-tt4gv 1/1 Running 0 27h
kube-system kube-scheduler-kuber-master1 1/1 Running 0 10d
kube-system kube-scheduler-kuber-master2 1/1 Running 0 10d
kube-system kube-scheduler-kuber-master3 1/1 Running 1 10d
kube-system metrics-server-ddf5ffb86-27q7x 2/2 Running 0 27h
kube-system nginx-proxy-kuber-ingress-01 1/1 Running 1 10d
kube-system nginx-proxy-kuber-node-01 1/1 Running 1 10d
kube-system nginx-proxy-kuber-node-02 1/1 Running 1 10d
kube-system nginx-proxy-kuber-node-03 1/1 Running 1 10d
kube-system nodelocaldns-2clp8 1/1 Running 0 10d
kube-system nodelocaldns-b4552 1/1 Running 1 10d
kube-system nodelocaldns-hkffk 1/1 Running 1 10d
kube-system nodelocaldns-jflnt 1/1 Running 0 10d
kube-system nodelocaldns-k7cn7 1/1 Running 1 10d
kube-system nodelocaldns-ksd4t 1/1 Running 1 10d
kube-system nodelocaldns-xm544 1/1 Running 0 10d
kubernetes-dashboard dashboard-metrics-scraper-856586f554-thz5d 1/1 Running 1 27h
kubernetes-dashboard kubernetes-dashboard-67484c44f6-mgqgr 1/1 Running 0 9h
Upvotes: 0
Views: 942
Reputation: 107
The solution is to add the following content to the ingress - annotation. Then the ingress controller starts to see the DNS addresses.
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
Also, for convenience, changed path: / to a regular expression:
- path: /v1(/|$)(.*)
Upvotes: 2