GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
14.94k stars 1.62k forks source link

Modules from a multi-config project are deploying in the wrong contexts #7506

Closed renzodavid9 closed 2 years ago

renzodavid9 commented 2 years ago

In a multi config project (different skaffold.yaml files), where each config has a different deploy context (kubeContext), running skaffold dev deploys all the modules in all the contexts.

Expected behavior

Every module should be deploy in its corresponding context

Actual behavior

All the modules are deployed in all the contexts

Information

We can use the example project multi-config-microservices, adding different kubeContext for each module:

Modify leeroy-app skaffold.yaml file to add a kubeContext:

apiVersion: skaffold/v2beta28
kind: Config
metadata:
  name: app-config
requires:
- path: ../base
build:
  artifacts:
  - image: leeroy-app
    requires:
    - image: base
      alias: BASE
deploy:
  kubeContext: context-one
  kubectl:
    manifests:
    - kubernetes/*
portForward:
- resourceType: deployment
  resourceName: leeroy-app
  port: http
  localPort: 9001

Modify leeroy-web skaffold.yaml file to add a kubeContext:

apiVersion: skaffold/v2beta28
kind: Config
metadata:
  name: web-config
requires:
- path: ../base
build:
  artifacts:
  - image: leeroy-web
    requires:
    - image: base
      alias: BASE
deploy:
  kubeContext: context-two
  kubectl:
    manifests:
    - kubernetes/*
portForward:
- resourceType: deployment
  resourceName: leeroy-web
  port: 8080
  localPort: 9000

The other yaml files in the example don't need a change.

Steps to reproduce the behavior

  1. Open the multi-config-microservices example
  2. Modify the skaffold.yaml files listed above to add different kubeContext
  3. Create the context-one and context-two contexts
  4. Run skaffold dev in the multi-config-microservices example
  5. Check the pods deployed in each context running kubectl get pods --context=context-one and kubectl get pods --context=context-two, you'll notice that all the modules were deployed in all the contexts
aaron-prindle commented 2 years ago

Dupe of https://github.com/GoogleContainerTools/skaffold/issues/7540, closing