I'm trying to create a local development environment with Skaffold and k3d.
My environment consists of multiple Skaffold modules and every modules declares a dev profile. The main skaffold.yaml
consists of multiple requires statement that are pointing to multiple git repos (every repo has its own skaffold configuration).
In order to prepare the cluster, when I create a cluster using k3d, I run skaffold run -p dev
.
Every skaffold modules declare a profile like this:
profiles:
- name: dev
build:
local:
push: false
useDockerCLI: false
artifacts:
- image: my-org/my-image
docker: {}
sync:
infer:
- '**/*.ts'
This profile is useful if I want to develop on a particular module, but when i want to setup the entire cluster, skaffold will build all the images instead of pulling them from a repo.
What I want to achieve is to build locally when I want to run skaffold dev
on a particular module, but pull images when i run skaffold run
against my skaffold.yaml
entry point.
Is is possibile to do that?
Thanks
Using Skaffold profile, as you do in your question for local development, is a good idea, but you could also introduce an additional profile specifically for pulling images from a repository when running the main
skaffold.yaml
.You would have:
dev
profile in each module, configured for local development, allowing local builds with specific settings likepush: false
. It is ideal for working on individual modules.pull-images
Profile), introduced to handle the specific case where you want to pull images from a repository instead of building them locally. That profile should be defined in each module'sskaffold.yaml
.The main
skaffold.yaml
usesrequires
statements to include all modules.By specifying the
pull-images
profile when runningskaffold run -p pull-images
, it tells Skaffold to use thepull-images
profile for each module. That results in pulling images for the entire cluster setup instead of building them.That would allow you to distinguish between two scenarios:
skaffold dev
): use thedev
profile for building images locally when working on individual modules.skaffold run
): use thepull-images
profile to pull images from a repository for all modules when setting up the entire cluster.Your module Skaffold configuration would be:
And in your main
skaffold.yaml
:Applying these changes to your example module's
skaffold.yaml
: