mirror of https://github.com/certd/certd
chore: k8s logger
parent
93559174c7
commit
efacfd6b2c
|
@ -1,7 +1,7 @@
|
|||
import kubernetesClient from 'kubernetes-client';
|
||||
//@ts-ignore
|
||||
import dns from 'dns';
|
||||
import { logger } from '@certd/pipeline';
|
||||
import { ILogger } from '@certd/pipeline';
|
||||
|
||||
//@ts-ignore
|
||||
const { KubeConfig, Client, Request } = kubernetesClient;
|
||||
|
@ -10,8 +10,10 @@ export class K8sClient {
|
|||
kubeConfigStr: string;
|
||||
lookup!: any;
|
||||
client!: any;
|
||||
constructor(kubeConfigStr: string) {
|
||||
logger: ILogger;
|
||||
constructor(kubeConfigStr: string, logger: ILogger) {
|
||||
this.kubeConfigStr = kubeConfigStr;
|
||||
this.logger = logger;
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
@ -33,9 +35,9 @@ export class K8sClient {
|
|||
*/
|
||||
setLookup(localRecords: { [key: string]: { ip: string } }) {
|
||||
this.lookup = (hostnameReq: any, options: any, callback: any) => {
|
||||
logger.info('custom lookup', hostnameReq, localRecords);
|
||||
this.logger.info('custom lookup', hostnameReq, localRecords);
|
||||
if (localRecords[hostnameReq]) {
|
||||
logger.info('local record', hostnameReq, localRecords[hostnameReq]);
|
||||
this.logger.info('local record', hostnameReq, localRecords[hostnameReq]);
|
||||
callback(null, localRecords[hostnameReq].ip, 4);
|
||||
} else {
|
||||
dns.lookup(hostnameReq, options, callback);
|
||||
|
@ -64,7 +66,7 @@ export class K8sClient {
|
|||
const created = await this.client.api.v1.namespaces(namespace).secrets.post({
|
||||
body: opts.body,
|
||||
});
|
||||
logger.info('new secrets:', created);
|
||||
this.logger.info('new secrets:', created);
|
||||
return created;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ export class DeployCertToAliyunAckIngressPlugin extends AbstractTaskPlugin {
|
|||
const kubeConfigStr = await this.getKubeConfig(client, clusterId, isPrivateIpAddress);
|
||||
|
||||
this.logger.info('kubeconfig已成功获取');
|
||||
const k8sClient = new K8sClient(kubeConfigStr);
|
||||
const k8sClient = new K8sClient(kubeConfigStr,this.logger);
|
||||
const ingressType = ingressClass || 'qcloud';
|
||||
if (ingressType === 'qcloud') {
|
||||
throw new Error('暂未实现');
|
||||
|
|
|
@ -91,7 +91,7 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
|
|||
this.logger.info('授权id:', accessId);
|
||||
//TODO 这里实现你要部署的执行方法
|
||||
|
||||
new K8sClient('111');
|
||||
new K8sClient('111', logger);
|
||||
}
|
||||
}
|
||||
//TODO 这里实例化插件,进行注册
|
||||
|
|
|
@ -101,7 +101,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
|
|||
const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId);
|
||||
|
||||
this.logger.info('kubeconfig已成功获取');
|
||||
const k8sClient = new K8sClient(kubeConfigStr);
|
||||
const k8sClient = new K8sClient(kubeConfigStr, this.logger);
|
||||
if (this.clusterIp != null) {
|
||||
if (!this.clusterDomain) {
|
||||
this.clusterDomain = `${this.clusterId}.ccs.tencent-cloud.com`;
|
||||
|
|
Loading…
Reference in New Issue