Skip to content

chore: refactor examples dir #1253

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

Closed
Ananya2001-an opened this issue Sep 7, 2023 · 0 comments
Closed

chore: refactor examples dir #1253

Ananya2001-an opened this issue Sep 7, 2023 · 0 comments

Comments

@Ananya2001-an
Copy link
Member

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.

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

No branches or pull requests

1 participant