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

     1  ---
     2  title: "Kube-context Activation"
     3  linkTitle: "Kube-context Activation"
     4  weight: 80
     5  featureId: deploy.kubecontext
     6  ---
     7  
     8  When interacting with a Kubernetes cluster, just like any other Kubernetes-native tool,
     9  Skaffold requires a valid Kubernetes context to be configured.
    10  The selected kube-context determines the Kubernetes cluster, the Kubernetes user, and the default namespace.
    11  By default, Skaffold uses the _current_ kube-context from your kube-config file.
    12  
    13  You can override this default one of two ways:
    14  
    15  1. `--kube-context` flag
    16  
    17      ```bash
    18      skaffold dev --kube-context <myrepo>
    19      ```
    20  
    21  1. Specify `deploy.kubeContext` configuration in `skaffold.yaml`
    22  
    23      ```yaml
    24      deploy:
    25        kubeContext: minikube
    26      ```
    27  
    28  The CLI flag always takes precedence over the config field in the `skaffold.yaml`.
    29  
    30  ### Kube-context activation and Skaffold profiles
    31  
    32  The kube-context has a double role for Skaffold profiles:
    33  
    34  1. A Skaffold profile may be auto-activated by the current kube-context (via `profiles.activation.kubeContext`).
    35  
    36  1. A Skaffold profile may change the kube-context (via `profiles.deploy.kubeContext`).
    37  
    38  Skaffold ensures that these two roles are not conflicting.
    39  To that end, profile activation is done with the original kube-context.
    40  If any profile is auto-activated by a matching kube-context, the resulting kube-context must remain unchanged.
    41  This rule prevents profile-specific settings for one context to be deployed into a different context.
    42  
    43  For example, given the following profiles:
    44  
    45  ```yaml
    46  profiles:
    47    - name: profile-1
    48      deploy:
    49        kubeContext: docker-for-desktop
    50  
    51    - name: profile-2
    52      activation:
    53        - kubeContext: minikube
    54  ```
    55  
    56  It is illegal to activate both profiles here, because `profile-2` has an activation by `kube-context` and `profile-1` changes the effective `kube-context`.
    57  This happens for
    58  
    59  - `skaffold run -p profile-1,profile-2`
    60  - `skaffold run -p profile-1` if the current kube-context is `minikube`
    61  
    62  {{< alert title="Note" >}}
    63  It is possible to activate conflicting profiles in conjunction with the CLI flag. So the following example is valid `skaffold run --kube-context minikube -p profile-1,profile-2`
    64  {{< /alert >}}
    65  
    66  ### Limitations
    67  
    68  It is not possible to change the kube-context of a running `skaffold dev` session.
    69  To pick up the changes to `kubeContext`, you will need to quit and re-run `skaffold dev`.
    70  
    71  ## Kubeconfig selection
    72  
    73  The kubeconfig file is only loaded once during Skaffold's startup phase.
    74  
    75  1. If the `--kubeconfig` flag is set, then only that file is loaded.
    76  2. If `$KUBECONFIG` environment variable is set, then it is used as a list of paths (normal path delimiting rules for your system). These paths are merged.
    77  3. Otherwise, ${HOME}/.kube/config is used.
    78  4. If neither `--kubeconfig` or `--kube-context` are given and no kubeconfig file is found, Skaffold will try to guess an in-cluster
    79     configuration using the secrets stored in `/var/run/secrets/kubernetes.io/serviceaccount/`. This is useful when Skaffold runs inside
    80     a kubernetes Pod and should deploy to the same cluster.