GoogleContainerTools / GoogleContainerTools/skaffold

Default profile that can be overridden with --profile?

Open
#8,458 3 comments 0 reactions 0 assignees View on GitHub
kind/question
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

I'm trying to set a default profile (e.g. when running plain `skaffold dev`) using auto-activations per https://github.com/GoogleContainerTools/skaffold/issues/488, but it doesn't work as I'd hope when using `--profile` to attempt to override the default profile.

Example:
```yaml
apiVersion: skaffold/v4beta2
kind: Config
metadata:
name: skaffold-profiles-test
profiles:
- name: development
activation: [{}] # Set as default profile
manifests:
kustomize:
paths:
- overlays/development
portForward:
- resourceType: service
resourceName: dev-only-service
namespace: default
port: 8080
localPort: 8080
- name: production
manifests:
kustomize:
paths:
- overlays/production
```

The `development` profile has a service and associated port-forward that the `production` profile lacks.

* Running `skaffold dev` works as expected. The auto-activated `development` profile is rendered and port-forwarding starts.
* Running `skaffold dev --profile development` also works the same.
* Running `skaffold dev --profile production` emits errors/warnings:
```
Deployments stabilized in 3.179 seconds
WARN[0005] could not map pods to service default/dev-only-service/8080: getting service default/dev-only-service: services "dev-only-service" not found subtask=service/dev-only-service task=PortForward
port forwarding service-dev-only-service-default-8080 got terminated: output: Error from server (NotFound): services "dev-only-service" not found
```

Although https://skaffold.dev/docs/environment/profiles/#activating-multiple-profiles-at-the-same-time doesn't explicitly mention how `--profile` and `activation:` interact, it appears that `--profile` has added the `production` profile while unfortunately also keeping the (auto-activated) `development` profile.

The only solution we've found is to stop using auto-activation, and duplicate the contents of everything under the profile you want to be the default to the root. edit: that isn't sufficient since it isn't possible to "unset" e.g. required build artifacts.

Is there a way to truly have a default profile and have `--profile` override it, or alternatively disable the "base" config and require a profile to be specified?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.