arnab74
Intern
Intern
  • UID6365
  • Fans0
  • Follows0
  • Posts1
Reads:2292Replies:1

Connect back-end with front-end over rest api call running on kubernetes

Created#
More Posted time:Sep 30, 2019 10:49 AM
I have a two tier application. The frontend calls the webapi layer through simple http rest call http://mywebapi:5000/ My working docker compose code is below and the application works




version: '3'

services:
  webfrontend:
    image: webfrontend
    build: ./nodeexpress-alibaba-ci-tutorial
    ports:
      - "3000:3000"
    networks:
      - my-shared-network  

  mywebapi:
    image: mywebapi
    build: ./dotnetcorewebapi-alibaba-ci-tutorial
    ports:
      - "5000:5000"
    networks:
      - my-shared-network  
networks:
  my-shared-network: {}
Now I'm trying to get this to work on kubernetes. I have created two deployments and two services-loadbalancer for webfrontend and clusterip for mywebapi
But, after deploying, I find that the data from mywebapi is not reaching the frontend. I can view the frontend on the browser through the load balancer public ip.
Mywebapi deployment yaml

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: '2'
  creationTimestamp: '2019-09-29T15:21:42Z'
  generation: 2
  labels:
    app: mywebapi-default
  name: mywebapi-default
  namespace: default
  resourceVersion: '667574310'
  selfLink: /apis/apps/v1beta2/namespaces/default/deployments/mywebapi-default
  uid: d723a9d5-e2cc-11e9-93ec-a65f0b53b1fa
spec:
  progressDeadlineSeconds: 600
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: mywebapi-default
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: mywebapi-default
    spec:
      containers:
        - image: >-
            registry-intl-vpc.ap-southeast-1.aliyuncs.com/devopsci-t/mywebapi:1.0
          imagePullPolicy: Always
          name: mywebapi-default
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 2
  conditions:
    - lastTransitionTime: '2019-09-29T15:30:25Z'
      lastUpdateTime: '2019-09-29T15:30:25Z'
      message: Deployment has minimum availability.
      reason: MinimumReplicasAvailable
      status: 'True'
      type: Available
    - lastTransitionTime: '2019-09-29T15:21:42Z'
      lastUpdateTime: '2019-09-29T15:30:25Z'
      message: ReplicaSet "mywebapi-default-647b864f" has successfully progressed.
      reason: NewReplicaSetAvailable
      status: 'True'
      type: Progressing
  observedGeneration: 2
  readyReplicas: 2
  replicas: 2
  updatedReplicas: 2




Mywebapi service yaml


apiVersion: v1
kind: Service
metadata:
  creationTimestamp: '2019-09-29T15:21:44Z'
  name: mywebapi-svc
  namespace: default
  resourceVersion: '667545270'
  selfLink: /api/v1/namespaces/default/services/mywebapi-svc
  uid: d84503ee-e2cc-11e9-93ec-a65f0b53b1fa
spec:
  clusterIP: 172.19.0.74
  ports:
    - name: mywebapiport
      port: 5000
      protocol: TCP
      targetPort: 5000
  selector:
    app: mywebapi-default
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}


I even tried updating the http rest call url to http://mywebapi-svc:5000/ but still does not work. In the webfrontend pod logs I find the below error
Got error: getaddrinfo ENOTFOUND mywebapi-svc mywebapi-svc:5000

Sincerely appreciate all help
Thanks

Cloudy
Administrator
Administrator
  • UID63
  • Fans15
  • Follows1
  • Posts96
1st Reply#
Posted time:Oct 11, 2019 10:53 AM
Dear arnab74,

Please create a ticket in your Alibaba Cloud console and our post-sales team will help you with that. You can refer to the below link for the instruction of creating ticket: https://www.alibabacloud.com/help/doc-detail/47605.htm#ticket
Thank you.
Guest