citrusframework / yaks

YAKS is a platform to enable Cloud Native BDD testing on Kubernetes
Apache License 2.0
83 stars 27 forks source link

Setting namespace for "Given Kubernetes pod {name} is running" and "Given Camel-K integration {name} is running" #365

Closed nhb-89 closed 2 years ago

nhb-89 commented 2 years ago

Hi!

I want to check if a camel-k integration is running on the cluster before send a request to it. Due to some restrictions the yaks test is not running in the same namespace as the integration.

I tried out the kubernetes and camel-k steps.

Here are the things I tried:

Given Kubernetes namespace name-of-integration-namespace Given Kubernetes pod name-pod-integration is running

Given Kubernetes name-of-integration-namespace Given Kubernetes pod labeled with camel.apache.org/integration=integration-name is running --> only one replica

Given Kubernetes namespace name-of-integration-namespace Given Camel-K integration integration-name is running

Unfortunately none of things are tried are working. The first two tries should be working after reading the documentation. The last example should not work, because the steps are from different packages

christophd commented 2 years ago

There is an issue with Given Kubernetes namespace ... as it does not fully control the namespace for inspecting Kubernetes resources.

Kubernetes and Camel-K namespace settings are separate, so we also miss a step Given Camel-K namespace ... respectively.

Fortunately as a workaround you can set the namespace via env variables in yaks-config.yaml configuration. Something like this:

config:
  runtime:
    env:
      - name: YAKS_KUBERNETES_NAMESPACE
        value: <name-of-integration-namespace>
      - name: YAKS_CAMELK_NAMESPACE
        value: <name-of-integration-namespace>

Now your test should look for the right namespace when doing a Given Camel-K integration ... is running.

Of course you need to make sure that the service account yaks-viewer in the yaks test namespace is granted to list resources in the integration namespace.

Please let me know if this works for you

christophd commented 2 years ago

Fixed in v0.9.0