skaffold/kaniko: Get access to service from another namespace

4/12/2020

I've deployed a registry service into a namespace registry:

$ kubectl get service -n registry
NAME                       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
registry-docker-registry   ClusterIP   10.43.119.11   <none>        5000/TCP   18h

this is my skaffold.yaml:

apiVersion: skaffold/v2beta1
kind: Config
metadata:
  name: spring-boot-slab
build:
  artifacts:
  - image: skaffold-covid-backend
    kaniko:
      dockerfile: Dockerfile-multistage
      cache: {}
  cluster: {}
deploy:
  kubectl:
    manifests:
    - k8s/*

Everything works fine, up to when kaniko is trying to push the image to above registry:

Get "http://registry-docker-registry.registry.svc.cluster.local:5000/v2/": dial tcp: lookup registry-docker-registry.registry.svc.cluster.local on 127.0.0.53:53: no such host

Any ideas about how to get access to this registry deployed inside the same kubernetes?

I've tried to get access to the registry from another pod:

$ kubectl exec -ti graylog-1 -- curl registry-docker-registry.registry:5000/v2/_catalog
{"repositories":["skaffold-covid-backend","skaffold-covid-backend/cache"]}

As you can see, it's able to get access to registry.

-- Jordi
kaniko
kubernetes
skaffold

3 Answers

4/12/2020

According to this instruction, you can get access to:

registry-docker-registry.registry

or according to the instructions:

registry-docker-registry.registry.svc.cluster.local
-- V. Mokrecov
Source: StackOverflow

4/12/2020
  1. You can try to exec a pod in your intended namespace and try to curl the service that you want to reach as well as its port. The format in general is:
<your-service>.<your-namespace>

So from your intended pod you can curl it using the following command:

curl <your-service>.<your-namespace>:<your-port>
  1. Try to port forward your service to your local using the following command:
kubectl -n <namespace> svc/<your-service> <your-localhost-port>:<your-service-port> 

See whether you can access it this way.

-- irvifa
Source: StackOverflow

4/12/2020

Try something like this. I hope this command will work.

registry-docker-registry.registry.svc.cluster.local
-- Dashrath Mundkar
Source: StackOverflow