Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pull local imagen in Kind with Podman in Windows 11 #3732

Open
carrulop opened this issue Sep 4, 2024 · 9 comments
Open

Unable to pull local imagen in Kind with Podman in Windows 11 #3732

carrulop opened this issue Sep 4, 2024 · 9 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@carrulop
Copy link

carrulop commented Sep 4, 2024

I have installed latest version from Podman and podman desktop (podman 5.2.2) on Windows 11.
I have installed kind extension (v0.24.0 gol.22.6).
I have created an image using podman build -t mi-microservice . using Containerfile, and image is successfully created. Indeed, I saw it in podman desktop: localhost/mi-microservice. This image consists on a microservice created by spring boot that enables a java server listening on 8080 port.

If I create a container using this image, for example, with podman run, it is successfully created, and I can reach to my microservice with a browser, at localhost://8080, and it works fine.

The issue comes when I want to deploy my image like a pod with kubernetes, using kind.

I created the following manifest for my microservice:

app.yml

kind: Service
apiVersion: v1
metadata:
  name: demo-service
  labels:
    app: demo-service
spec:
  type: NodePort
  selector:
    app: demo-service
  ports:
  - port: 8080
    nodePort: 30080
    targetPort: 8080
    name: http
---
apiVersion: v1
kind: Pod
metadata:
  name: demo-app
  labels:
    app: demo-service
spec:
  containers:
    - name: microservice-app
      image: localhost/mi-microservicio:latest
      ports:
        - name: http
          containerPort: 8080
          protocol: TCP
          hostPort: 8080

This manifest contains a pod that uses my local image, and a service.
When I execute:
kubectl apply -f app.yml

This tell me the service and pod was created. But if I execute: kubectl get pod, it tells that image could not be pulled, and status is ErrImagePull.

If I create the pod using podman desktop, it works.

How can I make my manifest works with Kind? Why Kind does not load my local image? What am I doing bad?

Thanks a lot!

Best regards

Environment:

  • kind version: (v0.24.0):
  • Podman version: (5.2.2):
  • OS (Windows 11):
  • Kubernetes version: (1.31.0):
@carrulop carrulop added the kind/bug Categorizes issue or PR as related to a bug. label Sep 4, 2024
@BenTheElder
Copy link
Member

Kind has it's own container runtime in the nodes, you have to make the image available using either:

https://kind.sigs.k8s.io/docs/user/local-registry/

https://kind.sigs.k8s.io/docs/user/quick-start/#loading-an-image-into-your-cluster

note for podman if you use kind load you'll have to use something like podman save ... | kind load image-archive

I recommend local registry, which also persists across clusters and efficiently transfers layers

@BenTheElder BenTheElder added kind/support Categorizes issue or PR as a support question. and removed kind/bug Categorizes issue or PR as related to a bug. labels Sep 4, 2024
@carrulop
Copy link
Author

carrulop commented Sep 4, 2024

I read the local-registry solution, but I need help to understand it. I see there is a script called "kind-with-registry.sh". I have Windows 11, and I saved it to a file, but I am unable to execute. It only open an editor. How can I execute it? In a console, it does nothing.

@BenTheElder
Copy link
Member

You'll have to run it inside the linux VM running podman, sorry I don't develop on Windows or use podman desktop so I'm not sure exactly what enables that.

You could manually perform the equivalent steps instead.

@carrulop
Copy link
Author

carrulop commented Sep 4, 2024

I have executed the script inside the linux VM where Windows use, but I got an error because kind does not exist in this VM. How can I make work kind inside VM linux?

I have seen the script makes a kind create cluster. Is it possible to use the current cluster I have created using podman desktop? Or should I create cluster using the script?

@BenTheElder
Copy link
Member

BenTheElder commented Sep 4, 2024

I have seen the script makes a kind create cluster. Is it possible to use the current cluster I have created using podman desktop? Or should I create cluster using the script?

It is, but not directly using the script, the script is just a sample and has comments about each of the steps.

I have executed the script inside the linux VM where Windows use, but I got an error because kind does not exist in this VM. How can I make work kind inside VM linux?

That depends on the VM, you would need it installed there. (Again, I don't use this environment and can't say)

But you don't actually need kind installed if you do these manually, because the script currently only uses kind to create the cluster and then list the nodes. You could run the step against your nodes yourself.

@afbjorklund
Copy link
Contributor

I think you need to remove the fake "localhost" directory from the image name... It is only understood/ignored by Podman and cri-o

Others like Kubernetes and containerd might try to pull the image from localhost:80 (which does not exist)?

@carrulop
Copy link
Author

carrulop commented Sep 5, 2024

Finally what I did was click on "Push image to Kind cluster" from Podman-desktop, and now, the pod is created successfully, reading the image fine.

Now, the issue that I have is how access to the nodePort of the service from outside of the cluster, that is, from my local computer where I have deployed my cluster with kind.

As you can see in manifest app.yml, I defined a service called demo-service, whose type is NodePort, exposing to port 30080. If I call to curl demo-service:8080 from another pod, it reachs successfully to my microservice-app container.

But, if I tried to call to: curl localhost:30080 from my browser, it get error: localhost rejected connection.

How can I configure my cluster with Kind in order to be able to receive calls outer from the cluster?

Thanks a lot!!

@stmcginnis
Copy link
Contributor

Great! You will need to have extraPortMappings to access the services running in the cluster since you are actually running them inside a VM and not on your local host, even though Docker Desktop makes it look that way.

More details can be found here: https://kind.sigs.k8s.io/docs/user/known-issues/#docker-desktop-for-macos-and-windows

@carrulop
Copy link
Author

carrulop commented Sep 5, 2024

Thanks!!

I have used: kubectl port-foward demo-app 30080:8080, and with this, I can do: http://localhost:30080 to access to my microservice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

4 participants