mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
adf-cli k8s image - Be able to override image by label and namespace (#5786)
* Ability to set the image of pods based on label * Use the namespaces as filter
This commit is contained in:
@@ -47,7 +47,7 @@ In develop mode, the CLI takes the prebuilt scripts from the dist folder.
|
|||||||
|docker-publish |publish docker image|
|
|docker-publish |publish docker image|
|
||||||
|init-aae-env |Init env|
|
|init-aae-env |Init env|
|
||||||
|kubectl-delete |delete kubectl |
|
|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 |
|
|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-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|
|
|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,9 @@ export interface KubeArgs {
|
|||||||
token?: string;
|
token?: string;
|
||||||
clusterEnv?: string;
|
clusterEnv?: string;
|
||||||
clusterUrl?: string;
|
clusterUrl?: string;
|
||||||
serviceName?: string;
|
|
||||||
dockerRepo?: string;
|
dockerRepo?: string;
|
||||||
deployName?: string;
|
label?: string;
|
||||||
|
namespaces?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCluster(args: KubeArgs) {
|
function setCluster(args: KubeArgs) {
|
||||||
@@ -57,9 +57,16 @@ function useContext(args: KubeArgs) {
|
|||||||
logger.info(response);
|
logger.info(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImage(args: KubeArgs) {
|
function getDeploymentName(args: KubeArgs, namespace: string): string {
|
||||||
|
logger.info('Perform get deployment name...');
|
||||||
|
const result = exec('kubectl', [`get`, `deployments`, `--namespace=${namespace}`, `-l`, `app=${args.label}`, `-o`, `name`], {});
|
||||||
|
logger.info(`deployment name: ${result}`);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setImage(args: KubeArgs, deploymentName: string, serviceName: string, namespace: string) {
|
||||||
logger.info('Perform set image...');
|
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}`, `${deploymentName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {});
|
||||||
logger.info(response);
|
logger.info(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,16 +85,16 @@ function main(args) {
|
|||||||
|
|
||||||
program
|
program
|
||||||
.version('0.1.0')
|
.version('0.1.0')
|
||||||
.description('his command allows you to update a specific service on the rancher env with a specifig tag \n\n' +
|
.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} --deployName ${deployName} --dockerRepo ${dockerRepo} --tag ${tag}')
|
'adf-cli kubectl-image --clusterEnv ${clusterEnv} --clusterUrl ${clusterUrl} --username ${username} --token ${token} --label ${label} --namespaces ${namespaces} --dockerRepo ${dockerRepo} --tag ${tag}')
|
||||||
.option('--tag [type]', 'tag')
|
.option('--tag [type]', 'tag')
|
||||||
.option('--installCheck [type]', 'install kube ctl')
|
.option('--installCheck [type]', 'install kube ctl')
|
||||||
.option('--username [type]', 'username')
|
.option('--username [type]', 'username')
|
||||||
.option('--clusterEnv [type]', 'cluster Env')
|
.option('--clusterEnv [type]', 'cluster Env')
|
||||||
.option('--clusterUrl [type]', 'cluster Url')
|
.option('--clusterUrl [type]', 'cluster Url')
|
||||||
.option('--serviceName [type]', 'serviceName')
|
|
||||||
.option('--dockerRepo [type]', 'docker Repo')
|
.option('--dockerRepo [type]', 'docker Repo')
|
||||||
.option('--deployName [type]', 'deploy Name')
|
.option('--label [type]', 'pod label')
|
||||||
|
.option('--namespaces [type]', 'list of namespaces')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
if (process.argv.includes('-h') || process.argv.includes('--help')) {
|
if (process.argv.includes('-h') || process.argv.includes('--help')) {
|
||||||
@@ -104,6 +111,12 @@ function main(args) {
|
|||||||
setCredentials(args);
|
setCredentials(args);
|
||||||
setContext(args);
|
setContext(args);
|
||||||
useContext(args);
|
useContext(args);
|
||||||
setImage(args);
|
const namespaces: string [] = args.namespaces.split(',');
|
||||||
|
namespaces.forEach( (namespace) => {
|
||||||
|
logger.info(`Find deployment name based on label and namespace ${namespace}`);
|
||||||
|
const deploymentName = getDeploymentName(args, namespace);
|
||||||
|
logger.info(`Found ${deploymentName}`);
|
||||||
|
setImage(args, deploymentName.trim(), '*', namespace);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user