1.2.1 • Published 4 years ago
@pubgcorp/kubectl v1.2.1
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; }
for custom resource// clusterName is key of dictionary<name, K8sCluster> const result: KubectlResponse = await kubectl.targetCluster(clusterName).get(namespace, kind, name);
// 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
4 years ago
1.2.0
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.1.7
4 years ago
1.1.6
4 years ago
1.1.5
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
4 years ago
1.0.28
4 years ago
1.0.27
4 years ago
1.0.26
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago