Skip to content

Commit cf95003

Browse files
authored
Merge pull request #95 from grafana/paul/remove-deprecations
Removed deprecated APIs
2 parents 1955c37 + cfaa46b commit cf95003

27 files changed

+43
-5628
lines changed

README.md

+1-318
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ The methods above return an object that implements the following helper function
179179
180180
### Examples
181181
182-
### Creating a pod in a random namespace and wait until it is running
182+
### Creating a pod and wait until it is running
183183
184184
```javascript
185185
import { Kubernetes } from 'k6/x/kubernetes';
@@ -218,320 +218,3 @@ export default function () {
218218
}
219219
}
220220
```
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.
235-
236-
| Config options | Type | Description | Default |
237-
| ------------ | ------ | ---------------------------------------- | ------ |
238-
| config_path | String | The path to the kubeconfig file | ~/.kube/config |
239-
240-
```javascript
241-
import { Kubernetes } from 'k6/x/kubernetes';
242-
243-
export default function () {
244-
const kubernetesClient = new Kubernetes({
245-
// config_path: "/path/to/kube/config"
246-
})
247-
}
248-
```
249-
250-
### (Deprecated) `Client.config_maps`
251-
252-
| Method | Description |
253-
| ------------ | ------ |
254-
| apply | creates the Kubernetes resource given a YAML configuration |
255-
| create | creates the Kubernetes resource given an object configuration |
256-
| delete | removes the named ConfigMap |
257-
| get | returns the named ConfigMaps |
258-
| list | returns a collection of ConfigMaps |
259-
260-
```javascript
261-
import { Kubernetes } from 'k6/x/kubernetes';
262-
263-
export default function () {
264-
const kubernetesClient = new Kubernetes({});
265-
266-
const nameSpace = "default";
267-
const name = "config-map-name";
268-
kubernetesClient.config_maps.apply(getConfigMapYaml(name), nameSpace);
269-
}
270-
```
271-
272-
### (Deprecated) `Client.deployments`
273-
274-
| Method | Description |
275-
| ------------ | ------ |
276-
| apply | creates the Kubernetes resource given a YAML configuration |
277-
| create | creates the Kubernetes resource given an object configuration |
278-
| delete | removes the named Deployment |
279-
| get | returns the named Deployment |
280-
| list | returns a collection of Deployments |
281-
282-
283-
284-
```javascript
285-
import { Kubernetes } from 'k6/x/kubernetes';
286-
287-
export default function () {
288-
const kubernetesClient = new Kubernetes({});
289-
290-
const nameSpace = "default";
291-
const name = "deployment-name";
292-
const app = 'app-label';
293-
294-
kubernetesClient.deployments.apply(getDeploymentYaml(name, app), nameSpace);
295-
}
296-
```
297-
298-
299-
### (Deprecated) `Client.ingresses`
300-
301-
| Method | Description |
302-
| ------------ | ------ |
303-
| apply | creates the Kubernetes resource given a YAML configuration |
304-
| create | creates the Kubernetes resource given an object configuration |
305-
| delete | removes the named Ingress |
306-
| get | returns the named Ingress |
307-
| list | returns a collection of Ingresses |
308-
309-
```javascript
310-
import { Kubernetes } from 'k6/x/kubernetes';
311-
312-
export default function () {
313-
const kubernetesClient = new Kubernetes({});
314-
315-
const nameSpace = "default";
316-
const name = "deployment-name";
317-
const url = 'ingress-url.com';
318-
319-
kubernetesClient.ingresses.apply(getIngressYaml(name, url), nameSpace);
320-
}
321-
```
322-
323-
### (Deprecated) `Client.jobs`
324-
325-
| Method | Description |
326-
| ------------ | ------ |
327-
| apply | creates the Kubernetes resource given a YAML configuration |
328-
| create | creates the Kubernetes resource given an object configuration |
329-
| delete | removes the named Job |
330-
| get | returns the named Jobs |
331-
| list | returns a collection of Jobs |
332-
| wait | wait for all Jobs to complete |
333-
334-
```javascript
335-
import { Kubernetes } from 'k6/x/kubernetes';
336-
337-
export default function () {
338-
const kubernetesClient = new Kubernetes({});
339-
const namespace = "default"
340-
const jobName = "new-job"
341-
const image = "perl"
342-
const command = ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
343-
344-
kubernetesClient.jobs.create({
345-
namespace: namespace,
346-
name: jobName,
347-
image: image,
348-
command: command
349-
})
350-
351-
const completed = kubernetesClient.jobs.wait({
352-
namespace: namespace,
353-
name: jobName,
354-
timeout: "30s"
355-
})
356-
const jobStatus = completed? "completed": "not completed"
357-
}
358-
```
359-
360-
### (Deprecated) `Client.namespaces`
361-
362-
| Method | Description |
363-
| ------------ | ------ |
364-
| apply | creates the Kubernetes resource given a YAML configuration |
365-
| create | creates the Kubernetes resource given an object configuration |
366-
| delete | removes the named Namespaces |
367-
| get | returns the named Namespace |
368-
| list | returns a collection of Namespaces |
369-
370-
371-
```javascript
372-
import { Kubernetes } from 'k6/x/kubernetes';
373-
374-
export default function () {
375-
const kubernetesClient = new Kubernetes({});
376-
const name = "namespace-name";
377-
378-
kubernetesClient.namespaces.apply(getNamespaceYaml(name));
379-
}
380-
```
381-
382-
### (Deprecated) `Client.nodes`
383-
384-
| Method | Description |
385-
| ------------ | ------ |
386-
| list | returns a collection of Nodes comprising the cluster |
387-
388-
```javascript
389-
import { Kubernetes } from 'k6/x/kubernetes';
390-
391-
export default function () {
392-
const kubernetesClient = new Kubernetes({});
393-
const nodes = kubernetesClient.nodes.list()
394-
}
395-
```
396-
397-
### (Deprecated) `Client.persistent_volumes`
398-
399-
| Method | Description |
400-
| ------------ | ------ |
401-
| apply | creates the Kubernetes resource given a YAML configuration |
402-
| create | creates the Kubernetes resource given an object configuration |
403-
| delete | removes the named persistent volume |
404-
| get | returns the named persistent volume instance |
405-
| list | returns a collection of persistent volumens |
406-
407-
```javascript
408-
import { Kubernetes } from 'k6/x/kubernetes';
409-
410-
export default function () {
411-
const kubernetesClient = new Kubernetes({});
412-
413-
const name = "example-pv";
414-
kubernetesClient.persistent_volumes.apply(getPVYaml(name, "1Gi", "local-storage"));
415-
}
416-
```
417-
418-
### (Deprecated) `Client.persistent_volumes_claims`
419-
420-
| Method | Description |
421-
| ------------ | ------ |
422-
| apply | creates the Kubernetes resource given a YAML configuration |
423-
| create | creates the Kubernetes resource given an object configuration |
424-
| delete | removes the named persistent volume claim |
425-
| get | returns the named persistent volume claim |
426-
| list | returns a collection of persistent volumen claims |
427-
428-
```javascript
429-
import { Kubernetes } from 'k6/x/kubernetes';
430-
431-
export default function () {
432-
const kubernetesClient = new Kubernetes({});
433-
434-
const name = "example-pvc";
435-
const nameSpace = "default";
436-
437-
kubernetes.persistent_volume_claims.apply(getPVCYaml(name, "1Gi", "nfs-csi"), nameSpace);
438-
}
439-
```
440-
441-
### (Deprecated) `Client.pods`
442-
443-
| Method | Description |
444-
| ------------ | ------ |
445-
| create | runs a pod |
446-
| delete | removes the named Pod |
447-
| get | returns the named Pod |
448-
| list | returns a collection of Pods |
449-
| wait | wait for the Pod to be in a given status |
450-
| exec | executes a non-interactive command |
451-
| 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"
537-
```

0 commit comments

Comments
 (0)