You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+1-318
Original file line number
Diff line number
Diff line change
@@ -179,7 +179,7 @@ The methods above return an object that implements the following helper function
179
179
180
180
### Examples
181
181
182
-
### Creating a pod in a random namespace and wait until it is running
182
+
### Creating a pod and wait until it is running
183
183
184
184
```javascript
185
185
import { Kubernetes } from 'k6/x/kubernetes';
@@ -218,320 +218,3 @@ export default function () {
218
218
}
219
219
}
220
220
```
221
-
222
-
## Resource kind helpers
223
-
224
-
This API offers a helper for each kind of Kubernetes resources supported (Pods, Deployments, Secrets, et cetera). For each one, an interface for creating, getting, listing and deleting objects is offered.
225
-
226
-
>⚠️ This interface is deprecated and will be removed soon
227
-
> -
228
-
Migrate to the usage of the generic resources API.
229
-
</br>
230
-
231
-
232
-
### (Deprecated) Create a client: `new Kubernetes(config)`
233
-
234
-
Creates a Kubernetes client to interact with the Kubernetes cluster.
| addEphemeralContainer | adds an ephemeral container to a running pod |
452
-
453
-
454
-
455
-
```javascript
456
-
import { Kubernetes } from 'k6/x/kubernetes';
457
-
458
-
export default function() {
459
-
const kubernetesClient = new Kubernetes({});
460
-
const namespace = "default"
461
-
const podName = "new-pod"
462
-
const image = "busybox"
463
-
const command = ["sh", "-c", "sleep 5"]
464
-
465
-
kubernetesClient.pods.create({
466
-
namespace: namespace,
467
-
name: podName,
468
-
image: image,
469
-
command: command
470
-
});
471
-
472
-
const options = {
473
-
namespace: namespace,
474
-
name: podName,
475
-
status: "Succeeded",
476
-
timeout: "10s"
477
-
}
478
-
if (kubernetesClient.pods.wait(options)) {
479
-
console.log(podName + " pod completed successfully")
480
-
} else {
481
-
throw podName + " is not completed"
482
-
}
483
-
}
484
-
```
485
-
486
-
### (Deprecated) `Client.secrets`
487
-
488
-
| Method | Description |
489
-
| ------------ | ------ |
490
-
| apply | creates the Kubernetes resource given a YAML configuration |
491
-
| create | creates the Kubernetes resource given an object configuration |
492
-
| delete | removes the named secret |
493
-
| get | returns the named secret |
494
-
| list | returns a collection of secrets |
495
-
496
-
497
-
```javascript
498
-
import { Kubernetes } from 'k6/x/kubernetes';
499
-
500
-
export default function() {
501
-
const kubernetesClient = new Kubernetes({});
502
-
const secrets = kubernetesClient.secrets.list()
503
-
}
504
-
```
505
-
506
-
### (Deprecated) `Client.services`
507
-
508
-
| Method | Description |
509
-
| ------------ | ------ |
510
-
| apply | creates the Kubernetes resource given a YAML configuration |
511
-
| create | creates the Kubernetes resource given an object configuration |
512
-
| delete | removes the named service |
513
-
| get | returns the named service |
514
-
| list | returns a collection of services |
515
-
516
-
517
-
```javascript
518
-
import { Kubernetes } from 'k6/x/kubernetes';
519
-
520
-
export default function() {
521
-
const kubernetesClient = new Kubernetes({});
522
-
const svcs = kubernetesClient.services.list()
523
-
}
524
-
```
525
-
526
-
527
-
## If things go wrong
528
-
529
-
530
-
### Are you using the custom binary?
531
-
532
-
An easy mistake--which happens often--is to forget that `xk6` is generating a new executable. You may be accustomed to simply running `k6` from the command-line which probably isn't your new build. Make sure to use `./k6` after building your extended version otherwise you can expect to see an error similar to:
533
-
534
-
535
-
```bash
536
-
ERRO[0000] The moduleSpecifier "k8s-test-script.js" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://k6.io/docs/using-k6/modules#using-local-modules-with-docker. Additionally it was tried to be loaded as remote module by prepending "https://" to it, which also didn't work. Remote resolution error: "Get "https://k8s-test-script.js": dial tcp: lookup k8s-test-script.js: no such host"
0 commit comments