How to Set Up External Access to My Kubernetes Cluster?

0
5
Asked By CleverOtter89 On

Hey folks! I'm trying to figure out how to allow external access to my application running in a Kubernetes cluster. I've got an ingress set up on port 8080 and it's visible in k9s with some addresses. I understand I need a load balancer in front of my setup, but I'm stuck on the configuration. Here's what I've done so far:

For my app ingress, I have:

```
ingresses:
my-app:
enabled: true
className: "traefik"
customAnnotations: {}
hosts:
- host: "myapp.apps.caspersbox.com"
paths:
- path: /actuator/health
serviceName: "my-app"
servicePort: 8081
type: "Prefix"
- path: /
serviceName: "my-app"
servicePort: 8080
type: "Prefix"
```

And for the load balancer service:

```
apiVersion: v1
kind: Service
metadata:
name: lb-service
spec:
selector:
app: myapp
type: LoadBalancer
ports:
- name: http-ui
protocol: TCP
port: 443
targetPort: 8080
```

I also set up MetalLB with the following configuration:

```
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: default-pool
namespace: my-ns
spec:
addresses:
- 192.168.10.25-192.168.10.29

---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default-advertisement
namespace: myns
spec:
ipAddressPools:
- default-pool
```

I'm seeing an IP address assigned, but the port seems to be mapping incorrectly (going from 443 to 32470 in services). I'm really just looking for either a usable IP address on my network or to access the service via the host IP. Any guidance would be super helpful!

2 Answers

Answered By CuriousCat23 On

If you're not super attached to using the ingress, you can simplify things by just using the LoadBalancer directly. Set the LoadBalancer service to go straight to the port being exposed in your container. Since you mentioned you turned off the ingress, ensure that your LoadBalancer is correctly configured to point to the right container port. It sounds like you might still be seeing port translations that need to sync up, so double-check that configuration!

Answered By WiseTurtle55 On

It looks like you're trying to accomplish two things simultaneously with the Ingress and LoadBalancer services. You generally want to choose one method to expose your app. For your setup with Ingress, ensure that it's configured to point to a ClusterIP Service that has the correct ports.

First, check if your ingress has picked up the LoadBalancer IP by running `kubectl -A get ingress`. If the ADDRESS column shows an IP, it should be working well. If not, verify if your service has an assigned EXTERNAL-IP with `kubectl get svc -A`. If that’s not populated, that indicates an issue with the LoadBalancer. Adjust the service if needed—remember, you can't change a service type, so recreating it might be necessary if your current one isn't working as intended.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.