0.8.5 • Published 2 years ago
@nestcloud2/kubernetes v0.8.5
NestCloud - Kubernetes
Description
The kubernetes client module for nestcloud.
Installation
$ npm install --save @nestcloud2/kubernetes
Usage
Use External Cluster
import { Module } from '@nestjs/common';
import { KubernetesModule } from '@nestcloud2/kubernetes';
@Module({
imports: [KubernetesModule.forRoot({ kubeConfig: '/root/.kube/config' })],
})
export class AppModule {}
Use Internal Cluster
import { Module } from '@nestjs/common';
import { KubernetesModule } from '@nestcloud2/kubernetes';
@Module({
imports: [KubernetesModule.forRoot()],
})
export class AppModule {}
Use Client
import { Injectable, IKubernetes } from '@nestjs/common';
import { InjectKubernetes } from '@nestcloud2/kubernetes';
@Injectable()
export class TestService {
constructor(@InjectKubernetes() private readonly client: IKubernetes) {}
async getConfigMaps() {
const namespace = 'default';
const configMap = 'test-configmap';
const result = await this.client.api.v1
.namespaces(namespace)
.configmaps(configMap)
.get();
console.log(result);
}
}
Stay in touch
- Author - NestCloud
License
NestCloud is MIT licensed.