mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(k8s/application): expose tolerations and affinities (#4063)
* feat(k8s/application): expose placement conditions * feat(k8s/applications): minor UI update * feat(k8s/application): update message for admin and non admin users * feat(kubernetes/applications): minor UI update Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
63bf654d8d
commit
4431d748c2
22 changed files with 635 additions and 112 deletions
75
app/kubernetes/pod/service.js
Normal file
75
app/kubernetes/pod/service.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
import _ from 'lodash-es';
|
||||
import angular from 'angular';
|
||||
import PortainerError from 'Portainer/error';
|
||||
|
||||
import { KubernetesCommonParams } from 'Kubernetes/models/common/params';
|
||||
import KubernetesPodConverter from 'Kubernetes/pod/converter';
|
||||
|
||||
class KubernetesPodService {
|
||||
/* @ngInject */
|
||||
constructor($async, KubernetesPods) {
|
||||
this.$async = $async;
|
||||
this.KubernetesPods = KubernetesPods;
|
||||
|
||||
this.getAllAsync = this.getAllAsync.bind(this);
|
||||
this.logsAsync = this.logsAsync.bind(this);
|
||||
this.deleteAsync = this.deleteAsync.bind(this);
|
||||
}
|
||||
/**
|
||||
* GET ALL
|
||||
*/
|
||||
async getAllAsync(namespace) {
|
||||
try {
|
||||
const data = await this.KubernetesPods(namespace).get().$promise;
|
||||
return _.map(data.items, (item) => KubernetesPodConverter.apiToModel(item));
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to retrieve pods', err);
|
||||
}
|
||||
}
|
||||
|
||||
get(namespace) {
|
||||
return this.$async(this.getAllAsync, namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs
|
||||
*
|
||||
* @param {string} namespace
|
||||
* @param {string} podName
|
||||
*/
|
||||
async logsAsync(namespace, podName) {
|
||||
try {
|
||||
const params = new KubernetesCommonParams();
|
||||
params.id = podName;
|
||||
const data = await this.KubernetesPods(namespace).logs(params).$promise;
|
||||
return data.logs.length === 0 ? [] : data.logs.split('\n');
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to retrieve pod logs', err);
|
||||
}
|
||||
}
|
||||
|
||||
logs(namespace, podName) {
|
||||
return this.$async(this.logsAsync, namespace, podName);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE
|
||||
*/
|
||||
async deleteAsync(pod) {
|
||||
try {
|
||||
const params = new KubernetesCommonParams();
|
||||
params.id = pod.Name;
|
||||
const namespace = pod.Namespace;
|
||||
await this.KubernetesPods(namespace).delete(params).$promise;
|
||||
} catch (err) {
|
||||
throw new PortainerError('Unable to remove pod', err);
|
||||
}
|
||||
}
|
||||
|
||||
delete(pod) {
|
||||
return this.$async(this.deleteAsync, pod);
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesPodService;
|
||||
angular.module('portainer.kubernetes').service('KubernetesPodService', KubernetesPodService);
|
Loading…
Add table
Add a link
Reference in a new issue