I have a small ec2 backed (not eks) k8s cluster (version 1.23.1), running in aws with 1 master and 1 worker node. The cluster has a few services, one of which is a simple front end built on flask. I am able to expose the flask app publicly using a node port service with out any issues. But I cant seem to get my load balancer to work correctly.
flask app deployment:
kind: Deployment
metadata:
name: app-ui
labels:
app: ui
spec:
replicas: 1
selector:
matchLabels:
app: ui
template:
metadata:
labels:
app: ui
spec:
containers:
- name: app-ui
image: **image removed**
ports:
- containerPort: 5000
imagePullSecrets:
- name: docker-hub
Node port (working):
With this node port I can hit the app using {{worker_public_ip}}:30000
apiVersion: v1
kind: Service
metadata:
name: app-ui-nodeport
spec:
type: NodePort
selector:
app: ui
ports:
- protocol: TCP
port: 5000
targetPort: 5000
nodePort: 30000
Load balancer (not working)
apiVersion: v1
kind: Service
metadata:
name: app-ui-loadbalancer
spec:
type: LoadBalancer
selector:
app: ui
ports:
- protocol: TCP
port: 5000
targetPort: 5000
Description of the load balancer
Name: app-ui-loadbalancer
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=ui
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.109.158.206
IPs: 10.109.158.206
Port: <unset> 5000/TCP
TargetPort: 5000/TCP
NodePort: <unset> 32343/TCP
Endpoints: 10.244.1.46:5000
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Please correct me if im wrong. I thought this would create an actual load balancer in aws. Then using the public ip of that load balancer I would be able to hit the app on port 5000.
CodePudding user response:
kubectl describe service app-ui-loadbalancer
might tell you more about what's going on. Specifically, check the Events
section. Perhaps you might need to add a firewall rule or it's error trying to get an IP.