Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Helpers for exposing pod/deployment in a cluster #62

Closed
pablochacin opened this issue Jul 15, 2022 · 1 comment
Closed

Create Helpers for exposing pod/deployment in a cluster #62

pablochacin opened this issue Jul 15, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@pablochacin
Copy link
Contributor

pablochacin commented Jul 15, 2022

When running chaos tests this is common pattern:

  • Create a target pod or deployment (commonly, on its own namespace)
  • Subject the target pod/deployment to certain attack (e.g. kill replica, stress resources, delay network traffic)
  • Submit load to the target and measure behavior

A similar requirement may arise in other contexts, such as integration tests.

However, in order to reach the target from outside a k8s cluster, it must be exposed as a service and optionally (depending on the cluster's infrastructure) the service exposed as an ingress.

Presently the xk6-kubernetes extension offers the basic building blocks for doing so, but requires a considerable programming effort. It can be done by means of applying a raw yaml manifest or by creating a kubernetes service object "manually" and submitting it to the cluster via a create operation. Neither option seems neither convenient nor idiomatic in the context of k6 testing.

Therefore, it would be convenient to create a helper method in the ingress package that allows exposing a pod/deployment as a service and, optionally, as an ingress.

The intended API should look similar to this example below:

 import { kubernetes } from xk6-kubernetes
 
k8s  =  new Kubernetes()

pod = k8s.pods.Create({
  name: "my-pod",
  namespace: "my-namespace",
  image: "my-image",
} )

k8s.helpers.expose({
  selector: { run: "my-app" },
  service: "my-service", 
  type: "ClusterIP",
  port: 80, 
  ingress: "my-ingress",
  path: "/my-app"
})
@pablochacin
Copy link
Contributor Author

With the introduction of the Generic API and helper functions such as getExternalIP this helper may result redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant