I have problem with my app. I have server where i have microk8s and i trying deploy application. I writed deploy, ingress and service file. deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
replicas: 1
selector:
matchLabels:
run: my-nginx
template:
metadata:
labels:
run: my-nginx
spec:
containers:
- name: my-nginx
image: nginx
ports:
- containerPort: 80
ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: learn-linux.eu
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: learn-linux.eu
http:
paths:
- path: /
backend:
serviceName: nginx-service
servicePort: 80
service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-service
labels:
app: my-nginx
spec:
ports:
- port: 80
protocol: TCP
selector:
app: my-nginx
Domain record A is changed to server IP where i have microk8s. But when i execute curl learn-linux.eu i getting:
curl: (7) Failed to connect to localhost port 80: Connection refused
but when i execute curl command to pod IP, i receive nginx default page
root@learn-linux:~# curl 10.1.31.22
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
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>
My service describe:
Name: nginx-service
Namespace: default
Labels: app=my-nginx
Annotations: <none>
Selector: app=my-nginx
Type: ClusterIP
IP: 10.152.183.44
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: <none>
Session Affinity: None
Events: <none>
microk8s kubectl describe deployments my-nginx
Name: my-nginx
Namespace: default
CreationTimestamp: Thu, 03 Sep 2020 12:18:15 +0200
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: run=my-nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: run=my-nginx
Containers:
my-nginx:
Image: nginx
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: my-nginx-5dc4865748 (1/1 replicas created)
Events: <none>
root@learn-linux:~# microk8s kubectl describe deployments my-nginx
Name: my-nginx
Namespace: default
CreationTimestamp: Thu, 03 Sep 2020 12:18:15 +0200
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: run=my-nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: run=my-nginx
Containers:
my-nginx:
Image: nginx
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: my-nginx-5dc4865748 (1/1 replicas created)
Events: <none>
microk8s kubectl describe pod my-nginx-5dc4865748
Name: my-nginx-5dc4865748-nbjww
Namespace: default
Priority: 0
Node: learn-linux/193.33.111.185
Start Time: Thu, 03 Sep 2020 12:18:16 +0200
Labels: pod-template-hash=5dc4865748
run=my-nginx
Annotations: <none>
Status: Running
IP: 10.1.31.22
IPs:
IP: 10.1.31.22
Controlled By: ReplicaSet/my-nginx-5dc4865748
Containers:
my-nginx:
Container ID: containerd://a15250412d4ce90ed9d5d31f98aff233cbe88bf26378429f6521e26a979281a2
Image: nginx
Image ID: docker.io/library/nginx@sha256:b0ad43f7ee5edbc0effbc14645ae7055e21bc1973aee5150745632a24a752661
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Thu, 03 Sep 2020 12:18:32 +0200
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-2wkwf (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-2wkwf:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-2wkwf
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events: <none>
I don't know what i do wrong, i tried from many tutorials but still not working. Anyone have idea?
#Update microk8s kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
learn-linux.eu <none> learn-linux.eu 80 15h
curl -v -H "host: learn-linux.eu" 10.1.31.24
* Trying 10.1.31.24:80...
* TCP_NODELAY set
* Connected to 10.1.31.24 (10.1.31.24) port 80 (#0)
> GET / HTTP/1.1
> Host: learn-linux.eu
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.19.2
< Date: Fri, 04 Sep 2020 07:37:38 GMT
< Content-Type: text/html
< Content-Length: 612
< Last-Modified: Tue, 11 Aug 2020 14:50:35 GMT
< Connection: keep-alive
< ETag: "5f32b03b-264"
< Accept-Ranges: bytes
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
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
? Can you add output fromcurl -v -H "host: learn-linux.eu" ingress-ip/
?/etc/hosts
with nginx-ingress ip, there is documentation about that. not sure if this will work microk8s. Could you try it?