當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Kubectl.apply方法代碼示例

本文整理匯總了TypeScript中kubernetes-common/kubectl-object-model.Kubectl.apply方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Kubectl.apply方法的具體用法?TypeScript Kubectl.apply怎麽用?TypeScript Kubectl.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kubernetes-common/kubectl-object-model.Kubectl的用法示例。


在下文中一共展示了Kubectl.apply方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2: 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


注:本文中的kubernetes-common/kubectl-object-model.Kubectl.apply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。