2

I am working on a Kubernetes I deployed on my Mac using Vagrant and Vbox. Then I installed Istio, Knative Serving, and Eventing.

I then defined a service.yaml file with the following content:

---
apiVersion: v1
kind: Namespace
metadata:
  name: hello-k8s-ns

---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: hello-k8s
  namespace: hello-k8s-ns
spec:
  template:
    spec:
      containers:
        - image: sasadangelo/hello-k8s

where sasadangelo/hello-k8s is a Hello World!!! docker application I built and deployed on Docker HUB. My problem is that when I try to deploy it with the kubect apply command, everything goes fine but no Pod is deployed. I see the service deployed but when I analyze it with kubect describe I see the following error message:

Revision "hello-k8s-lm6hk" failed with message: Unable to fetch image "sasadangelo/hello-k8s": failed to resolve image to digest: failed to fetch image information: Get https://index.docker.io/v2/: dial tcp 54.72.52.58:443: connect: connection refused.

It's not clear to me why it cannot download the image from Docker HUB. My Vagrant VM access to the Internet correctly and the command:

kubectl run hello-k8s --generator=run-pod/v1 --image=sasadangelo/hello-k8s:latest --port=80

works fine.

Since I am new to Knative I suspect I missing something in Knative configuration. Can anyone help?

Salvatore D'angelo
  • 1,019
  • 3
  • 14
  • 39

1 Answers1

1

According to Mario's reply, I solved configuring Docker HUB credentials. Here the procedure.

I think KNative for some reason don't simply pull the image but it does some additional stuff (i.e. verify digest) that requests Docker HUB authentication.

According to the procedure linked, if you give the command:

kubectl create secret mysecret ...

Then you need to modify the service.yaml in this way:

---
apiVersion: v1
kind: Namespace
metadata:
  name: hello-k8s-ns

---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: hello-k8s
  namespace: hello-k8s-ns
spec:
  template:
  spec:
    containers:
      - image: sasadangelo/hello-k8s
  imagePullSecrets:  # <--------------- Add this line
    - name: docker-hub-registry # <---- Add this line
Salvatore D'angelo
  • 1,019
  • 3
  • 14
  • 39