Kubernetes not pulling latest image

3/16/2020

Something which is puzzling me

I have written a docker file v1 with a v1 of my code.

for example:

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))

I am building and pushing my image to docker hub with the tag development (leexha/sample:development) . For example a v2 of my code is as below

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello EARTH!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))

I can confirm that my latest code is being pushed into docker hub as I did a docker run and its working fine.

However, when I try to run the latest docker image in kubernetes doing a kubectl run sample --image=leexha/sample:development it is strangely fetching v1 of my code (Hello World)

Is there any reason why this working like this?

-- Adam
docker
kubernetes

2 Answers

3/17/2020

You can define imagePullPolicy: Always in your deployment file. For production environment do not use latest docker image tag.

-- Sachin Arote
Source: StackOverflow

3/16/2020

Yes, performance. According to the docs the default pull policy is IfNotPresent unless your image is using the tag latest. Override by setting imagePullPolicy to Always.

EDIT: you don't want to check for and pull updated images in production, where a tagged image should never change. Even the check can be costly. In development you can use latest or override with imagePullPolicy.

-- ewramner
Source: StackOverflow