Skip to content

chore: refactor examples dir  #1253

Closed
Closed
@Ananya2001-an

Description

@Ananya2001-an

Describe the bug
We could refactor the examples folder to make it more readable and maintainable. Like creating a folder called kubectl/equivalents inside examples to give example for the corresponding kubectl command.

For example, creating NamespaceCreateEquivalent.js file which shows you the code equivalent to kubectl command: kubectl create namespace test

** Client Version **
e.g. 0.18.1

** Example Code**
PodsFilterByNamespace.js

const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const k8sApi = kc.makeApiClient(k8s.CoreV1Api);

/*
This sample javascript code is equivalent to `kubectl get pod --namespace=demo-namespace`
*/

const main = async () => {
    try {
        const podRes = await k8sApi.listNamespacedPod('demo-namespace');
        console.log('Pod: ', podRes.body.items[0].metadata);
     } catch (err) {
         console.error(err);
     }
};

main();

Additional context
I have already started working on this and would love to get assigned for the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions