GoogleContainerTools / GoogleContainerTools/skaffold
Skaffold doesn't respect `kube-context` for configuring platform
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
### Expected behavior
If `kubeContext` is set in `skaffold.yaml`, skaffold should use this context to determine the build/deploy platform.
This is what I expect, but it only happens when `~.kube/config`'s context is matching `skaffold.yaml`.
```
DEBU[0000] CLI platforms provided: "" subtask=-1 task=DevLoop
DEBU[0000] getting client config for kubeContext: `docker-desktop` subtask=-1 task=DevLoop
DEBU[0000] platforms detected from active kubernetes cluster nodes: "linux/arm64" subtask=-1 task=DevLoop
DEBU[0000] platforms selected for artifact "server": "linux/arm64" subtask=-1 task=DevLoop
```
### Actual behavior
Skaffold will use the current cluster to determine it:
https://github.com/GoogleContainerTools/skaffold/blob/51aea28d18210ccc004730db716864283d57e793/pkg/skaffold/platform/resolver.go#L124-L151
This is what actually happens. Skaffold ignores `skaffold.yaml` and uses the `~.kube/config`'s context.
```
DEBU[0001] CLI platforms provided: "" subtask=-1 task=DevLoop
DEBU[0001] getting client config for kubeContext: `test-context-amd-64` subtask=-1 task=DevLoop
DEBU[0001] platforms detected from active kubernetes cluster nodes: "linux/amd64" subtask=-1 task=DevLoop
DEBU[0001] platforms selected for artifact "server": "linux/amd64" subtask=-1 task=DevLoop
```
Notice how it resolved `amd64` instead of `arm64`, which caused issues for me.
### Information
- Skaffold version: v2.8.0
- Operating system: macOS Ventura 13.2
- Installed via: homebrew
- Contents of skaffold.yaml:
```yaml
apiVersion: skaffold/v4beta7
kind: Config
build:
artifacts:
- image: test
docker:
dockerfile: Dockerfile
tagPolicy:
inputDigest: {}
local:
push: false
tryImportMissing: true
deploy:
kubeContext: docker-desktop
```
### Steps to reproduce the behavior
1. Have 2 kubernetes contexts, one with amd64 and one with arm64
2. Set your current context to the amd64 cluster
3. Set your `kubeContext` to the arm64 cluster
4. Run `skaffold dev`
Contributor guide
Assessment
This issue has not been assessed yet.