GoogleContainerTools / GoogleContainerTools/skaffold
remoteManifests don't replace image on deployment if digest specified
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
### Expected behavior
When using `remoteManifests`, if the deployed manifest contains an image digest then the image is not replaced with the one built by skaffold
### Actual behavior
The image is not replaced and a warning `WARN[0002] image [foo] is not used by the deployment` is printed
### Information
- Skaffold version: v1.17.2
- Operating system: MacOS Mojave
- Contents of skaffold.yaml:
This is a basic reproduction I've cooked up
```yaml
---
apiVersion: skaffold/v2beta10
kind: Config
metadata:
name: nginx
build:
# Abuse the fact that the image is already pushed with `:latest` to docker.io
tagPolicy:
sha256: {}
artifacts:
- image: nginx
custom:
# Skaffold will simply pick up the version of `nginx` with the `:latest` tag from docker.io
buildCommand: true
deploy:
kubectl:
manifests: [""]
remoteManifests:
- skaffold-digest-bug:deployment/nginx
```
And deployment.yaml:
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
namespace: skaffold-digest-bug
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2@sha256:4cf620a5c81390ee209398ecc18e5fb9dd0f5155cd82adcbae532fec94006fb9
ports:
- containerPort: 80
```
### Steps to reproduce the behavior
1. Use the above `skaffold.yaml` and `deployment.yaml` files
2. `kubectl create ns skaffold-digest-bug`
3. `kubectl apply -f deployment.yaml`
4. `skaffold run`
5. You'll see the warning `WARN[0002] image [nginx] is not used by the deployment` as described
6. Edit `deployment.yaml` to remove the sha from the image (ie `image: nginx:1.14.2`)
7. `kubectl apply -f deployment.yaml`
8. `skaffold run`
9. The warning will not appear
It looks like the problem is here: https://github.com/GoogleContainerTools/skaffold/blame/v1.17.2/pkg/skaffold/kubernetes/manifest/images.go#L108
That check was added in https://github.com/GoogleContainerTools/skaffold/commit/e3fd35032997048c777f9957ad02c160932f05af - but the comment on the commit ("Ignore tags (not digests) in manifests") is directly contradicted by the code and the behaviour. By not adding to `r.found` it _is_ ignoring digests...
Is this behaviour intentional somehow?
Contributor guide
Assessment
This issue has not been assessed yet.