• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript kubectl-object-model.Kubectl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中kubernetes-common/kubectl-object-model.Kubectl的典型用法代码示例。如果您正苦于以下问题:TypeScript Kubectl类的具体用法?TypeScript Kubectl怎么用?TypeScript Kubectl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Kubectl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: deleteResources

export async function deleteResources() {
    let args = TaskInputParameters.args;

    if (args == null || args.length == 0) {
        throw (tl.loc("ArgumentsInputNotSupplied"));
    }

    let kubectl = new Kubectl(await utils.getKubectl(), TaskInputParameters.namespace);
    var result = kubectl.delete(args);
    utils.checkForErrors([result]);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:11,代码来源:delete.ts


示例2: scale

export async function scale() {
    let kubectl = new Kubectl(await utils.getKubectl(), tl.getInput("namespace", false));
    let kind = tl.getInput("kind", true).toLowerCase();
    let replicas = tl.getInput("replicas", true);
    let name = tl.getInput("name", true);
    let result = kubectl.scale(kind, name, replicas);
    utils.checkForErrors([result]);
    utils.checkForErrors([kubectl.checkRolloutStatus(kind, name)]);
    utils.checkForErrors([kubectl.annotate(kind, name, constants.pipelineAnnotations, true)]);
    utils.checkForErrors(utils.annotateChildPods(kubectl, kind, name, JSON.parse((kubectl.getAllPods()).stdout)));
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:11,代码来源:scale.ts


示例3: annotateResources

function annotateResources(files: string[], kubectl: Kubectl, resourceTypes: Resource[]) {
    let annotateResults: IExecSyncResult[] = [];
    var allPods = JSON.parse((kubectl.getAllPods()).stdout);
    annotateResults.push(kubectl.annotateFiles(files, constants.pipelineAnnotations, true));
    resourceTypes.forEach(resource => {
        if (resource.type.toUpperCase() != models.KubernetesWorkload.Pod.toUpperCase()) {
            utils.annotateChildPods(kubectl, resource.type, resource.name, allPods)
                .forEach(execResult => annotateResults.push(execResult));
        }
    });
    utils.checkForErrors(annotateResults, true);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:12,代码来源:DeploymentHelper.ts


示例4: createSecret

export async function createSecret() {
    let args = "";
    if (utils.isEqual(TaskInputParameters.secretType, "dockerRegistry", utils.StringComparer.OrdinalIgnoreCase)) {
        args = getDockerRegistrySecretArgs();
    }
    else {
        args = getGenericSecretArgs();
    }

    let kubectl = new Kubectl(await utils.getKubectl(), TaskInputParameters.namespace);
    var result = kubectl.createSecret(args, true, TaskInputParameters.secretName.trim());
    utils.checkForErrors([result]);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:13,代码来源:createSecret.ts


示例5: deployManifests

function deployManifests(files: string[], kubectl: Kubectl, isCanaryDeploymentStrategy: boolean): string[] {
    let result;
    if (isCanaryDeploymentStrategy) {
        var canaryDeploymentOutput = canaryDeploymentHelper.deployCanary(kubectl, files);
        result = canaryDeploymentOutput.result;
        files = canaryDeploymentOutput.newFilePaths;
    } else {
        result = kubectl.apply(files);
    }
    utils.checkForErrors([result]);
    return files;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:12,代码来源:DeploymentHelper.ts


示例6: patch

export async function patch() {
    let kubectl = new Kubectl(await utils.getKubectl(), tl.getInput("namespace", false));
    let kind = tl.getInput("kind", false).toLowerCase();
    let name = tl.getInput("name", false);
    let filePath = tl.getInput("resourceFileToPatch", false);
    let strategy = tl.getInput("mergeStrategy", false);
    let patch = tl.getInput("patch", true);
    if (tl.filePathSupplied("resourceFileToPatch") && tl.getInput("resourceToPatch") == "file") {
        kind = "-f";
        name = filePath;
    }

    let result = kubectl.patch(kind, name, patch, strategy);
    utils.checkForErrors([result]);
    let resources = kubectl.getResources(result.stdout, ["deployment", "replicaset", "daemonset", "pod", "statefulset"]);

    resources.forEach(resource => {
        utils.checkForErrors([kubectl.checkRolloutStatus(resource.type, resource.name)]);
        utils.checkForErrors([kubectl.annotate(resource.type, resource.name, constants.pipelineAnnotations, true)]);
        utils.checkForErrors(utils.annotateChildPods(kubectl, resource.type, resource.name, JSON.parse((kubectl.getAllPods()).stdout)));
    });
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:22,代码来源:patch.ts


示例7: deployCanary

export function deployCanary(kubectl: Kubectl, filePaths: string[]) {
    var newObjectsList = [];
    var percentage = parseInt(TaskInputParameters.canaryPercentage);

    filePaths.forEach((filePath: string) => {
        var fileContents = fs.readFileSync(filePath);
        yaml.safeLoadAll(fileContents, function (inputObject) {

            var name = inputObject.metadata.name;
            var kind = inputObject.kind;
            if (helper.isDeploymentEntity(kind)) {
                var existing_canary_object = fetchCanaryResource(kubectl, kind, name);

                if (!!existing_canary_object) {
                    throw (tl.loc("CanaryDeploymentAlreadyExistErrorMessage"));
                }

                tl.debug("Calculating replica count for canary");
                var canaryReplicaCount = calculateReplicaCountForCanary(inputObject, percentage);
                tl.debug("Replica count is " + canaryReplicaCount);
                // Get stable object
                tl.debug("Querying stable object");
                var stable_object = fetchResource(kubectl, kind, name);
                if (!stable_object) {
                    tl.debug("Stable object not found. Creating only canary object");
                    // If stable object not found, create canary deployment.
                    var newCanaryObject = getNewCanaryResource(inputObject, canaryReplicaCount);
                    tl.debug("New canary object is: " + JSON.stringify(newCanaryObject));
                    newObjectsList.push(newCanaryObject);
                } else {
                    tl.debug("Stable object found. Creating canary and baseline objects");
                    // If canary object not found, create canary and baseline object.
                    var newCanaryObject = getNewCanaryResource(inputObject, canaryReplicaCount);
                    var newBaselineObject = getNewBaselineResource(stable_object, canaryReplicaCount);
                    tl.debug("New canary object is: " + JSON.stringify(newCanaryObject));
                    tl.debug("New baseline object is: " + JSON.stringify(newBaselineObject));
                    newObjectsList.push(newCanaryObject);
                    newObjectsList.push(newBaselineObject);
                }
            } else {
                // Updating non deployment entity as it is.
                newObjectsList.push(inputObject);
            }
        });
    });

    var manifestFiles = fileHelper.writeObjectsToFile(newObjectsList);
    var result = kubectl.apply(manifestFiles);
    return { "result": result, "newFilePaths": manifestFiles };
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:50,代码来源:CanaryDeploymentHelper.ts


示例8: fetchResource

function fetchResource(kubectl: Kubectl, kind: string, name: string): object {
    var result = kubectl.getResource(kind, name);

    if (result == null || !!result.stderr) {
        return null;
    }

    if (!!result.stdout) {
        try {
            var resource = JSON.parse(result.stdout);
            UnsetsClusterSpecficDetails(resource);
            return resource;
        } catch (ex) {
            tl.debug("Exception occurred while Parsing " + resource + " in Json object");
            return null;
        }
    }
    return null;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:19,代码来源:CanaryDeploymentHelper.ts


示例9: annotateChildPods

export function annotateChildPods(kubectl: Kubectl, resourceType: string, resourceName: string, allPods): IExecSyncResult[] {
    let commandExecutionResults = [];
    var owner = resourceName;
    if (resourceType.toLowerCase().indexOf("deployment") > -1) {
        owner = kubectl.getNewReplicaSet(resourceName);
    }

    if (!!allPods && !!allPods["items"] && allPods["items"].length > 0) {
        allPods["items"].forEach((pod) => {
            let owners = pod["metadata"]["ownerReferences"];
            if (!!owners) {
                owners.forEach(ownerRef => {
                    if (ownerRef["name"] == owner) {
                        commandExecutionResults.push(kubectl.annotate("pod", pod["metadata"]["name"], pipelineAnnotations, true));
                    }
                });
            }
        });
    }

    return commandExecutionResults;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:22,代码来源:utilities.ts


示例10: deleteCanaryDeployment

export function deleteCanaryDeployment(kubectl: Kubectl, manifestFilesPath: string) {

    // get manifest files
    var inputManifestFiles: string[] = utils.getManifestFiles(manifestFilesPath);

    if (inputManifestFiles == null || inputManifestFiles.length == 0) {
        throw (tl.loc("ManifestFileNotFound"));
    }

    // create delete cmd prefix
    let argsPrefix: string;
    argsPrefix = createCanaryObjectsArgumentString(inputManifestFiles);

    // append delete cmd args as suffix (if present)
    let args = utils.getDeleteCmdArgs(argsPrefix, TaskInputParameters.args);
    tl.debug("Delete cmd args : " + args);

    if (!!args && args.length > 0) {
        // run kubectl delete cmd
        var result = kubectl.delete(args);
        utils.checkForErrors([result]);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:23,代码来源:CanaryDeploymentHelper.ts



注:本文中的kubernetes-common/kubectl-object-model.Kubectl类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript kwyjibo.DocAction函数代码示例发布时间:2022-05-25
下一篇:
TypeScript koa-static.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap