Ambiguous warning : "WARN[0064] image [gcr.io/wired-benefit-XXXXX/demoapp] is not used by the deployment"

150 views Asked by At

Expected behavior

Stated warning should NOT be displayed.

Actual behavior

Every time I make a change and trigger a re-deployment, I get an error like:

WARN[0064] image [gcr.io/wired-benefit-XXXXX/demoapp] is not used by the deployment

Yet the image is modified with the updated change, so I'm not sure what the error is indicating,

Information

  • Skaffold version: version... v1.15.0
  • Operating system: ... MacOS Catilina 10.15.16
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2beta8
kind: Config
metadata:
  name: demoapp
build:
  artifacts:
  - image: gcr.io/wired-benefit-293406/demoapp
deploy:
  kubectl:
    manifests:
    - k8*.yml

Content of K8s manifests :

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: demoapp
  name: demoapp
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demoapp
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: demoapp
    spec:
      containers:
      - image: gcr.io/wired-benefit-293406/demoapp
        imagePullPolicy: IfNotPresent
        name: demoapp
      restartPolicy: Always

apiVersion: v1
kind: Service
metadata:
  labels:
    app: demoapp
  name: demoapp-svc
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 3000
  selector:
    app: demoapp
  type: LoadBalancer

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: demoapp
spec:
  maxReplicas: 5
  minReplicas: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: demoapp
  targetCPUUtilizationPercentage: 80

Steps to reproduce the behavior

  1. a very basic starter demo app
  2. skaffold dev
  3. Any change ... docker build is successful by skaffold and even pushing to registry

But, changes are not being reflected. Could be tag related problem. When I manually set the image name to latest for the deployment, then app change works.

1

There are 1 answers

0
Dawid Kruk On BEST ANSWER

As I said in the comment:

Does your K8S manifests is a single file with Deployment, Service and HPA inside of it? I ran exactly as you've pasted it (encountered same warning) and it lacked the --- in between the resources.

Talking specifically about the content included in Content of K8s manifests, this file is missing three dashes (---) between the resources.

It could be fixed either by:

  • spliting the resources in multiple files (by following skaffold.yaml and it's template k8*.yml):
    • k8s-deployment.yaml
    • k8s-service.yaml
    • k8s-hpa.yaml
  • adding the --- between each of the resource in Content of K8s manifests (example):
DEPLOYMENT
---
SERVICE
--- 
HPA

You can read more about --- in YAML files by following this StackOverflow answer:


As for the reproduction. I used the the official getting started guide:

I copied the Content of K8s manifests into the k8s-pod.yaml and changed the line (this file does not have --- between the resources):

      - image: gcr.io/PROJECT-NAME/demoapp

Running below command with:

  • $ skaffold dev
Listing files to watch...
 - gcr.io/PROJECT-NAME/demoapp
Generating tags...
 - gcr.io/PROJECT-NAME/demoapp -> gcr.io/PROJECT-NAME/demoapp:<--REDACTED-->
Checking cache...
 - gcr.io/PROJECT-NAME/demoapp: Not found. Building
Building [gcr.io/PROJECT-NAME/demoapp]...
Sending build context to Docker daemon  3.072kB
<--REDACTED-->
<--REDACTED-->: Pushed 
<--REDACTED-->: Layer already exists 
<--REDACTED-->: digest: <--REDACTED--> size: 739
Tags used in deployment:
 - gcr.io/PROJECT-NAME/demoapp -> gcr.io/PROJECT-NAME/demoapp:<--REDACTED-->
Starting deploy...
WARN[0023] image [gcr.io/PROJECT-NAME/demoapp] is not used by the deployment 
 - horizontalpodautoscaler.autoscaling/demoapp created
Waiting for deployments to stabilize...
Deployments stabilized in 198.216977ms
Press Ctrl+C to exit
Watching for changes...

Focusing on:

WARN[0023] image [gcr.io/PROJECT-NAME/demoapp] is not used by the deployment 
 - horizontalpodautoscaler.autoscaling/demoapp created

As you can see only the HPA object was created. Deployment and Service was not created. It's also showing the same warning as yours.

Running $ kubectl apply -f k8s-pod.yaml will yield the same results!

Editing the k8s-pod.yaml file to include --- and running $ skaffold dev once again should produce output similar to the one below:

Listing files to watch...
 - gcr.io/PROJECT-NAME/demoapp
Generating tags...
 - gcr.io/PROJECT-NAME/demoapp -> gcr.io/PROJECT-NAME/<--REDACTED-->
Checking cache...
 - gcr.io/PROJECT-NAME/demoapp: Not found. Building
<--REDACTED-->
<--REDACTED-->: Pushed 
<--REDACTED-->: Layer already exists 
<--REDACTED-->: digest: <--REDACTED--> size: 739
Tags used in deployment:
 - gcr.io/PROJECT-NAME/demoapp -> gcr.io/PROJECT-NAME/demoapp:<--REDACTED-->
Starting deploy...
 - deployment.apps/demoapp created
 - service/demoapp-svc created
 - horizontalpodautoscaler.autoscaling/demoapp created
Waiting for deployments to stabilize...
 - deployment/demoapp is ready.
Deployments stabilized in 5.450197785s
Press Ctrl+C to exit
Watching for changes...
[demoapp] Hello World with ---!
[demoapp] Hello World with ---!
[demoapp] Hello World with ---!

As you can see above all of the resources were created, there was no warning about the deployment not using an image and also the app responded.


Additional resources: