Czesc,
utworzylem deployment i service do niego, a nastepnie ingress. Niestety przy testowaniu dostaje blad: "Connecting to lesson9lab.example.com (lesson9lab.example.com)|192.168.49.2|:80... failed: Connection refused." przy testowaniu K8S ingress? Czy cos mam poblokowane po stronie Ubuntu Server na VirtualBox?
$ sudo cat /etc/hosts
127.0.0.1 localhost
192.168.49.2 lesson9lab.example.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
$ minikube ssh
Last login: Tue Oct 3 15:55:24 2023 from 192.168.49.1
docker@minikube:~$ curl 10.109.165.185:80
<!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>
kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
lesson9lab nginx lesson9lab.example.com 192.168.49.2 80 18m```
```kubectl describe ingress
Name: lesson9lab
Labels: <none>
Namespace: default
Address: 192.168.49.2
Ingress Class: nginx
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
lesson9lab.example.com
/ lesson9lab:80 (10.0.0.156:80)
Annotations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 18m (x2 over 19m) nginx-ingress-controller Scheduled for sync
$ curl lesson9lab.example.com
curl: (7) Failed to connect to lesson9lab.example.com port 80 after 1 ms: Connection refused
$ wget lesson9lab.example.com
--2023-10-03 16:40:59-- http://lesson9lab.example.com/
Resolving lesson9lab.example.com (lesson9lab.example.com)... 192.168.49.2
Connecting to lesson9lab.example.com (lesson9lab.example.com)|192.168.49.2|:80... failed: Connection refused.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.10
Release: 22.10
Codename: kinetic
$ cat lesson9lab.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: lesson9lab
name: lesson9lab
spec:
replicas: 1
selector:
matchLabels:
app: lesson9lab
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: lesson9lab
spec:
containers:
- image: nginx
name: nginx
resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: lesson9lab
name: lesson9lab
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: lesson9lab
status:
loadBalancer: {}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
creationTimestamp: null
name: lesson9lab
spec:
rules:
- host: lesson9lab.example.com
http:
paths:
- backend:
service:
name: lesson9lab
port:
number: 80
path: /
pathType: Prefix
status:
loadBalancer: {}
Po zmianie portu service na 90
:
$ cat lesson10lab_port_90.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: lesson9lab
name: lesson9lab
spec:
replicas: 1
selector:
matchLabels:
app: lesson9lab
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: lesson9lab
spec:
containers:
- image: nginx
name: nginx
resources: {}
status: {}
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: lesson9lab
name: lesson9lab
spec:
ports:
- port: 90
protocol: TCP
targetPort: 80
selector:
app: lesson9lab
status:
loadBalancer: {}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
creationTimestamp: null
name: lesson9lab
spec:
rules:
- host: lesson9lab.example.com
http:
paths:
- backend:
service:
name: lesson9lab
port:
number: 90
path: /
pathType: Prefix
status:
loadBalancer: {}
Wykonaniu:
$ kubectl create -f lesson10lab_port_90.yaml
deployment.apps/lesson9lab created
service/lesson9lab created
ingress.networking.k8s.io/lesson9lab created
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/lesson9lab-6bf46bb49-xs7s2 1/1 Running 0 22m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 23m
service/lesson9lab ClusterIP 10.107.166.85 <none> 90/TCP 22m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/lesson9lab 1/1 1 1 22m
NAME DESIRED CURRENT READY AGE
replicaset.apps/lesson9lab-6bf46bb49 1 1 1 22m
$ curl 10.107.166.85:90
<!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>
Dostaje taki sam komunikat:
$ curl lesson9lab.example.com
curl: (7) Failed to connect to lesson9lab.example.com port 80 after 1 ms: Connection refused
$ wget lesson9lab.example.com
--2023-10-03 20:28:00-- http://lesson9lab.example.com/
Resolving lesson9lab.example.com (lesson9lab.example.com)... 192.168.49.2
Connecting to lesson9lab.example.com (lesson9lab.example.com)|192.168.49.2|:80... failed: Connection refused.