mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(k8s/application): add the ability to set the auto-scale policy of an application (#4118)
* feat(application): add horizontalpodautoscaler creation * feat(application): Add the ability to set the auto-scale policy of an application * feat(k8s/application): minor UI update * fix(application): set api version and prevent to use hpa with global deployment type * feat(settings): add a switch to enable features based on server metrics * feat(k8s/applications): minor UI update Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
909e1ef02c
commit
6756b04b67
16 changed files with 534 additions and 84 deletions
|
@ -12,10 +12,10 @@ class KubernetesHorizontalPodAutoScalerService {
|
|||
|
||||
this.getAsync = this.getAsync.bind(this);
|
||||
this.getAllAsync = this.getAllAsync.bind(this);
|
||||
// this.createAsync = this.createAsync.bind(this);
|
||||
// this.patchAsync = this.patchAsync.bind(this);
|
||||
this.createAsync = this.createAsync.bind(this);
|
||||
this.patchAsync = this.patchAsync.bind(this);
|
||||
// this.rollbackAsync = this.rollbackAsync.bind(this);
|
||||
// this.deleteAsync = this.deleteAsync.bind(this);
|
||||
this.deleteAsync = this.deleteAsync.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,65 +53,65 @@ class KubernetesHorizontalPodAutoScalerService {
|
|||
return this.$async(this.getAllAsync, namespace);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * CREATE
|
||||
// */
|
||||
// async createAsync(horizontalPodAutoScaler) {
|
||||
// try {
|
||||
// const params = {};
|
||||
// const payload = KubernetesHorizontalPodAutoScalerConverter.createPayload(horizontalPodAutoScaler);
|
||||
// const namespace = payload.metadata.namespace;
|
||||
// const data = await this.KubernetesHorizontalPodAutoScalers(namespace).create(params, payload).$promise;
|
||||
// return data;
|
||||
// } catch (err) {
|
||||
// throw new PortainerError('Unable to create horizontalPodAutoScaler', err);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* CREATE
|
||||
*/
|
||||
async createAsync(horizontalPodAutoScaler) {
|
||||
try {
|
||||
const params = {};
|
||||
const payload = KubernetesHorizontalPodAutoScalerConverter.createPayload(horizontalPodAutoScaler);
|
||||
const namespace = payload.metadata.namespace;
|
||||
const data = await this.KubernetesHorizontalPodAutoScalers(namespace).create(params, payload).$promise;
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to create horizontalPodAutoScaler', err);
|
||||
}
|
||||
}
|
||||
|
||||
// create(horizontalPodAutoScaler) {
|
||||
// return this.$async(this.createAsync, horizontalPodAutoScaler);
|
||||
// }
|
||||
create(horizontalPodAutoScaler) {
|
||||
return this.$async(this.createAsync, horizontalPodAutoScaler);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * PATCH
|
||||
// */
|
||||
// async patchAsync(oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler) {
|
||||
// try {
|
||||
// const params = new KubernetesCommonParams();
|
||||
// params.id = newHorizontalPodAutoScaler.Name;
|
||||
// const namespace = newHorizontalPodAutoScaler.Namespace;
|
||||
// const payload = KubernetesHorizontalPodAutoScalerConverter.patchPayload(oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler);
|
||||
// if (!payload.length) {
|
||||
// return;
|
||||
// }
|
||||
// const data = await this.KubernetesHorizontalPodAutoScalers(namespace).patch(params, payload).$promise;
|
||||
// return data;
|
||||
// } catch (err) {
|
||||
// throw new PortainerError('Unable to patch horizontalPodAutoScaler', err);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* PATCH
|
||||
*/
|
||||
async patchAsync(oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler) {
|
||||
try {
|
||||
const params = new KubernetesCommonParams();
|
||||
params.id = newHorizontalPodAutoScaler.Name;
|
||||
const namespace = newHorizontalPodAutoScaler.Namespace;
|
||||
const payload = KubernetesHorizontalPodAutoScalerConverter.patchPayload(oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler);
|
||||
if (!payload.length) {
|
||||
return;
|
||||
}
|
||||
const data = await this.KubernetesHorizontalPodAutoScalers(namespace).patch(params, payload).$promise;
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to patch horizontalPodAutoScaler', err);
|
||||
}
|
||||
}
|
||||
|
||||
// patch(oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler) {
|
||||
// return this.$async(this.patchAsync, oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler);
|
||||
// }
|
||||
patch(oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler) {
|
||||
return this.$async(this.patchAsync, oldHorizontalPodAutoScaler, newHorizontalPodAutoScaler);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * DELETE
|
||||
// */
|
||||
// async deleteAsync(horizontalPodAutoScaler) {
|
||||
// try {
|
||||
// const params = new KubernetesCommonParams();
|
||||
// params.id = horizontalPodAutoScaler.Name;
|
||||
// const namespace = horizontalPodAutoScaler.Namespace;
|
||||
// await this.KubernetesHorizontalPodAutoScalers(namespace).delete(params).$promise;
|
||||
// } catch (err) {
|
||||
// throw new PortainerError('Unable to remove horizontalPodAutoScaler', err);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* DELETE
|
||||
*/
|
||||
async deleteAsync(horizontalPodAutoScaler) {
|
||||
try {
|
||||
const params = new KubernetesCommonParams();
|
||||
params.id = horizontalPodAutoScaler.Name;
|
||||
const namespace = horizontalPodAutoScaler.Namespace;
|
||||
await this.KubernetesHorizontalPodAutoScalers(namespace).delete(params).$promise;
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to remove horizontalPodAutoScaler', err);
|
||||
}
|
||||
}
|
||||
|
||||
// delete(horizontalPodAutoScaler) {
|
||||
// return this.$async(this.deleteAsync, horizontalPodAutoScaler);
|
||||
// }
|
||||
delete(horizontalPodAutoScaler) {
|
||||
return this.$async(this.deleteAsync, horizontalPodAutoScaler);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * ROLLBACK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue