set up a basic Nodejs Express API

0 votes

I am new to K8s and this is my first time trying to get to grips with it. I am trying to set up a basic Nodejs Express API using this deployment.yml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - image: registry.gitlab.com/<project>/<app>:<TAG>
        imagePullPolicy: Always
        name: api
        env:
        - name: PORT
          value: "8080"
        ports:
          - containerPort: 8080
            hostPort: 80
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 30
          timeoutSeconds: 1
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 30
          timeoutSeconds: 1
      imagePullSecrets:
        - name: registry.gitlab.com

Which is being deployed via gitlab-ci. This is working and I have set up a service to expose it:

apiVersion: v1
kind: Service
metadata:
  name: api-svc
  labels:
    app: api-svc
spec:
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  selector:
    app: api
  type: LoadBalancer

I went through a lot of blogs and documnetations, it said i need to create an ingress.yaml file and i did create it 

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  backend:
    serviceName: api-svc
    servicePort: 80

But when I visit the external IP address that was generated from the ingress and I just 502 error pages.

Sep 21, 2018 in Power BI by Hannah
• 18,520 points
1,691 views

1 answer to this question.

0 votes

In order for Ingress to work on GCE you need to define your backend service das a NodePort not as ClusterIP or LoadBalancer.

Change the port in your service.yaml file

apiVersion: v1
kind: Service
metadata:
  name: api-svc-v2
  labels:
    app: api-svc-v2
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
    nodePort: 31810
    protocol: TCP
    name: http
  selector:
    app: backend-api-v2

answered Sep 21, 2018 by Kalgi
• 52,340 points

Related Questions In Power BI

+1 vote
1 answer
0 votes
1 answer

I have a web API with basic authorisation and username and password. How do i connect to it in Power BI?

Hey, @There, I found your query is quite ...READ MORE

answered Oct 29, 2020 in Power BI by Gitika
• 65,730 points
4,977 views
0 votes
1 answer

How do I set up a Power BI Embedded solution with row-level security for external users?

To enable Power BI Embedded for external ...READ MORE

answered Mar 25, 2025 in Power BI by anonymous
• 36,180 points
1,329 views
0 votes
1 answer

How to troubleshoot a refresh on data set in power bi service

Some common reason include data privacy settings ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5, 2025 2,089 views
+1 vote
1 answer
0 votes
1 answer

permissions related to AWS ECR

if you add allowContainerRegistry: true, kops will add those permissions ...READ MORE

answered Oct 9, 2018 in Kubernetes by Kalgi
• 52,340 points
2,274 views
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
18,054 views
0 votes
1 answer

Looking for a way to to list all cloud services with their description

A jQuery selector like this should do ...READ MORE

answered Sep 21, 2018 in Power BI by Kalgi
• 52,340 points
1,151 views
0 votes
1 answer

How to assign Power BI license to a new user

The assign license method of MS Graph API might ...READ MORE

answered Sep 25, 2018 in Power BI by Kalgi
• 52,340 points
1,490 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP