clusters

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application added in v0.2.0

type Application struct {
	Cluster   string
	Namespace string
	Name      string
}

type Cache added in v0.3.0

type Cache struct {
	// contains filtered or unexported fields
}

type Clusters

type Clusters struct {
	clustersProto.UnimplementedClustersServer
	// contains filtered or unexported fields
}

Clusters contains all fields and methods to interact with the configured Kubernetes clusters. It must implement the Clusters service from the protocol buffers definition.

func Load

func Load(config Config) (*Clusters, error)

Load loads all clusters for the given configuration. The clusters can be retrieved from different providers. Currently we are supporting incluster configuration and kubeconfig files. In the future it is planning to directly support GKE, EKS, AKS, etc.

func (*Clusters) GetApplication

func (c *Clusters) GetApplication(ctx context.Context, getApplicationRequest *clustersProto.GetApplicationRequest) (*clustersProto.GetApplicationResponse, error)

GetApplication returns a single application with the given name in the given cluster and namespace. If there isn't, such an application an error is returned.

func (*Clusters) GetApplications

func (c *Clusters) GetApplications(ctx context.Context, getApplicationsRequest *clustersProto.GetApplicationsRequest) (*clustersProto.GetApplicationsResponse, error)

GetApplications returns a list of applications for the given clusters and namespaces. To generate this list, we loop over every cluster and namespace and try to get the applications for this.

func (*Clusters) GetApplicationsTopology added in v0.2.0

func (c *Clusters) GetApplicationsTopology(ctx context.Context, getApplicationsTopologyRequest *clustersProto.GetApplicationsTopologyRequest) (*clustersProto.GetApplicationsTopologyResponse, error)

GetApplicationsTopology returns the topology for the given list of clusters and namespaces. We add an additional node for each cluster and namespace. These nodes are used to group the applications by the cluster and namespace.

func (*Clusters) GetCRDs

GetCRDs returns all CRDs for all clusters. Instead of only returning the CRDs for a list of specified clusters, we return all CRDs, so that we only have to call this function once from the React app. The CRDs form all loaded clusters are merged and then deduplicated.

func (*Clusters) GetClusters

func (c *Clusters) GetClusters(ctx context.Context, getClustersRequest *clustersProto.GetClustersRequest) (*clustersProto.GetClustersResponse, error)

GetClusters returns all loaded Kubernetes clusters. We are not returning the complete cluster structure. Instead we are returning just the names of the clusters. We are also sorting the clusters alphabetically, to improve the user experience in the frontend. NOTE: Maybe we can also save the cluster names slice, since the name of a cluster couldn't change during runtime.

func (*Clusters) GetLogs added in v0.2.0

GetLogs returns the log line for the given pod, which is identified by the cluster, namespace and name.

func (*Clusters) GetNamespaces

func (c *Clusters) GetNamespaces(ctx context.Context, getNamespacesRequest *clustersProto.GetNamespacesRequest) (*clustersProto.GetNamespacesResponse, error)

GetNamespaces returns all namespaces for the given clusters. As we did it for the clusters, we are also just returning the names of all namespaces. After we retrieved all namespaces we have to depulicate them, so that our frontend logic can handle them properly. We are also sorting the namespaces alphabetically.

func (*Clusters) GetResources

func (c *Clusters) GetResources(ctx context.Context, getResourcesRequest *clustersProto.GetResourcesRequest) (*clustersProto.GetResourcesResponse, error)

GetResources returns a list of resources for the given clusters and namespaces. To generate this list, we loop over every cluster and namespace and try to get the resources for this. A resource is identified by it's Kubernetes API path and name.

func (*Clusters) GetTeam added in v0.2.0

GetTeam returns a single team. Each team is identified by his name. This also means that each team name must be unique across clusters and namespaces.We use the generated list of teams to identify where we find the Team CR for the given team name. Then we return the CR. We also use the list of teams, to get all applications, which can be associated with the team and return them within the team. Since we are using the generated list of teams, it is possible that a team can not be found directly after it is created. The reason for this is that we cache the teams for the specified cache duration via the --clusters.cache-duration.teams flag (default 60m). We do this because it can become expensive to generate the list of teams, when the number of teams and applications grows.

func (*Clusters) GetTeams added in v0.2.0

GetTeams returns all teams. Since this is only used to render the page which shows all teams, we just return the name, description and logo of each team.

func (*Clusters) GetTemplates added in v0.3.0

func (c *Clusters) GetTemplates(ctx context.Context, getTemplatesRequest *clustersProto.GetTemplatesRequest) (*clustersProto.GetTemplatesResponse, error)

GetTemplates returns a list of templates. The name of a template must be unique accross all clusters and namespace, because we only use the name in the CRs and resources to identify a template. If the last fetch was before the request time + the cache duration we return the cached templates. If this isn't the case and the lenght of the templates slice is 0 we fetch the templates and return them to the user. If the length of the slice is larger then 0, we return the cached templates, but trigger a refectch in the background.

type Config

type Config struct {
	Providers []provider.Config `yaml:"providers"`
}

Config is the configuration required to load all clusters.

type Team added in v0.2.0

type Team struct {
	Cluster      string
	Namespace    string
	Name         string
	Description  string
	Applications []Application
}

type Topology added in v0.3.0

type Topology struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL