How to run a local docker image as a k3s node

Viewed 1864

I've just started with docker and k3s.

I have a local docker image that I've made with a custom app inside.

I was wondering how would I set that as a pod on k3s.

I have k3s set with docker instead of containerd but when I run kubectl create I still get the error ImagePullBackOff.

Can anyone help? thank you!

2 Answers

Here a demo instructions I wrote in the past for a company demo:

References

Install/Setup

sudo snap install microk8s --classic --channel=1.21  

sudo usermod -a -G microk8s $USER 
sudo chown -f -R $USER ~/.kube 
su - $USER 

# DNS setup

microk8s.kubectl run -i --tty --image busybox:1.28.4 dns-test --restart=Never --rm /bin/sh 

microk8s enable registry dns storage

Start

sudo systemctl start docker 
microk8s start 

Services check

microk8s status --wait-ready 

microk8s kubectl get nodes 
microk8s kubectl get services 

App deploy


# Pull hello world image from docker hub

docker pull hello-world 

# Push hello world image to microk8s registry

docker tag hello-world localhost:32000/hello-world 
docker push localhost:32000/hello-world 

# Try it

docker run --rm localhost:32000/hello-world 

App running

microk8s kubectl run my-demo --image localhost:32000/hello-world 
microk8s kubectl expose pod my-demo --port 8080 --target-port 8080 

Terminatation

microk8s kubectl delete service my-demo 
microk8s kubectl delete pod my-demo 

# or  

kubectl delete -f app.yaml 

# then 

microk8s.stop 
Related