Skip to content

Latest commit

 

History

History

kubernetes

NestCloud - Kubernetes

NPM Version Package License NPM Downloads Travis Linux Coverage

Description

The kubernetes client module for nestcloud.

Installation

$ npm install --save @nestcloud/kubernetes

Usage

Use External Cluster

import { Module } from '@nestjs/common';
import { KubernetesModule } from '@nestcloud/kubernetes';

@Module({
  imports: [
      KubernetesModule.forRoot({ kubeConfig: '/root/.kube/config' })
  ],
})
export class AppModule {
}

Use Internal Cluster

import { Module } from '@nestjs/common';
import { KubernetesModule } from '@nestcloud/kubernetes';

@Module({
  imports: [
      KubernetesModule.forRoot()
  ],
})
export class AppModule {}

Use Client

import { Injectable, IKubernetes } from '@nestjs/common';
import { InjectKubernetes } from '@nestcloud/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

License

NestCloud is MIT licensed.