github.com/GoogleContainerTools/skaffold/v2@v2.13.2/docs-v1/content/en/docs/environment/profiles.md (about)

     1  ---
     2  title: "Profiles"
     3  linkTitle: "Profiles"
     4  weight: 70
     5  featureId: profiles
     6  aliases: [/docs/how-tos/profiles]
     7  ---
     8  
     9  Skaffold profiles allow you to define build, test and deployment
    10  configurations for different contexts. Different contexts are typically different
    11  environments in your app's lifecycle, like Production or Development.
    12  
    13  You can create profiles in the `profiles` section of `skaffold.yaml`.
    14  
    15  For a detailed discussion on Skaffold configuration, see
    16  [Skaffold Concepts]({{< relref "/docs/design/config.md" >}}) and
    17  [skaffold.yaml References]({{< relref "/docs/references/yaml" >}}).
    18  
    19  ## Profiles (`profiles`)
    20  
    21  Each profile has six parts:
    22  
    23  * Name (`name`): The name of the profile
    24  * Build configuration (`build`)
    25  * Test configuration (`test`)
    26  * Deploy configuration (`deploy`)
    27  * Patches (`patches`)
    28  * Activation (`activation`)
    29  
    30  Once a profile is activated, the specified `build`, `test` and `deploy` configuration
    31  in it will be laid onto, but won't completely replace, the `build`, `test` and `deploy` sections declared
    32  in the main section of `skaffold.yaml`. The `build`, `test` and `deploy` configuration in the `profiles`
    33  section use the same syntax as the `build`, `test` and `deploy` sections of
    34  `skaffold.yaml`; for more information, see [Builders]({{< relref "/docs/pipeline-stages/builders" >}}),
    35  [Testers](/docs/pipeline-stages/testers), [Deployers]({{< relref "/docs/pipeline-stages/deployers" >}}) and you can always refer to
    36   [skaffold.yaml reference]({{< relref "/docs/references/yaml" >}}) for an overview of the syntax.
    37   Alternatively, you can override the main configuration with finer grained control using `patches`.
    38  
    39  
    40  ### Activation
    41  
    42  You can activate a profile two ways: CLI flag or skaffold.yaml activations.
    43  
    44  **CLI flag**: You can activate profiles with the `-p` (`--profile`) parameter in the
    45  `skaffold dev` and `skaffold run` commands.
    46    ```bash
    47    skaffold run -p [PROFILE]
    48    ```
    49  
    50  **Activations in skaffold.yaml**: You can auto-activate a profile based on
    51  
    52  * kubecontext (could be either a string or a regexp: prefixing with `!` will negate the match)
    53  * environment variable value
    54  * skaffold command (dev/run/build/deploy)
    55  
    56  A profile is auto-activated if any one of the activations under it are triggered.
    57  An activation is triggered if all of the criteria (`env`, `kubeContext`, `command`) are triggered.
    58  
    59  
    60  In the example below:
    61  
    62   * `profile1` is activated if `MAGIC_VAR` is 42
    63   * `profile2` is activated if `MAGIC_VAR` is 1337 or we are running `skaffold dev` while kubecontext is set to `minikube`.
    64  
    65  {{% readfile file="samples/profiles/activations.yaml" %}}
    66  
    67  
    68  ### Override via replacement
    69  
    70  The `build`, `test` and `deploy` sections defined in the profile will be laid onto the main configuration.
    71  The default values are the same in profiles as in the main config.
    72  
    73  The following example showcases a `skaffold.yaml` with one profile named `gcb`,
    74  for building with Google Cloud Build:
    75  
    76  {{% readfile file="samples/profiles/profiles.yaml" %}}
    77  
    78  With no profile activated, Skaffold will build the artifact
    79  `gcr.io/k8s-skaffold/skaffold-example` using local Docker daemon and deploy it
    80  with `kubectl`.
    81  
    82  However, if you run Skaffold with the following command:
    83  
    84  ```bash
    85  skaffold dev -p gcb
    86  ```
    87  
    88  Skaffold will switch to Google Cloud Build for building artifacts.
    89  
    90  Note that
    91  since the `gcb` profile does not specify a deploy configuration, Skaffold will
    92  continue using `kubectl` for deployments.
    93  
    94  
    95  ### Override via patches
    96  
    97  Patches are a more verbose way of overriding your config, but they provide a powerful, fine-grained way
    98  to override individual values in your yaml config. They are based on [JSON Patch](http://jsonpatch.com/) under the hood.
    99  
   100  In the example below instead of overriding the whole `build` section, the `dev` profile specifically
   101  defines a different Dockerfile to use for the first artifact.
   102  
   103  {{% readfile file="samples/profiles/patches.yaml" %}}
   104  
   105  ### Activating multiple profiles at the same time
   106  
   107  Multiple profiles can be specified either by using the `-p` flag multiple times or by comma separated profiles.
   108  
   109  ```bash
   110  skaffold dev -p hello,world
   111  ```
   112  
   113  Skaffold will activate both profiles, `hello` and `world`. 
   114  This is e.g. useful when combined with patches to provide a composable development setup where `hello` and `world` can be added on demand.
   115  
   116  ### Deactivating Profiles
   117  
   118  Profiles can also be manually deactivated by prefixing the profile name with `-` like so:
   119  
   120  ```bash
   121  skaffold dev -p hello,-world
   122  ```
   123  
   124  Skaffold will activate the `hello` profile, and deactivate the `world` profile, even if it had otherwise been activated through the configuration.