Skip to content

# Class: ClusterFeature

## Hierarchy

- ClusterFeature

## Index

### Properties

- templateContext

### Methods

- applyResources
- install
- renderTemplates
- uninstall
- updateStatus
- upgrade

### Object literals

- status

## Properties

### templateContext

• templateContext: any

Defined in src/extensions/cluster-feature.ts:29

this field sets the template parameters that are to be applied to any templated kubernetes resources that are to be installed for the feature. See the renderTemplates() method for more details

## Methods

### `Protected` applyResources

▸ applyResources(`cluster`: Cluster, `resourceSpec`: string | string[]): Promise‹void›

Defined in src/extensions/cluster-feature.ts:85

this is a helper method that conveniently applies kubernetes resources to the cluster.

Parameters:

Name | Type | Description
--- | --- | ---
`cluster` | Cluster | the cluster that the resources are to be applied to
`resourceSpec` | string | string[] | as a string type this is a folder path that is searched for files specifying kubernetes resources. The files are read and if any of the resource files are templated, the template parameters are filled using the templateContext field (See renderTemplate() method). Finally the resources are applied to the cluster. As a string[] type resourceSpec is treated as an array of fully formed (not templated) kubernetes resources that are applied to the cluster

Returns: Promise‹void›

### `Abstract` install

▸ install(`cluster`: Cluster): Promise‹void›

Defined in src/extensions/cluster-feature.ts:47

to be implemented in the derived class, this method is typically called by Lens when a user has indicated that this feature is to be installed. The implementation of this method should install kubernetes resources using the applyResources() method, or by directly accessing the kubernetes api (K8sApi)

Parameters:

Name | Type | Description
--- | --- | ---
`cluster` | Cluster | the cluster that the feature is to be installed on

Returns: Promise‹void›

### `Protected` renderTemplates

▸ renderTemplates(`folderPath`: string): string[]

Defined in src/extensions/cluster-feature.ts:109

this is a helper method that conveniently reads kubernetes resource files into a string array. It also fills templated resource files with the template parameter values specified by the templateContext field. Templated files must end with the extension '.hb' and the template syntax must be compatible with handlebars.js

Parameters:

Name | Type | Description
--- | --- | ---
`folderPath` | string | this is a folder path that is searched for files defining kubernetes resources.

Returns: string[]

an array of strings, each string being the contents of a resource file found in the folder path. This can be passed directly to applyResources()

### `Abstract` uninstall

▸ uninstall(`cluster`: Cluster): Promise‹void›

Defined in src/extensions/cluster-feature.ts:63

to be implemented in the derived class, this method is typically called by Lens when a user has indicated that this feature is to be uninstalled. The implementation of this method should uninstall kubernetes resources using the kubernetes api (K8sApi)

Parameters:

Name | Type | Description
--- | --- | ---
`cluster` | Cluster | the cluster that the feature is to be uninstalled from

Returns: Promise‹void›

### `Abstract` updateStatus

▸ updateStatus(`cluster`: Cluster): Promise‹ClusterFeatureStatus›

Defined in src/extensions/cluster-feature.ts:75

to be implemented in the derived class, this method is called periodically by Lens to determine details about the feature's current status. The implementation of this method should provide the current status information. The currentVersion and latestVersion fields may be displayed by Lens in describing the feature. The installed field should be set to true if the feature has been installed, otherwise false. Also, Lens relies on the canUpgrade field to determine if the feature can be upgraded so the implementation should set the canUpgrade field according to specific rules for the feature, if relevant.

Parameters:

Name | Type | Description
--- | --- | ---
`cluster` | Cluster | the cluster that the feature may be installed on

Returns: Promise‹ClusterFeatureStatus›

a promise, resolved with the updated ClusterFeatureStatus

### `Abstract` upgrade

▸ upgrade(`cluster`: Cluster): Promise‹void›

Defined in src/extensions/cluster-feature.ts:55

to be implemented in the derived class, this method is typically called by Lens when a user has indicated that this feature is to be upgraded. The implementation of this method should upgrade the kubernetes resources already installed, if relevant to the feature

Parameters:

Name | Type | Description
--- | --- | ---
`cluster` | Cluster | the cluster that the feature is to be upgraded on

Returns: Promise‹void›

## Object literals

### status

### ▪ status: object

Defined in src/extensions/cluster-feature.ts:34

this field holds the current feature status, is accessed directly by Lens

### canUpgrade

• canUpgrade: false = false

Defined in src/extensions/cluster-feature.ts:38

### currentVersion

• currentVersion: null = null

Defined in src/extensions/cluster-feature.ts:35

### installed

• installed: false = false

Defined in src/extensions/cluster-feature.ts:36

### latestVersion

• latestVersion: null = null

Defined in src/extensions/cluster-feature.ts:37