Cant run pip install with GitLab Runner on EKS


I am running gitlab runner on EKS cluster on a dedicated node.

config: |
      executor = "kubernetes"
        namespace = "{{.Release.Namespace}}"
        image = "python:alpine3.7"
        privileged = true
        allowPrivilegeEscalation = true
        poll_timeout = 600
            name = "docker"
            mount_path = "/var/run/docker.sock"
            host_path = "/var/run/docker.sock"

My Ci pipeline is trying to build a python docker image:

FROM python:alpine3.7
COPY . /app

COPY requirements.txt .

RUN pip install -r requirements.txt

CMD [ "python", "./" ]

While running the build image image on my runner the pip command is failing with:

Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe17fcd0a90>: Failed to establish a new connection: [Errno -3] Try again')': /simple/uvicorn/

running the pip command insiade another node/pod on the cluster will work, also this pipeline job will succedd when running on a gitlab shared runners.

Why I cant access pypi with DIND image running on EKS?

I solved the issue whit addding

--network host

to the build command in the pipeline job script.

I suggest to use kaniko or other k8s native container image build tool instead of unsecure and privileged DinD.