本文整理匯總了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;
}
示例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 };
}