-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skaffold rebuilds all images on every run (GitHub Action) - also the unaffected ones #4842
Comments
Dealing with the same thing here The easy (but bad) solution is just to tag all images with :latest, e.g.:
...and then using cacheFrom: image:latest This will override your past images and loses the commit identifier, but it does make caching work - this is a non-starter for me, so I tried:
But it's not a templated field, so it can't perform the variable substitution cries in wasted time
Doesn't feel great but it should work in theory - hopefully someone has a better suggestion? |
I run
The whole issue can be resolved by setting apiVersion: skaffold/v2beta8
kind: Config
build:
tagPolicy:
sha256: {}
local:
concurrency: 0
tryImportMissing: true Why isn't it true by default? We should also improve the docs around local caching. |
I think this issue will be fixed with #4850 providing you to save and restore your Skaffold cache file. Normally it's saved in |
Great with the How do you suggest to use cache file together with GitHub Actions for instance? |
It looks like the cache action would work? |
@mr-bjerre did you have a chance to try the cache-action? |
Try this. Keep in mind that this doesn't work for local builds. If you delete images from your registry the cache is no longer stable. - name: Cache skaffold image builds & config
uses: actions/cache@v2
with:
path: ~/.skaffold/
key: fixed |
Thanks for the suggestions ! Question before trying it out: I only have to add that additional step suggested by @StarpTech in GitHub actions? I'll leave everything else as stated on my original post? I.e. the |
@mr-bjerre yes. The action must be inserted before calling skaffold. |
It works !! I'm kinda mind blown by that magic - thanks a lot! |
keep an eye to #4889 |
I might have closed this a little too early. Now my images are no longer being cached. I'm getting the following message in the post cache step in my Github Action.
My actions file look like this name: Deploy to staging
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- "k8s-manifest/**/*"
- "lib/**"
- "services/**"
- "skaffold.yaml"
env:
PROJECT_ID: ${{ secrets.STAGING_PROJECT }}
GKE_CLUSTER: parallax-cluster
GKE_ZONE: europe-west3-a
SKAFFOLD_DEFAULT_REPO: gcr.io/${{ secrets.STAGING_PROJECT }}/parallax
SKAFFOLD_PROFILE: staging
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Check out repository on develop branch
uses: actions/checkout@v2
with:
ref: develop
- name: Install gcloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: "309.0.0"
service_account_key: ${{ secrets.STAGING_SA_BUILD_AND_DEPLOY }}
project_id: ${{ secrets.STAGING_PROJECT }}
- name: Install kustomize, kubectl and skaffold
uses: daisaru11/setup-cd-tools@v1
with:
kubectl: "1.19.2"
kustomize: "3.8.4"
skaffold: "1.15.0"
- name: Cache skaffold image builds & config
uses: actions/cache@v2
with:
path: ~/.skaffold/
key: fixed
- name: Configure docker
run: |
gcloud --quiet auth configure-docker
- name: Connect to cluster
run: |
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"
- name: Build and deploy to cluster
run: |
skaffold run \
-l skaffold.dev/run-id=LEAVE_UNCHANGED In |
I haven't tried this action, but from the docs it says:
I suspect you need to make your cache key have a unique suffix, like the git commit SHA, and use restore-keys? Untested: key: fixed-${{ github.sha }}
restore-keys: |
fixed-${{ github.sha }}
fixed- |
|
@briandealwis exactly. The cache behind |
The suggestion from @briandealwis seems to be working perfectly. Thanks. |
I think I'm missing something here, as my ~/.skaffold/cache is only 36kb even after building large images:
Do I need |
@aantn The |
@briandealwis trying to understand. A few questions:
What I am trying to accomplish is caching layers in the docker file which didn't change between builds where subsequent layers do change. If I understand correctly, I need to cache Docker internals for that and not |
The For docker layer caching I think you'll need to use the |
[removed] wrong issue sorry |
Commenting for triage party, issue is closed with no one currently re-experiencing/commenting on it |
Can confirm #4842 (comment) works well. And a pretty stinking smart idea with a write only key |
Hello Folks, need some guidance here. Trying to learn and test out skaffold cache, and I can see the cache gets restored. But Skaffold still builds a new image
Workflow - https://github.com/rajivsavroop/GH_skaffold_example/blob/test-skaffold-cache/.github/workflows/example.yaml I really appreciate any help you can provide. |
I wish to have a GitHub Action that deploys all services in GKE if the service has been changed (either in manifest, source code or dependency). I wish that the action uses cache for the building.
The action looks like this
while my
skaffold.yaml
looks like thisExpected behavior
I'd expect the above action to only rebuild affected images
Actual behavior
The above action rebuilds all images - also the ones that already exist in the default repo and which hasn't had any changes. I'd expect that
skaffold run
would realize that the unaffected images wouldn't be rebuild (works if I doskaffold run
from my local machine).I have considered setting up a self-hosted runner which always will have the cache available but I imagine that my task is very common for the community so I'm probably just missing something essential here to do. What is the best practice?
The text was updated successfully, but these errors were encountered: