You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Skaffold, a skaffold.env file can be defined in the project root directory to specify environment variables that Skaffold will load into the process. This provides a more organized and manageable way of setting environment variables, rather than passing them as command line arguments.
The skaffold.env file should be in the format of KEY=value pairs, with one pair per line. Skaffold will automatically load these variables into the environment before running any commands.
Here is an example skaffold.env file:
ENV_VAR_1=value1
ENV_VAR_2=value2
Setting Skaffold Flags with Environment Variables
In addition to loading environment variables from the skaffold.env file, Skaffold also allows users to set flags using environment variables. To set a flag using an environment variable, use the SKAFFOLD_ prefix and convert the flag name to uppercase.
For example, to set the --cache-artifacts flag to true, the equivalent environment variable would be SKAFFOLD_CACHE_ARTIFACTS=true.
Here is an example usage in the skaffold.env file:
Reasons for not adding it as a skaffold.yaml field
There's no obvious way to incorporate the flags like default-repo and others in the skaffold configuration definition. It only make sense to have a single value per run for these parameters. But right now even as a top level parameter in the skaffold.yaml file, due to multi-module support Skaffold would need to enforce that all the skaffold pipelines define the same value for these flags, and also decide how to resolve conflicts. We avoid that by allowing a single skaffold.env file that can define these flags along with other env variables that will only have a single resolved value despite the number of skaffold modules involved.
Can we add 1 integration tests that has a skaffold.env file and a go template that uses an ENV var set in the skaffold.env file in the skaffold.yaml (validating that it was correctly set)? Want to make sure we have a way of verifying this continues to work over time (if we bump the deps or we change our env expansion logic)
Additionally once this is merged, we might need to coordinate w/ parter teams, etc. as some bundle all relevant skaffold files for their pipeline's. We might need to add this to set of files to be tracked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #1545, #7913
Description
In Skaffold, a
skaffold.envfile can be defined in the project root directory to specify environment variables that Skaffold will load into the process. This provides a more organized and manageable way of setting environment variables, rather than passing them as command line arguments.The
skaffold.envfile should be in the format ofKEY=valuepairs, with one pair per line. Skaffold will automatically load these variables into the environment before running any commands.Here is an example
skaffold.envfile:Setting Skaffold Flags with Environment Variables
In addition to loading environment variables from the
skaffold.envfile, Skaffold also allows users to set flags using environment variables. To set a flag using an environment variable, use theSKAFFOLD_prefix and convert the flag name to uppercase.For example, to set the
--cache-artifactsflag totrue, the equivalent environment variable would beSKAFFOLD_CACHE_ARTIFACTS=true.Here is an example usage in the
skaffold.envfile:Reasons for not adding it as a
skaffold.yamlfieldThere's no obvious way to incorporate the flags like
default-repoand others in the skaffold configuration definition. It only make sense to have a single value per run for these parameters. But right now even as a top level parameter in theskaffold.yamlfile, due to multi-module support Skaffold would need to enforce that all the skaffold pipelines define the same value for these flags, and also decide how to resolve conflicts. We avoid that by allowing a singleskaffold.envfile that can define these flags along with other env variables that will only have a single resolved value despite the number of skaffold modules involved.