Versions and references are noted below.
I am attempting to migrate my Angular client application and my Node/Express API from a Heroku virtualized server to DigitalOcean's Managed Kubernetes (DOKS). Largely following the Ingress Tutorial (see References, below), I have successfully:
The pertinent YAML configuration files are attached below (see Configurations, below). I'd be glad to add others if it would help.
Where I have failed is connecting to the Angular from the Internet. I receive an HTTP 502 Bad Gateway when connecting.
To ensure my Angular code was not causing the problem, I have created a default Angular app, following the Default Angular Tutorial (see References).
I followed Troubleshooting Deployments (see References) and determined the following:
The error code in the ingress log is:
2021/04/12 06:08:43 [error] 423#423: *1158356 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: pvg.example.com, request: "GET / HTTP/1.1", upstream: "http://XXX.XXX.XXX.XXX:4200/", host: "pvg.example.com"
This is where I am stuck. I would be grateful for any insights from this expert community.
Thank you!
Disclaimer: I have also asked this question on DigitalOcean's Community website with no responses over the last week (see References, below). When answered, I will link the two together.
Configurations
Configuration for Service and Deployment of Angular:
---
apiVersion: v1
kind: Service
metadata:
name: my-app-cip
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 4200
selector:
app: my-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: nginx
image: registry.digitalocean.com/XXXXXXXX/my-app:0.1.0
ports:
- containerPort: 4200
protocol: TCP
Configuration for Ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-kubernetes-ingress
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- hosts:
- api.example.com # This is working
- pvg.example.com # This is NOT working
secretName: hello-kubernetes-tls
rules:
- host: "api.example.com" # This is working
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: my-api-cip
port:
number: 80
- host: "pvg.example.com" # This is NOT working
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: my-app-cip
port:
number: 80
Versions
References
Ingress Tutorial
Default Angular Tutorial:
Troubleshooting Deployments
Question as asked on DigitalOcean Community website:
EDIT: Fixed markdown mistakes; added comment to YAML for clarification; fixed typo in Ingress YAML file.