Skaffold doesn't respect `kube-context` for configuring platform
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:
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
- Have 2 kubernetes contexts, one with amd64 and one with arm64
- Set your current context to the amd64 cluster
- Set your
kubeContextto the arm64 cluster - Run
skaffold dev
Hey @anthonyalayo, thanks for opening this issue. Have you try the --kube-context flag? Maybe that can help for your use case. It will be something like: skaffold dev --kube-context=docker-desktop. Please let us know! Thanks 😄
@renzodavid9 thanks for the reply! I'm hoping for a solution that can be built into the yaml file, as it is more easier synchronize across developers. Is there an option within the yaml?