I have a microk8s cluster with nginx ingress and a .NET Orleans application deployed to some pods. Then I have a service which is attached to the pods I belive (I am new to Kubernetes and Microk8s so appoligies if I am wrong). I get the error: 404 not found when I try to access the ingress. There are no errors in the ingress-nginx-controller and no errors in my pods.
Here are my yaml: Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloud.solar.trest.se
labels:
orleans/serviceId: cloud.solar.trest.se
orleans/clusterId: trest
spec:
selector:
matchLabels:
orleans/serviceId: cloud.solar.trest.se
orleans/clusterId: trest
replicas: 2
template:
metadata:
labels:
orleans/serviceId: cloud.solar.trest.se
orleans/clusterId: trest
spec:
containers:
- name: main
image: lordmax2/klevebrandsolarcontroller:cloud-latest
imagePullPolicy: Always
ports:
- containerPort: 80
- containerPort: 443
- containerPort: 11111
- containerPort: 30000
- containerPort: 7298
env:
- name: ORLEANS_SERVICE_ID
valueFrom:
fieldRef:
fieldPath: metadata.labels['orleans/serviceId']
- name: ORLEANS_CLUSTER_ID
valueFrom:
fieldRef:
fieldPath: metadata.labels['orleans/clusterId']
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: DOTNET_SHUTDOWNTIMEOUTSECONDS
value: "120"
terminationGracePeriodSeconds: 180
strategy:
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
Service:
apiVersion: v1
kind: Service
metadata:
name: solar-service
spec:
selector:
orleans/serviceId: cloud.solar.trest.se
orleans/clusterId: trest
ports:
- name: port-11111
protocol: TCP
port: 11111
targetPort: 11111
- name: port-30000
protocol: TCP
port: 30000
targetPort: 30000
- name: port-80
protocol: TCP
port: 80
targetPort: 80
- name: port-443
protocol: TCP
port: 443
targetPort: 443
- name: port-7298
protocol: TCP
port: 7298
targetPort: 7298
Ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: solar-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
ingressclass.kubernetes.io/is-default-class: "true"
spec:
ingressClassName: "nginx"
rules:
- host: cloud.solar.trest.se
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: solar-service
port:
number: 7298
tls:
- hosts:
- cloud.solar.trest.se
secretName: cloud-certificate
The ingress looks like this when I do: microk8s kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
solar-ingress nginx cloud.solar.trest.se 10.10.1.200 80, 443 117m
The service looks like this: microk8s kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 2d4h
solar-service ClusterIP 10.152.183.166 <none> 11111/TCP,30000/TCP,80/TCP,443/TCP,7298/TCP 3h14m
Here are my pods: microk8s get pods
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
cloud.solar.trest.se-c97468cb-hwk4m 1/1 Running 0 9m26s 10.1.211.165 kdc-node-1 <none> <none>
cloud.solar.trest.se-c97468cb-lsm4n 1/1 Running 0 8m21s 10.1.160.143 kdc-node-2 <none> <none>
Here is the described ingress: microk8s kubectl describe ingress solar-ingress
Name: solar-ingress
Labels: <none>
Namespace: default
Address: 10.10.1.200
Ingress Class: nginx
Default backend: <default>
TLS:
cloud-certificate terminates cloud.solar.trest.se
Rules:
Host Path Backends
---- ---- --------
cloud.solar.trest.se
/ solar-service:7298 (10.1.160.143:7298,10.1.211.165:7298)
Annotations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 4m43s (x230 over 119m) nginx-ingress-controller Scheduled for sync
Normal Sync 4m43s (x224 over 115m) nginx-ingress-controller Scheduled for sync
Normal Sync 26s (x234 over 115m) nginx-ingress-controller Scheduled for sync
Here is microk8s kubectl get all
in every namespace:
kdc@kdc-node-1:~ $ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/cloud.solar.trest.se-c97468cb-hwk4m 1/1 Running 0 25m
pod/cloud.solar.trest.se-c97468cb-lsm4n 1/1 Running 0 24m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 2d4h
service/solar-service ClusterIP 10.152.183.166 <none> 11111/TCP,30000/TCP,80/TCP,443/TCP,7298/TCP 3h30m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/cloud.solar.trest.se 2/2 2 2 24h
NAME DESIRED CURRENT READY AGE
replicaset.apps/cloud.solar.trest.se-6c865fdb 0 0 0 24h
replicaset.apps/cloud.solar.trest.se-5b9bb67477 0 0 0 24h
replicaset.apps/cloud.solar.trest.se-c97468cb 2 2 2 25m
replicaset.apps/cloud.solar.trest.se-8577f49f4b 0 0 0 23h
kdc@kdc-node-1:~ $ kubectl get all -n ingress-nginx
NAME READY STATUS RESTARTS AGE
pod/ingress-nginx-admission-create-6jwj6 0/1 Completed 0 25h
pod/ingress-nginx-admission-patch-hw8sf 0/1 Completed 1 25h
pod/ingress-nginx-controller-7445ddc6c4-hw76d 1/1 Running 4 (133m ago) 25h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/ingress-nginx-controller-admission ClusterIP 10.152.183.230 <none> 443/TCP 25h
service/ingress-nginx-controller LoadBalancer 10.152.183.240 10.10.1.200 80:32307/TCP,443:32581/TCP 25h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-nginx-controller 1/1 1 1 25h
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-nginx-controller-7445ddc6c4 1 1 1 25h
NAME COMPLETIONS DURATION AGE
job.batch/ingress-nginx-admission-create 1/1 17m 25h
job.batch/ingress-nginx-admission-patch 1/1 17m 25h
kdc@kdc-node-1:~ $ kubectl get all -n metallb-system
NAME READY STATUS RESTARTS AGE
pod/speaker-2lct7 1/1 Running 0 147m
pod/speaker-rq2ls 1/1 Running 1 (133m ago) 147m
pod/controller-749f8b5cbc-dq8sm 1/1 Running 0 36m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/webhook-service ClusterIP 10.152.183.65 <none> 443/TCP 147m
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/speaker 2 2 2 2 2 kubernetes.io/os=linux 147m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/controller 1/1 1 1 147m
NAME DESIRED CURRENT READY AGE
replicaset.apps/controller-749f8b5cbc 1 1 1 36m
replicaset.apps/controller-5f7bb57799 0 0 0 147m
kdc@kdc-node-1:~ $ kubectl get ing
NAME CLASS HOSTS ADDRESS PORTS AGE
solar-ingress nginx cloud.solar.trest.se 127.0.0.1 80, 443 136m
*EDIT
I added metallb with an IPAddressPool and a L2Assignement to get some real ip addresses, but doesnt seem to work. If I do microk8s kubectl port-forward svc/solar-service 7298
I am able to reach service from the master node with https://127.0.0.1:7298, but not with https://10.10.0.150:7298 which is the node ip address..
Thanks in advance!
Best regards Max
I found the error, saw this log in the controller:
And my backend service is https only, so added this annotation:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"