Open balopat opened 4 years ago
Would something like this make sense:
builders:
- name: default # default is docker, unless otherwise specified
type: docker
- name: kaniko
type: kaniko
options:
image: gcr.io/kaniko-project/executor:v0.20.0
flags: ....
cluster:
namespace: kaniko
pullSecretName: kaniko-secret
Then
build:
artifacts:
# uses default builder
- image: my-image
context: docker/my-image
- image: my-other-image
context: docker/my-other-image
builder: kaniko. # overeride default builder
Or at the profile level
profiles:
- name: my-cool-profile
builder: kaniko # Use kaniko as the default builder for this profile
What you are suggesting is logically sound and follows the "referencable builder" concept that you kind of introduced using YamlAnchors. However, it introduces a new feature: the ability to specify different builders per artifact.
Do you have a use case for that? Based on the forgerock yaml it seems you either want to build all artifacts with docker or all of them with kaniko. Would the hybrid mode help you?
The hybrid mode can complicate things when you have each of the artifacts potentially built differently (docker, kaniko, gcb) and remove some options for optimizations, but it's far from impossible.
We had a very long discussion we had about per artifact builders where we concluded that we shouldn't support this: https://github.com/GoogleContainerTools/skaffold/issues/1179#issuecomment-433458471
We don't really have a use case for a builder per artifact. I got carried away with a bit of bike shedding!
A referencable builder per profile (with a default if omitted) would be quite nice. It would save repeating the builder spec on each profile.
Is this use case planned to be supported? Thanks
yes! we are planning to work on this in our proposed build config revamp in Q4
Just to get this issue to show some life:
This remains a big unaddressed usability issue with skaffold
Today, if you want to switch all your builder types to kaniko from local docker, you'll have to repeat all your artifacts. This is cumbersome so people resort to using YamlAnchors. E.g. https://github.com/ForgeRock/forgeops/blob/master/skaffold.yaml
The hydrated version of this yaml is this:
A smaller example:
Issues with our current config reflecting in repetition are:
kaniko.image
,kaniko.flags
, etc. are only available on the artifact level. Recommendation: If these would be available on thebuild.cluster.kaniko
level, one wouldn't have to repeat them for each artifactartifacts.kaniko.image
and try to build withlocal
docker, then skaffold fails with:Recommendation: skaffold could ignore kaniko related settings on the artifacts when building with docker. This means that artifacts could have at the same time settings for docker, kaniko and GCB (though this last one doesn't exist). In goland this might translate to an artifact being able to become simultaneously a KanikoArtifact and a DockerArtifact - not sure - but our abstraction here is messy.
The final result would be something like this: