1.2.1 • Published 3 years ago

@pubgcorp/kubectl v1.2.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 years ago

How to Use

1. Implement IKubeConfigFactory

class KubeconfigFactory implements IKubeconfigFactory {
    public async getKubeconfigs(): Promise<{ [name: string]: IKubeconfig }> {
        // TODO: Implement method making Dictionary<name, IKubeconfig> 
    }
}

2. Create Kubectl Instance

  • General Version
    const kubectl = new Kubectl(new KubeconfigFactory());
  • Using tsyringe Version
    // entrypoint of application
    container.register<Kubectl>(Kubectl, { useFactory: (c) => new Kubectl(c.resolve(KubeconfigFactory)) });

3. Examples

  • Get Resource
    export interface KubectlResponse {
        status: string;
        message: string;
        obj?: any;
    }
    // clusterName is key of dictionary<name, K8sCluster>
    const result: KubectlResponse = await kubectl.targetCluster(clusterName).get(namespace, kind, name);
    for custom resource
    // apiVersion means like kubernetes-client.io/v1
    const result: KubectlResponse = await kubectl.targetCluster(clusterName).get(namespace, kind, name, apiVersion);
  • Apply Resource
    const K8sObjects = [{
        kind: 'Namespace',
        apiVersion: 'v1',
        metadata: {
            name: 'abcdefg',
            labels: {},
            annotations: {},
        }
    }]
    const result = await kubectl.targetCluster(clusterName).apply(k8sObjects);
  • Patch Resource
    if useJsonPatch is true, use object as json patch object, otherwise get target and merge with object.
    const result = await kubectl.targetCluster(clusterName).patch(namespace, target, targetName, object, useJsonPatch);
1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago