At present I am running an Angular client app and a Nodejs/Express API on Heroku, and a MongoDB on MongoDB Inc. I have decided to migrate my project to Kubernetes, and selected DigitalOcean (mainly because they’re neither Google nor Amazon).
I have successfully migrated the API to a kubernetes deployment. Following an excellent DO tutorial, I was able to connect the deployment to my domain name through Nginx Ingress and secure it with Cert-Manager. This was the tutorial I followed: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-on-digitalocean-kubernetes-using-helm
I am now working to migrate the Angular client to a k8s deployment and could use advice on troubleshooting. I experienced problems containerizing the app with docker and resolved those by switching the package manager from npm to yarn. The container now successfully runs in a pod (status is ‘running’), and I’ve connected it to my ingress controller. When I try to connect, however, I get the 502 Bad Gateway error. I suspect I’m routing the port incorrectly. Angular apps default to port 4200, and I redirect those to port 80, just as with the tutorial, above.
Here are my yaml files for the deployment and for Ingress. There are four DNS routes. hw1 and hw2 are from the tutorial and are working fine. api is my API and is working fine. I have not included those yaml files. The DNS route for pvg does not work. It points to the “markwilx” deployment. I welcome any suggestion for proceeding with troubleshooting.
Thanks in advance, Mark
--- apiVersion: v1 kind: Service metadata: name: markwilx spec: type: ClusterIP ports: - port: 80 targetPort: 4200 selector: app: markwilx --- apiVersion: apps/v1 kind: Deployment metadata: name: markwilx spec: replicas: 1 selector: matchLabels: app: markwilx template: metadata: labels: app: markwilx spec: containers: - name: nginx image: registry.digitalocean.com/XXXXXXXX/markwilx:0.3.1 ports: - containerPort: 4200 protocol: TCP
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: - hw1.XXXXXXXXX.org # This is working - hw2.XXXXXXXXX.org # This is working - api.XXXXXXXXX.org # This is working - pvg.XXXXXXXXX.org # This is NOT working secretName: hello-kubernetes-tls rules: - host: "hw1.XXXXXXXXX.org" http: paths: - pathType: Prefix path: "/" backend: service: name: hello-kubernetes-first port: number: 80 - host: "hw2.XXXXXXXXX.org" http: paths: - pathType: Prefix path: "/" backend: service: name: hello-kubernetes-second port: number: 80 - host: "api.XXXXXXXXX.org" http: paths: - pathType: Prefix path: "/" backend: service: name: mwx-api port: number: 80 - host: "pvg.XXXXXXXXX.org" http: paths: - pathType: Prefix path: "/" backend: service: name: markwilx port: number: 80
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Click below to sign up and get $200 of credit to try our products over 60 days!