How to reference a docker image via sha256 hash in Kubernetes pod?

8/18/2019

I've get the image specified as:

  - image: kennethreitz/httpbin:sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b

Though this does not seem to work:

Warning  InspectFailed  5s (x7 over 71s)  kubelet, minikube  Failed to apply default image tag "kennethreitz/httpbin:sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b": couldn't parse image reference "kennethreitz/httpbin:sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b": invalid reference format

What is the correct format / synatx?

kubectl describe pod misty-hound-chris-test-568c59b788-64dtb
Name:               misty-hound-chris-test-568c59b788-64dtb
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               minikube/192.168.122.212
Start Time:         Sun, 18 Aug 2019 09:55:03 +0000
Labels:             app.kubernetes.io/instance=misty-hound
                    app.kubernetes.io/name=chris-test
                    pod-template-hash=568c59b788
Annotations:        <none>
Status:             Pending
IP:                 172.17.0.8
Controlled By:      ReplicaSet/misty-hound-chris-test-568c59b788
Containers:
  chris-test:
    Container ID:   
    Image:          kennethreitz/httpbin:sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b
    Image ID:       
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       InvalidImageName
    Ready:          False
    Restart Count:  0
    Liveness:       http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:      http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-kcjf7 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-kcjf7:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-kcjf7
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason         Age                     From               Message
  ----     ------         ----                    ----               -------
  Normal   Scheduled      4m31s                   default-scheduler  Successfully assigned default/misty-hound-chris-test-568c59b788-64dtb to minikube
  Warning  InspectFailed  2m14s (x12 over 4m30s)  kubelet, minikube  Failed to apply default image tag "kennethreitz/httpbin:sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b": couldn't parse image reference "kennethreitz/httpbin:sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b": invalid reference format
  Warning  Failed         2m (x13 over 4m30s)     kubelet, minikube  Error: InvalidImageName
-- Chris Stryczynski
kubernetes

1 Answer

8/18/2019

It uses the same label selection syntax as docker:

  - image: kennethreitz/httpbin@sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b

@ was needed after the image name.

-- Chris Stryczynski
Source: StackOverflow