skaffold init ; skaffold build/dev/run/...
fails if Kubernetes manifest references a tagged image #2463
Description
I run skaffold init
with the following files:
---8<---deployment.yaml---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: skatest
name: skatest
spec:
replicas: 1
selector:
matchLabels:
app: skatest
template:
metadata:
labels:
app: skatest
spec:
containers:
- image: foo/bar:baz
name: skatest
---8<---Dockerfile---
FROM nginx
This generates the following skaffold file:
apiVersion: skaffold/v1beta12
kind: Config
build:
artifacts:
- image: foo/bar:baz
deploy:
kubectl:
manifests:
- deployment.yaml
Then I run skaffold dev
.
Expected behavior
Skaffold builds my image and stuff happens.
Actual behavior
I get the following output:
Generating tags...
- foo/bar:baz -> WARN[0000] Unable to find git commit: Running [git describe --tags --always]: stdout , stderr: fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
, err: exit status 128: exit status 128
foo/bar:baz:dirty
Tags generated in 1.774232ms
Starting build...
Building [foo/bar:baz]...
Sending build context to Docker daemon 2.048kB
Pruning images...
Image prune complete in 18.783µs
FATA[0000] exiting dev mode because first build failed: build failed: building [foo/bar:baz]: build artifact: docker build: Error response from daemon: invalid reference format
It is trying to build the image foo/bar:baz:dirty
, which fails.
If I remove the image tag :baz
from the skaffold.yaml
file, the build succeeds.
Extra notes
I suspect that this is a classic case of "user doesn't read the documentation and expects things to work regardless", but it looks like Skaffold could warn me or scream at me if my Kubernetes resources reference tagged images. I like my onboarding to be smooth!
(This is particularly confusing because the output says Building [foo/bar:baz]...
, which we know to be LIES ALL LIES!!!)