Unable to connect to git repo via application

127 Views Asked by At

I have a node app. Trying to connect to a git repo via the app.

It works locally. It also works when I docker build and run it via container locally.

But when I deploy it, getting the following error.

Error: Cloning into '/opt/app-root/dist/temp_repo'... fatal: unable to access 'https://github.companyDomain.com/owner/repo-name.git/': CONNECT tunnel failed, response 404

CONNECT - HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "-" "git/2.38.5" "583aa8-0b75-47a5-a90e-3f0bc2aab696" "github.companyDomain.com:443

Why?

My code in the main index.js file.

import simpleGit from 'simple-git';

const url = `https://validUserName:[email protected]/owner/repo-name.git`;

export const clone = async () => {
  await simpleGit().clone(url, '/opt/app-root/dist/temp_repo', {
    '--branch': 'main',
    '--single-branch': null,
    '--depth': '1',
  });
};

await clone();

P.S: When deployed, I have set firewall rules for github.companyDomain.com TLS 443 and HTTPS 80.

Deployment is to a company owned internal server which I don't fully control.
Is not like AWS or Azure. Is self managed Kubernetes based if this info matters.

1

There are 1 best solutions below

0
VonC On BEST ANSWER

Your Kubernetes cluster is utilizing Istio, and the error message 404 NR route_not_found means Istio is unable to find a route or a matching filter chain for the downstream connection when your application is attempting to clone the git repository. The 404 NR error code stands for "No Route" and indicates that a routing problem exists within the Istio configuration. Here's how you might address or investigate this issue further:

Make sure there is a VirtualService and DestinationRule configuration for github.companyDomain.com or ensure that the external traffic to github.companyDomain.com is properly handled in your Istio configuration.
If there is a VirtualService configuration for github.companyDomain.com, make sure the routes are correctly defined and that they point to the correct DestinationRule and subsets, if applicable.

Create a ServiceEntry to allow traffic to github.companyDomain.com. A ServiceEntry informs Istio how to handle external traffic.

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
    name: github-external
spec:
    hosts:
    - github.companyDomain.com
    ports:
    - number: 443
    name: https
    protocol: HTTPS
    resolution: DNS
    location: MESH_EXTERNAL

See also this discussion which involves adding a match section for the path in question to the first VirtualService so that it routes to the correct service. Similarly, in your case, check the routing configurations in your Istio setup correctly match the paths and hosts your application is trying to access might help resolve the 404 NR route_not_found error.