I have followed the steps in the Udacity Full-Stack Nanodegree course to get a Kubernetes cluster running on AWS EKS.
The Service is running. Running the command kubectl get services simple-jwt-api -o wide
returns:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
simple-jwt-api LoadBalancer 10.100.217.57 a32d4ab0969b149bd9fb47d2065aee80-335944770.us-west-2.elb.amazonaws.com 80:31644/TCP 51m app=simple-jwt-api
Nodes appear to be running:
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
ip-192-168-3-213.us-west-2.compute.internal Ready <none> 80m v1.15.10-eks-bac369 192.168.3.213 54.70.213.28 Amazon Linux 2 4.14.173-137.229.amzn2.x86_64 docker://18.9.9
ip-192-168-46-0.us-west-2.compute.internal Ready <none> 80m v1.15.10-eks-bac369 192.168.46.0 34.220.32.208 Amazon Linux 2 4.14.173-137.229.amzn2.x86_64 docker://18.9.9
Pods appear to be running
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
simple-jwt-api-5dd5b9cf98-46ngm 1/1 Running 0 37m 192.168.22.121 ip-192-168-3-213.us-west-2.compute.internal <none> <none>
simple-jwt-api-5dd5b9cf98-kfgxf 1/1 Running 0 37m 192.168.20.148 ip-192-168-3-213.us-west-2.compute.internal <none> <none>
simple-jwt-api-5dd5b9cf98-xs6rp 1/1 Running 0 37m 192.168.60.136 ip-192-168-46-0.us-west-2.compute.internal <none> <none>
Docker file is:
FROM python:stretch
COPY . /app
WORKDIR /app
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
EXPOSE 8080
ENTRYPOINT ["gunicorn", "-b", ":8080", "main:APP"]
Deployment file is:
apiVersion: v1
kind: Service
metadata:
name: simple-jwt-api
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: simple-jwt-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-jwt-api
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 2
maxSurge: 2
selector:
matchLabels:
app: simple-jwt-api
template:
metadata:
labels:
app: simple-jwt-api
spec:
containers:
- name: simple-jwt-api
image: CONTAINER_IMAGE
securityContext:
privileged: false
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
ports:
- containerPort: 8080
Why can't I access the app at a32d4ab0969b149bd9fb47d2065aee80-335944770.us-west-2.elb.amazonaws.com?
It looks like the targetPort in service targetPort: 80
does not match the container port of POD i.e.: containerPort: 8080
. Please change the targetPort in service to be 8080 and try again.
apiVersion: v1
kind: Service
metadata:
name: simple-jwt-api
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: simple-jwt-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-jwt-api
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 2
maxSurge: 2
selector:
matchLabels:
app: simple-jwt-api
template:
metadata:
labels:
app: simple-jwt-api
spec:
containers:
- name: simple-jwt-api
image: CONTAINER_IMAGE
securityContext:
privileged: false
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
ports:
- containerPort: 8080