mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
Ability to set the image of pods based on label (#5781)
This commit is contained in:
parent
3651cc0235
commit
5dc3e4c46b
@ -47,7 +47,7 @@ In develop mode, the CLI takes the prebuilt scripts from the dist folder.
|
||||
|docker-publish |publish docker image|
|
||||
|init-aae-env |Init env|
|
||||
|kubectl-delete |delete kubectl |
|
||||
|kubectl-image |This command allows you to update a specific service on the rancher env with a specifig tag |
|
||||
|kubectl-image |This command allows you to update a specific service on the rancher env with a specific tag |
|
||||
|npm-publish | publish on npm |
|
||||
| update-commit-sha | his command allows you to update the commit sha as part of the `package.json`. Your `package.json` must to have an existing property called "commit" |
|
||||
|update-version |This command allows you to update the adf dependencies and js-api with different versions Update adf libs and js-api with latest alpha|
|
||||
|
@ -28,9 +28,8 @@ export interface KubeArgs {
|
||||
token?: string;
|
||||
clusterEnv?: string;
|
||||
clusterUrl?: string;
|
||||
serviceName?: string;
|
||||
dockerRepo?: string;
|
||||
deployName?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
function setCluster(args: KubeArgs) {
|
||||
@ -57,9 +56,30 @@ function useContext(args: KubeArgs) {
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
function setImage(args: KubeArgs) {
|
||||
function getContainersName(args: KubeArgs): string[] {
|
||||
logger.info('Perform get containers name...');
|
||||
const result = exec('kubectl', [`get`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`, `-o`, `jsonpath={.items[*].spec.containers[*].name}`], {});
|
||||
logger.info(`container ${result}`);
|
||||
return result ? result.split(' ') : [];
|
||||
}
|
||||
|
||||
function getUiName(args: KubeArgs): string[] {
|
||||
logger.info('Perform get ui name...');
|
||||
const result = exec('kubectl', [`get`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`, `-o`, `jsonpath={.items[*]..uiName}`], {});
|
||||
logger.info(`ui ${result}`);
|
||||
return result ? result.split(' ') : [];
|
||||
}
|
||||
|
||||
function getNamespace(args: KubeArgs): string[] {
|
||||
logger.info('Perform get ui namespace...');
|
||||
const result = exec('kubectl', [`get`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`, `-o`, `jsonpath={.items[*]..namespace}`], {});
|
||||
logger.info(`namespace ${result}`);
|
||||
return result ? result.split(' ') : [];
|
||||
}
|
||||
|
||||
function setImage(args: KubeArgs, uiName: string, serviceName: string, namespace: string) {
|
||||
logger.info('Perform set image...');
|
||||
const response = exec('kubectl', [`set`, `image`, `deployment/${args.deployName}`, `${args.serviceName}=${args.dockerRepo}:${args.tag}`], {});
|
||||
const response = exec('kubectl', [`set`, `image`, `--namespace=${namespace}`, `deployment/${uiName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {});
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
@ -78,16 +98,15 @@ function main(args) {
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.description('his command allows you to update a specific service on the rancher env with a specifig tag \n\n' +
|
||||
'adf-cli kubectl-image --clusterEnv ${clusterEnv} --clusterUrl ${clusterUrl} --username ${username} --token ${token} --deployName ${deployName} --dockerRepo ${dockerRepo} --tag ${tag}')
|
||||
.description('his command allows you to update a specific service on the rancher env with a specific tag \n\n' +
|
||||
'adf-cli kubectl-image --clusterEnv ${clusterEnv} --clusterUrl ${clusterUrl} --username ${username} --token ${token} --label ${label} --dockerRepo ${dockerRepo} --tag ${tag}')
|
||||
.option('--tag [type]', 'tag')
|
||||
.option('--installCheck [type]', 'install kube ctl')
|
||||
.option('--username [type]', 'username')
|
||||
.option('--clusterEnv [type]', 'cluster Env')
|
||||
.option('--clusterUrl [type]', 'cluster Url')
|
||||
.option('--serviceName [type]', 'serviceName')
|
||||
.option('--dockerRepo [type]', 'docker Repo')
|
||||
.option('--deployName [type]', 'deploy Name')
|
||||
.option('--label [type]', 'pod label')
|
||||
.parse(process.argv);
|
||||
|
||||
if (process.argv.includes('-h') || process.argv.includes('--help')) {
|
||||
@ -104,6 +123,17 @@ function main(args) {
|
||||
setCredentials(args);
|
||||
setContext(args);
|
||||
useContext(args);
|
||||
setImage(args);
|
||||
const containers: string [] = getContainersName(args);
|
||||
logger.info(`container ${containers[0]}, ${containers.length}`);
|
||||
|
||||
const uiNames = getUiName(args);
|
||||
const namespaces = getNamespace(args);
|
||||
for (let i = 0; i < containers.length; i++) {
|
||||
const container = containers[i];
|
||||
const uiName = uiNames[i];
|
||||
const namespace = namespaces[i];
|
||||
logger.info(`Set image for ${container} with name ${uiName} of namespace: ${namespace}`);
|
||||
setImage(args, uiName, container, namespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user