GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
15.05k stars 1.62k forks source link

Skaffold does not replaces image with Remote Helm repo with remoteChart, but it does replace with chartPath #7705

Closed sinhasonalkumar closed 1 year ago

sinhasonalkumar commented 2 years ago

Expected behavior

Skaffold should replace latest build image with remoteChart attribute.

Actual behavior

Skaffold is building new image on code change but not replacing latest image.

Information

apiVersion: skaffold/v2beta29
kind: Config
metadata:
  name: m-svc-2
build:
  artifacts:
  - image: m-svc-2-image
    docker:
      dockerfile: Dockerfile
deploy:
  # kubectl:
  #   manifests:
  #   - ./k8s/deployment.yaml
  helm:
    releases:
    - name: m-svc-2
      remoteChart: sonal-ms-github-helm-repo/micro-svc-helm-chart
      version: 0.6.0
      #chartPath: './micro-svc-helm-chart/'
      valuesFiles:
      - '../skaffold-k8s-state/helm-values/m-svc-2/local/values.yaml'
      artifactOverrides:
        container.image: m-svc-2-image
      imageStrategy:
        fqn: {}

Steps to reproduce the behavior

  1. clone git@github.com:sinhasonalkumar/skaffold-m-svc-1.git
  2. helm repo add sonal-ms-github-helm-repo https://sinhasonalkumar.github.io/helm-repository
  3. go 'https://github.com/sinhasonalkumar/skaffold-m-svc-1/blob/main/skaffold.yaml' and comment chartPath and uncomment remoteChart and version as show in the sample yaml above.
  4. This is springboot project using java17. You also should have maven and docker to build. I am running it on minikube.
  5. skaffold dev
  6. Do some code change in 'https://github.com/sinhasonalkumar/skaffold-m-svc-1/blob/main/src/main/java/com/sonal/skaffold/demo/msvc1/controller/HelloMSvc1Controller.java'
  7. mvn clean package
  8. skaffold will try to build docker image but will replace it. Please find logs

Logs

DEBU[0024] Running command: [helm --kube-context minikube get all m-svc-2]  subtask=0 task=Deploy
INFO[0024] Release m-svc-2 not upgraded as it is remote...  subtask=0 task=Deploy
WARN[0024] image [m-svc-2-image:556789fca8ab8a7ee1b39cc2572d447c3b26323c7944d43c0e05b2209c05cce5] is not used.  subtask=-1 task=DevLoop
WARN[0024] See helm documentation on how to replace image names with their actual tags: https://skaffold.dev/docs/pipeline-stages/deployers/helm/#image-configuration  subtask=-1 task=DevLoop
DEBU[0024] getting client config for kubeContext: `minikube`  subtask=-1 task=DevLoop
DEBU[0024] getting client config for kubeContext: `minikube`  subtask=-1 task=DevLoop
INFO[0024] Deploy completed in 48.125718ms               subtask=-1 task=Deploy
Waiting for deployments to stabilize...
DEBU[0024] getting client config for kubeContext: `minikube`  subtask=-1 task=DevLoop
DEBU[0024] getting client config for kubeContext: `minikube`  subtask=-1 task=DevLoop
DEBU[0024] checking status deployment/m-svc-2            subtask=-1 task=Deploy
DEBU[0025] Running command: [kubectl --context minikube rollout status deployment m-svc-2 --namespace default --watch=false]  subtask=-1 task=Deploy
DEBU[0025] Command output: [deployment "m-svc-2" successfully rolled out
]  subtask=-1 task=Deploy
 - deployment/m-svc-2 is ready.
Deployments stabilized in 1.071 second
Watching for changes...
DEBU[0025] Found dependencies for dockerfile: [{target/m-svc-2.jar /application/application.jar false 4 4}]  subtask=-1 task=DevLoop
matthiasdg commented 1 year ago

also experienced this with skaffold 2.1.0 and the setValueTemplates instead of artifactOverrides. Would save some time/trial and error if this behavior was documented on https://skaffold.dev/docs/pipeline-stages/deployers/helm/; first thought I messed something up with the tags. Luckily works with local chart.

ericzzzzzzz commented 1 year ago

Please reference https://skaffold.dev/docs/deployers/helm/#image-configuration to see how to set up image stanza for image replacement in manifests.