import { EnvironmentStatus } from '@/react/portainer/environments/types';
import { PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
import registriesModule from './registries';
import customTemplateModule from './custom-templates';
import { reactModule } from './react';
import './views/kubernetes.css';
angular.module('portainer.kubernetes', ['portainer.app', registriesModule, customTemplateModule, reactModule]).config([
'$stateRegistryProvider',
function ($stateRegistryProvider) {
'use strict';
const kubernetes = {
name: 'kubernetes',
url: '/kubernetes',
parent: 'endpoint',
abstract: true,
onEnter: /* @ngInject */ function onEnter($async, $state, endpoint, KubernetesHealthService, KubernetesNamespaceService, Notifications, StateManager) {
return $async(async () => {
const kubeTypes = [
PortainerEndpointTypes.KubernetesLocalEnvironment,
PortainerEndpointTypes.AgentOnKubernetesEnvironment,
PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment,
];
if (!kubeTypes.includes(endpoint.Type)) {
$state.go('portainer.home');
return;
}
try {
if (endpoint.Type === PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment) {
//edge
await KubernetesHealthService.ping(endpoint.Id);
endpoint.Status = EnvironmentStatus.Up;
} catch (e) {
endpoint.Status = EnvironmentStatus.Down;
await StateManager.updateEndpointState(endpoint);
if (endpoint.Type === PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment && endpoint.Status === EnvironmentStatus.Down) {
throw new Error('Unable to contact Edge agent, please ensure that the agent is properly running on the remote environment.');
await KubernetesNamespaceService.get();
let params = {};
if (endpoint.Type == PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment) {
params = { redirect: true, environmentId: endpoint.Id, environmentName: endpoint.Name, route: 'kubernetes.dashboard' };
} else {
Notifications.error('Failed loading environment', e);
$state.go('portainer.home', params, { reload: true, inherit: false });
});
},
};
const helmApplication = {
name: 'kubernetes.helm',
url: '/helm/:namespace/:name',
views: {
'content@': {
component: 'kubernetesHelmApplicationView',
const helmTemplates = {
name: 'kubernetes.templates.helm',
url: '/helm',
component: 'helmTemplatesView',
const services = {
name: 'kubernetes.services',
url: '/services',
component: 'kubernetesServicesView',
const ingresses = {
name: 'kubernetes.ingresses',
url: '/ingresses',
component: 'kubernetesIngressesView',
const ingressesCreate = {
name: 'kubernetes.ingresses.create',
url: '/add',
component: 'kubernetesIngressesCreateView',
const ingressesEdit = {
name: 'kubernetes.ingresses.edit',
url: '/:namespace/:name/edit',
const applications = {
name: 'kubernetes.applications',
url: '/applications',
component: 'kubernetesApplicationsView',
const applicationCreation = {
name: 'kubernetes.applications.new',
url: '/new',
component: 'kubernetesCreateApplicationView',
const application = {
name: 'kubernetes.applications.application',
url: '/:namespace/:name',
component: 'kubernetesApplicationView',
const applicationEdit = {
name: 'kubernetes.applications.application.edit',
url: '/edit',
const applicationConsole = {
name: 'kubernetes.applications.application.console',
url: '/:pod/:container/console',
component: 'kubernetesApplicationConsoleView',
const applicationLogs = {
name: 'kubernetes.applications.application.logs',
url: '/:pod/:container/logs',
component: 'kubernetesApplicationLogsView',
const applicationStats = {
name: 'kubernetes.applications.application.stats',
url: '/:pod/:container/stats',
component: 'kubernetesApplicationStatsView',
const stacks = {
name: 'kubernetes.stacks',
url: '/stacks',
const stack = {
name: 'kubernetes.stacks.stack',
const stackLogs = {
name: 'kubernetes.stacks.stack.logs',
url: '/logs',
component: 'kubernetesStackLogsView',
const configurations = {
name: 'kubernetes.configurations',
url: '/configurations',
component: 'kubernetesConfigurationsView',
const configurationCreation = {
name: 'kubernetes.configurations.new',
component: 'kubernetesCreateConfigurationView',
const configuration = {
name: 'kubernetes.configurations.configuration',
component: 'kubernetesConfigurationView',
const cluster = {
name: 'kubernetes.cluster',
url: '/cluster',
component: 'kubernetesClusterView',
const node = {
name: 'kubernetes.cluster.node',
url: '/:name',
component: 'kubernetesNodeView',
const nodeStats = {
name: 'kubernetes.cluster.node.stats',
url: '/stats',
component: 'kubernetesNodeStatsView',
const dashboard = {
name: 'kubernetes.dashboard',
url: '/dashboard',
component: 'kubernetesDashboardView',
const deploy = {
name: 'kubernetes.deploy',
url: '/deploy?templateId',
component: 'kubernetesDeployView',
params: {
templateId: '',
const resourcePools = {
name: 'kubernetes.resourcePools',
url: '/pools',
component: 'kubernetesResourcePoolsView',
const resourcePoolCreation = {
name: 'kubernetes.resourcePools.new',
component: 'kubernetesCreateResourcePoolView',
const resourcePool = {
name: 'kubernetes.resourcePools.resourcePool',
url: '/:id',
component: 'kubernetesResourcePoolView',
const resourcePoolAccess = {
name: 'kubernetes.resourcePools.resourcePool.access',
url: '/access',
component: 'kubernetesResourcePoolAccessView',
const volumes = {
name: 'kubernetes.volumes',
url: '/volumes',
component: 'kubernetesVolumesView',
const volume = {
name: 'kubernetes.volumes.volume',
component: 'kubernetesVolumeView',
const registries = {
name: 'kubernetes.registries',
url: '/registries',
component: 'endpointRegistriesView',
const registriesAccess = {
name: 'kubernetes.registries.access',
url: '/:id/access',
component: 'kubernetesRegistryAccessView',
const endpointKubernetesConfiguration = {
name: 'kubernetes.cluster.setup',
url: '/configure',
templateUrl: './views/configure/configure.html',
controller: 'KubernetesConfigureController',
controllerAs: 'ctrl',
const endpointKubernetesSecurityConstraint = {
name: 'kubernetes.cluster.securityConstraint',
url: '/securityConstraint',
templateUrl: '../kubernetes/views/security-constraint/constraint.html',
controller: 'KubernetesSecurityConstraintController',
$stateRegistryProvider.register(kubernetes);
$stateRegistryProvider.register(helmApplication);
$stateRegistryProvider.register(helmTemplates);
$stateRegistryProvider.register(applications);
$stateRegistryProvider.register(applicationCreation);
$stateRegistryProvider.register(application);
$stateRegistryProvider.register(applicationEdit);
$stateRegistryProvider.register(applicationConsole);
$stateRegistryProvider.register(applicationLogs);
$stateRegistryProvider.register(applicationStats);
$stateRegistryProvider.register(stacks);
$stateRegistryProvider.register(stack);
$stateRegistryProvider.register(stackLogs);
$stateRegistryProvider.register(configurations);
$stateRegistryProvider.register(configurationCreation);
$stateRegistryProvider.register(configuration);
$stateRegistryProvider.register(cluster);
$stateRegistryProvider.register(dashboard);
$stateRegistryProvider.register(deploy);
$stateRegistryProvider.register(node);
$stateRegistryProvider.register(nodeStats);
$stateRegistryProvider.register(resourcePools);
$stateRegistryProvider.register(resourcePoolCreation);
$stateRegistryProvider.register(resourcePool);
$stateRegistryProvider.register(resourcePoolAccess);
$stateRegistryProvider.register(volumes);
$stateRegistryProvider.register(volume);
$stateRegistryProvider.register(registries);
$stateRegistryProvider.register(registriesAccess);
$stateRegistryProvider.register(endpointKubernetesConfiguration);
$stateRegistryProvider.register(endpointKubernetesSecurityConstraint);
$stateRegistryProvider.register(services);
$stateRegistryProvider.register(ingresses);
$stateRegistryProvider.register(ingressesCreate);
$stateRegistryProvider.register(ingressesEdit);
]);