Why is kubernetes unable to pull from a local registry?
I want to deploy my containers on a raspberry kubernetes cluster.
my yml looks as follows
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
run: my-nginx
replicas: 1
template:
metadata:
labels:
run: my-nginx
spec:
containers:
- name: my-nginx
image: 192.168.178.37:5000/my-nginx
imagePullPolicy: Always
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: my-nginx-service
labels:
run: my-nginx
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 30007
selector:
run: my-nginx
but I get the following error
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 7s default-scheduler Successfully assigned default/my-nginx-7cf6c4949c-dnb6h to node1-pi4
Normal Pulling 5s kubelet Pulling image "192.168.178.37:5000/my-nginx"
Warning Failed 5s kubelet Failed to pull image "192.168.178.37:5000/my-nginx": rpc error: code = Unknown desc = Error response from daemon: Get https://192.168.178.37:5000/v2/: http: server gave HTTP response to HTTPS client
Warning Failed 5s kubelet Error: ErrImagePull
Normal SandboxChanged 4s kubelet Pod sandbox changed, it will be killed and re-created.
Normal BackOff 0s (x3 over 2s) kubelet Back-off pulling image "192.168.178.37:5000/my-nginx"
Warning Failed 0s (x3 over 2s) kubelet Error: ImagePullBackOff
pi@master-pi4 ~/Project/htmlBasic % kubectl restart
I added insecure registries
% cat /etc/docker/daemon.json
{ "insecure-registries":["192.168.178.37:5000"] }
and I am able to pull from my local registry.
% docker pull 192.168.178.37:5000/my-nginx
Using default tag: latest
latest: Pulling from my-nginx
Digest: sha256:d498979a2da64b098e25938a0ff0dd611959d791f726d6590f671d471aefed05
Status: Image is up to date for 192.168.178.37:5000/my-nginx:latest
192.168.178.37:5000/my-nginx:latest
How do I configure that kubernetes is able to pull from my local registry? I used is set up of kubernetes here
You will want to ensure all Nodes in your cluster have that same /etc/docker/daemon.json
file