Skip to content
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 init' for Kustomize projects generates profiles for each overlay #4349

Merged
merged 1 commit into from Jun 24, 2020

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Jun 18, 2020

Fixes #4293

this PR changes our support for Kustomize projects in skaffold init to generate a profile for each overlay. this will prevent multiple overlays from being applied in a single deploy, which is very likely NOT what users want to do. this is a common setup for projects with shared configuration across multiple environments, where several overlays are specified but only one is applied depending on the environment.

with this change, Skaffold will attempt to choose a default overlay to apply on a vanilla run of skaffold dev, so that users don't have to pass the explicit profile name on their first run after bootstrapping. the heuristic we'll use is:

  • if any overlay exists with the name dev, use it
  • otherwise, use the first overlay that isn't named prod

our directory traversal is ordered, so the generated config will always be deterministic.

users can also opt to provide their desired default overlay using the flag --default-kustomization.

@nkubala nkubala requested a review from a team as a code owner June 18, 2020 22:44
@nkubala nkubala requested a review from tstromberg June 18, 2020 22:44
@codecov
Copy link

codecov bot commented Jun 18, 2020

Codecov Report

Merging #4349 into master will increase coverage by 0.17%.
The diff coverage is 85.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4349      +/-   ##
==========================================
+ Coverage   71.75%   71.93%   +0.17%     
==========================================
  Files         325      325              
  Lines       12613    12708      +95     
==========================================
+ Hits         9051     9141      +90     
- Misses       2983     2990       +7     
+ Partials      579      577       -2     
Impacted Files Coverage Δ
pkg/skaffold/initializer/deploy/init.go 72.72% <66.66%> (+0.85%) ⬆️
pkg/skaffold/initializer/analyze/kustomize.go 75.00% <71.42%> (-25.00%) ⬇️
pkg/skaffold/initializer/deploy/kustomize.go 84.72% <85.18%> (+6.94%) ⬆️
cmd/skaffold/app/cmd/init.go 100.00% <100.00%> (ø)
pkg/skaffold/deploy/kustomize.go 77.19% <100.00%> (+0.13%) ⬆️
pkg/skaffold/initializer/analyze/analyze.go 90.47% <100.00%> (+0.31%) ⬆️
pkg/skaffold/initializer/config.go 100.00% <100.00%> (ø)
pkg/skaffold/initializer/deploy/kubectl.go 85.71% <100.00%> (+0.52%) ⬆️
pkg/skaffold/initializer/init.go 37.20% <100.00%> (ø)
pkg/skaffold/errors/err_map.go 100.00% <0.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 286fa95...7eba9ca. Read the comment docs.

Copy link
Member

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good except couple of nits.

docs/content/en/docs/pipeline-stages/init.md Show resolved Hide resolved

// Initializer detects a deployment type and is able to extract image names from it
type Initializer interface {
// deployConfig generates Deploy Config for skaffold configuration.
DeployConfig() latest.DeployConfig
DeployConfig() (latest.DeployConfig, []latest.Profile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shd we rename DeployConfig to DeployConfigWithProfiles since profile is not part of deploy config.
Or else, we could define a new method Profiles.

Upto you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but in the end decided it was ok since the contract is defined in the interface and is documented. DeployConfigWithProfiles is technically correct but seemed too verbose to me, especially because it's getting called next to BuildConfig. I'd vote to leave it alone unless you feel strongly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative is a separate Profiles().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would also need a big refactor since the profiles get generated basically from excess deploy configuration. i'm not really sure the best way to handle it 🤷

@tejal29 tejal29 self-assigned this Jun 19, 2020
@nkubala nkubala force-pushed the kustomize-improvements branch 5 times, most recently from db1a21b to 6fe50b2 Compare June 24, 2020 18:35
Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few optional things that can be left for the future. They're not functional changes.

docs/content/en/docs/pipeline-stages/init.md Show resolved Hide resolved
docs/content/en/docs/pipeline-stages/init.md Show resolved Hide resolved

// Initializer detects a deployment type and is able to extract image names from it
type Initializer interface {
// deployConfig generates Deploy Config for skaffold configuration.
DeployConfig() latest.DeployConfig
DeployConfig() (latest.DeployConfig, []latest.Profile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative is a separate Profiles().

pkg/skaffold/initializer/deploy/kubectl_test.go Outdated Show resolved Hide resolved
pkg/skaffold/initializer/init.go Show resolved Hide resolved
pkg/skaffold/initializer/deploy/kustomize.go Show resolved Hide resolved
@nkubala nkubala merged commit 4459eea into GoogleContainerTools:master Jun 24, 2020
@nkubala nkubala deleted the kustomize-improvements branch June 24, 2020 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[skaffold init] Support multiple kustomizations with heirarchy in kustomize projects
4 participants