fix(core): update
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import * as plugins from './kubernetes.plugins';
|
||||
import * as paths from './kubernetes.paths';
|
||||
|
||||
export class KubeClient {
|
||||
public client: plugins.kubectl.ApiRoot;
|
||||
@ -8,10 +9,54 @@ export class KubeClient {
|
||||
public async init () {
|
||||
const { KubeConfig } = require('kubernetes-client')
|
||||
const kubeconfig = new KubeConfig()
|
||||
kubeconfig.loadFromFile('~/some/path');
|
||||
kubeconfig.loadFromFile(paths.defaultKubeConfigPath);
|
||||
const Request = require('kubernetes-client/backends/request');
|
||||
|
||||
const backend = new Request({ kubeconfig });
|
||||
this.client = new plugins.kubectl.Client1_13({ backend, version: '1.13' })
|
||||
this.client = new plugins.kubectl.Client1_13({ backend, version: '1.13' });
|
||||
}
|
||||
|
||||
public async setRegistry () {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* sets an ssl secret
|
||||
* @param domainNameArg
|
||||
* @param sslCertificateArg
|
||||
*/
|
||||
public async setSslSecret (domainNameArg: string, sslCertificateArg: plugins.tsclass.network.ICert) {
|
||||
this.client.api.v1.namespace('default').secret.post({
|
||||
body: {
|
||||
apiVersion: 'v1',
|
||||
kind: 'Secret',
|
||||
metadata: {
|
||||
name: `lossless-ssl-${domainNameArg}`
|
||||
},
|
||||
type: 'Opaque',
|
||||
data: {
|
||||
'tls.crt': plugins.smartstring.base64.encode(sslCertificateArg.publicKey),
|
||||
'tls.key': plugins.smartstring.base64.encode(sslCertificateArg.privateKey)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public async getSslSecret (domainNameArg: string) {
|
||||
this.client.api.v1.namespace('default').secrets(domainNameArg).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* removes an ssl secret
|
||||
* @param domainName
|
||||
*/
|
||||
public async removeSslSecret (domainName: string) {
|
||||
this.client.api.v1.namespace('default').secrets(domainName).delete();
|
||||
}
|
||||
|
||||
public async setService () {}
|
||||
|
||||
public async deleteService () {}
|
||||
|
||||
public async installIngress () {}
|
||||
}
|
||||
|
3
ts/kubernetes.paths.ts
Normal file
3
ts/kubernetes.paths.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as plugins from './kubernetes.plugins';
|
||||
|
||||
export const defaultKubeConfigPath = plugins.path.join(plugins.smartpath.get.home(), '.kube/config')
|
@ -1,3 +1,27 @@
|
||||
// node native scope
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
}
|
||||
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass
|
||||
}
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
|
||||
export {
|
||||
smartpath,
|
||||
smartstring
|
||||
}
|
||||
|
||||
// third party scope
|
||||
import * as kubeclient from 'kubernetes-client';
|
||||
|
||||
export {
|
||||
|
Reference in New Issue
Block a user