Interview Prep/Jenkins/Integrations & delivery

Image builds take 9 minutes in Kubernetes pods because nothing is cached. How do you add caching with Kaniko?

IntermediateScenarioIntegrations & delivery
Answer

Situation read → Ephemeral pods lose the layer cache.

What I'd do →

  1. Enable Kaniko's registry cache:
    /kaniko/executor --context dir://$WORKSPACE --dockerfile Dockerfile \
      --destination $IMAGE:$TAG --cache=true --cache-repo=$REGISTRY/cache/shack-app
    
  2. Order the Dockerfile so dependency install layers come before source copy.
  3. Use a base image mirror in the internal registry.
  4. For BuildKit, use --export-cache type=registry and --import-cache.

Why → A registry-backed cache survives pod deletion.

Interview tip → Mention cache repos need their own retention policy.

All Jenkins questions Roadmap: Jenkins

More on Integrations & delivery