7

I've build docker image locally:

docker build -t backend -f backend.docker

Now I want to create deployment with it:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-deployment
spec:
  selector:
    matchLabels:
      tier: backend
  replicas: 2
  template:
    metadata:
      labels:
        tier: backend
    spec:
      containers:
      - name: backend
        image: backend
        imagePullPolicy: IfNotPresent # This should be by default so
        ports:
        - containerPort: 80

kubectl apply -f file_provided_above.yaml works, but then I have following pods statuses:

$ kubectl get pods
NAME                                   READY   STATUS             RESTARTS   AGE
backend-deployment-66cff7d4c6-gwbzf    0/1     ImagePullBackOff   0          18s

Before that it was ErrImagePull. So, my question is, how to tell it to use local docker images? Somewhere on the internet I read that I need to build images using microk8s.docker but it seems to be removed.

Bunyk
  • 7,635
  • 8
  • 47
  • 79

1 Answers1

13

Found docs on how to use private registry: https://microk8s.io/docs/working

First it needs to be enabled:

microk8s.enable registry

Then images pushed to registry:

docker tag backend localhost:32000/backend
docker push localhost:32000/backend

And then in above config image: backend needs to be replaced with image: localhost:32000/backend

ses
  • 13,174
  • 31
  • 123
  • 226
Bunyk
  • 7,635
  • 8
  • 47
  • 79
  • https://stackoverflow.com/questions/56515971/microk8s-pushing-image-to-local-registry – ses Jun 09 '19 at 15:53