3

I have this kubernetes yaml file

apiVersion: v1
kind: Service
metadata:
  name: incremental-api-load-balancer
spec:
  selector:
    app: incremental-api
    tier: api
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
  name: incremental-external-api-service
spec:
  selector:
    app: incremental-external-api
    tier: sidecar
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: incremental-api-deployment
spec:
  selector:
    matchLabels:
      app: incremental-api
      tier: api
      track: stable
  replicas: 3
  template:
    metadata:
      labels:
        app: incremental-api
        tier: api
        track: stable
    spec:
      containers:
      - name: incremental-flask-app
        image: incremental-flask
        imagePullPolicy: Never
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: incremental-external-api-deployment
spec:
  selector:
    matchLabels:
      app: incremental-external-api
      tier: sidecar
      track: stable
  replicas: 1
  template:
    metadata:
      labels:
        app: incremental-external-api
        tier: sidecar
        track: stable
    spec:
      containers:
      - name: incremental-external-api
        image: incremental-external-api
        imagePullPolicy: Never

When I do

docker images ls

I see

REPOSITORY                                  TAG                                        IMAGE ID            CREATED             SIZE
incremental-flask                             latest                                     8bbc4c45efdf        2 minutes ago       1.21GB
incremental-external-api                        latest                                     532203259006        3 minutes ago       1.2GB

From looking at this answer - Docker for Mac(Edge) - Kubernetes - reference local image

I should be pulling the local image.

However, I get this when I run

kubectl get pods

incremental-api-deployment-98b5d7c95-bmqbf         0/1       ErrImageNeverPull   0          1m
incremental-api-deployment-98b5d7c95-tktqv         0/1       ErrImageNeverPull   0          1m
incremental-api-deployment-98b5d7c95-xcwk2         0/1       ErrImageNeverPull   0          1m
incremental-external-api-service-deployment-b9dddff77-6z4p9   0/1       ErrImageNeverPull   0          1m

I am running a local cluster with Docker Desktop and I want to pull local images.

Why is this error happening?

praks5432
  • 7,246
  • 32
  • 91
  • 156

2 Answers2

1

--image-pull-policy=Never

using "latest" tag will always force a pull, because the value for imagePullPolicy:always , it will look for the remote repo to pull .

When you add the 'Never' option , local repo will be used

SKS
  • 105
  • 1
  • 8
0

Just use specific tag version instead of 'latest' (check configuration best practices here).

Nepomucen
  • 4,449
  • 3
  • 9
  • 24