@backstage/plugin-kubernetes-node 0.1.2-next.2 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @backstage/plugin-kubernetes-node
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 6010564: The `kubernetes-node` plugin has been modified to house a new extension points for Kubernetes backend plugin;
8
+ `KubernetesClusterSupplierExtensionPoint` is introduced .
9
+ `kubernetesAuthStrategyExtensionPoint` is introduced .
10
+ `kubernetesFetcherExtensionPoint` is introduced .
11
+ `kubernetesServiceLocatorExtensionPoint` is introduced .
12
+
13
+ The `kubernetes-backend` plugin was modified to use this new extension point.
14
+
15
+ - Updated dependencies
16
+ - @backstage/plugin-kubernetes-common@0.7.2
17
+ - @backstage/backend-plugin-api@0.6.8
18
+ - @backstage/catalog-model@1.4.3
19
+ - @backstage/types@1.1.1
20
+
21
+ ## 0.1.2-next.3
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+ - @backstage/backend-plugin-api@0.6.8-next.3
27
+ - @backstage/catalog-model@1.4.3
28
+ - @backstage/plugin-kubernetes-common@0.7.2-next.1
29
+
3
30
  ## 0.1.2-next.2
4
31
 
5
32
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -7,6 +7,22 @@ var backendPluginApi = require('@backstage/backend-plugin-api');
7
7
  const kubernetesObjectsProviderExtensionPoint = backendPluginApi.createExtensionPoint({
8
8
  id: "kubernetes.objects-provider"
9
9
  });
10
+ const kubernetesClusterSupplierExtensionPoint = backendPluginApi.createExtensionPoint({
11
+ id: "kubernetes.cluster-supplier"
12
+ });
13
+ const kubernetesAuthStrategyExtensionPoint = backendPluginApi.createExtensionPoint({
14
+ id: "kubernetes.auth-strategy"
15
+ });
16
+ const kubernetesFetcherExtensionPoint = backendPluginApi.createExtensionPoint({
17
+ id: "kubernetes.fetcher"
18
+ });
19
+ const kubernetesServiceLocatorExtensionPoint = backendPluginApi.createExtensionPoint({
20
+ id: "kubernetes.service-locator"
21
+ });
10
22
 
23
+ exports.kubernetesAuthStrategyExtensionPoint = kubernetesAuthStrategyExtensionPoint;
24
+ exports.kubernetesClusterSupplierExtensionPoint = kubernetesClusterSupplierExtensionPoint;
25
+ exports.kubernetesFetcherExtensionPoint = kubernetesFetcherExtensionPoint;
11
26
  exports.kubernetesObjectsProviderExtensionPoint = kubernetesObjectsProviderExtensionPoint;
27
+ exports.kubernetesServiceLocatorExtensionPoint = kubernetesServiceLocatorExtensionPoint;
12
28
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { KubernetesObjectsProvider } from '@backstage/plugin-kubernetes-node';\n\n/**\n * The interface for {@link kubernetesObjectsProviderExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesObjectsProviderExtensionPoint {\n addObjectsProvider(provider: KubernetesObjectsProvider): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a objects provider.\n *\n * @public\n */\nexport const kubernetesObjectsProviderExtensionPoint =\n createExtensionPoint<KubernetesObjectsProviderExtensionPoint>({\n id: 'kubernetes.objects-provider',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;;;AAgCO,MAAM,0CACXA,qCAA8D,CAAA;AAAA,EAC5D,EAAI,EAAA,6BAAA;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n AuthenticationStrategy,\n KubernetesClustersSupplier,\n KubernetesFetcher,\n KubernetesObjectsProvider,\n KubernetesServiceLocator,\n} from '@backstage/plugin-kubernetes-node';\n\n/**\n * The interface for {@link kubernetesObjectsProviderExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesObjectsProviderExtensionPoint {\n addObjectsProvider(provider: KubernetesObjectsProvider): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a objects provider.\n *\n * @public\n */\nexport const kubernetesObjectsProviderExtensionPoint =\n createExtensionPoint<KubernetesObjectsProviderExtensionPoint>({\n id: 'kubernetes.objects-provider',\n });\n\n/**\n * The interface for {@link kubernetesClusterSupplierExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesClusterSupplierExtensionPoint {\n addClusterSupplier(clusterSupplier: KubernetesClustersSupplier): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a cluster supplier.\n *\n * @public\n */\nexport const kubernetesClusterSupplierExtensionPoint =\n createExtensionPoint<KubernetesClusterSupplierExtensionPoint>({\n id: 'kubernetes.cluster-supplier',\n });\n\n/**\n * The interface for {@link kubernetesAuthStrategyExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesAuthStrategyExtensionPoint {\n addAuthStrategy(key: string, strategy: AuthenticationStrategy): void;\n}\n\n/**\n * An extension point the exposes the ability to add an Auth Strategy.\n *\n * @public\n */\nexport const kubernetesAuthStrategyExtensionPoint =\n createExtensionPoint<KubernetesAuthStrategyExtensionPoint>({\n id: 'kubernetes.auth-strategy',\n });\n\n/**\n * The interface for {@link kubernetesFetcherExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesFetcherExtensionPoint {\n addFetcher(fetcher: KubernetesFetcher): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a kubernetes fetcher.\n *\n * @public\n */\nexport const kubernetesFetcherExtensionPoint =\n createExtensionPoint<KubernetesFetcherExtensionPoint>({\n id: 'kubernetes.fetcher',\n });\n\n/**\n * The interface for {@link kubernetesServiceLocatorExtensionPoint}.\n *\n * @public\n */\nexport interface KubernetesServiceLocatorExtensionPoint {\n addServiceLocator(serviceLocator: KubernetesServiceLocator): void;\n}\n\n/**\n * An extension point the exposes the ability to configure a kubernetes service locator.\n *\n * @public\n */\nexport const kubernetesServiceLocatorExtensionPoint =\n createExtensionPoint<KubernetesServiceLocatorExtensionPoint>({\n id: 'kubernetes.service-locator',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;;;AAsCO,MAAM,0CACXA,qCAA8D,CAAA;AAAA,EAC5D,EAAI,EAAA,6BAAA;AACN,CAAC,EAAA;AAgBI,MAAM,0CACXA,qCAA8D,CAAA;AAAA,EAC5D,EAAI,EAAA,6BAAA;AACN,CAAC,EAAA;AAgBI,MAAM,uCACXA,qCAA2D,CAAA;AAAA,EACzD,EAAI,EAAA,0BAAA;AACN,CAAC,EAAA;AAgBI,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC,EAAA;AAgBI,MAAM,yCACXA,qCAA6D,CAAA;AAAA,EAC3D,EAAI,EAAA,4BAAA;AACN,CAAC;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { KubernetesObjectsProvider as KubernetesObjectsProvider$1 } from '@backstage/plugin-kubernetes-node';
2
+ import { KubernetesObjectsProvider as KubernetesObjectsProvider$1, KubernetesClustersSupplier as KubernetesClustersSupplier$1, AuthenticationStrategy as AuthenticationStrategy$1, KubernetesFetcher as KubernetesFetcher$1, KubernetesServiceLocator as KubernetesServiceLocator$1 } from '@backstage/plugin-kubernetes-node';
3
3
  import { Entity } from '@backstage/catalog-model';
4
- import { ObjectsByEntityResponse, KubernetesRequestAuth, CustomResourceMatcher } from '@backstage/plugin-kubernetes-common';
4
+ import { ObjectsByEntityResponse, KubernetesRequestAuth, CustomResourceMatcher, KubernetesFetchError, FetchResponse } from '@backstage/plugin-kubernetes-common';
5
+ import { JsonObject } from '@backstage/types';
5
6
 
6
7
  /**
7
8
  * The interface for {@link kubernetesObjectsProviderExtensionPoint}.
@@ -17,6 +18,62 @@ interface KubernetesObjectsProviderExtensionPoint {
17
18
  * @public
18
19
  */
19
20
  declare const kubernetesObjectsProviderExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesObjectsProviderExtensionPoint>;
21
+ /**
22
+ * The interface for {@link kubernetesClusterSupplierExtensionPoint}.
23
+ *
24
+ * @public
25
+ */
26
+ interface KubernetesClusterSupplierExtensionPoint {
27
+ addClusterSupplier(clusterSupplier: KubernetesClustersSupplier$1): void;
28
+ }
29
+ /**
30
+ * An extension point the exposes the ability to configure a cluster supplier.
31
+ *
32
+ * @public
33
+ */
34
+ declare const kubernetesClusterSupplierExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesClusterSupplierExtensionPoint>;
35
+ /**
36
+ * The interface for {@link kubernetesAuthStrategyExtensionPoint}.
37
+ *
38
+ * @public
39
+ */
40
+ interface KubernetesAuthStrategyExtensionPoint {
41
+ addAuthStrategy(key: string, strategy: AuthenticationStrategy$1): void;
42
+ }
43
+ /**
44
+ * An extension point the exposes the ability to add an Auth Strategy.
45
+ *
46
+ * @public
47
+ */
48
+ declare const kubernetesAuthStrategyExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesAuthStrategyExtensionPoint>;
49
+ /**
50
+ * The interface for {@link kubernetesFetcherExtensionPoint}.
51
+ *
52
+ * @public
53
+ */
54
+ interface KubernetesFetcherExtensionPoint {
55
+ addFetcher(fetcher: KubernetesFetcher$1): void;
56
+ }
57
+ /**
58
+ * An extension point the exposes the ability to configure a kubernetes fetcher.
59
+ *
60
+ * @public
61
+ */
62
+ declare const kubernetesFetcherExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesFetcherExtensionPoint>;
63
+ /**
64
+ * The interface for {@link kubernetesServiceLocatorExtensionPoint}.
65
+ *
66
+ * @public
67
+ */
68
+ interface KubernetesServiceLocatorExtensionPoint {
69
+ addServiceLocator(serviceLocator: KubernetesServiceLocator$1): void;
70
+ }
71
+ /**
72
+ * An extension point the exposes the ability to configure a kubernetes service locator.
73
+ *
74
+ * @public
75
+ */
76
+ declare const kubernetesServiceLocatorExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<KubernetesServiceLocatorExtensionPoint>;
20
77
 
21
78
  /**
22
79
  *
@@ -41,5 +98,166 @@ interface KubernetesObjectsByEntity {
41
98
  interface CustomResourcesByEntity extends KubernetesObjectsByEntity {
42
99
  customResources: CustomResourceMatcher[];
43
100
  }
101
+ /**
102
+ * Provider-specific authentication configuration
103
+ * @public
104
+ */
105
+ type AuthMetadata = Record<string, string>;
106
+ /**
107
+ *
108
+ * @public
109
+ */
110
+ interface ClusterDetails {
111
+ /**
112
+ * Specifies the name of the Kubernetes cluster.
113
+ */
114
+ name: string;
115
+ url: string;
116
+ authMetadata: AuthMetadata;
117
+ skipTLSVerify?: boolean;
118
+ /**
119
+ * Whether to skip the lookup to the metrics server to retrieve pod resource usage.
120
+ * It is not guaranteed that the Kubernetes distro has the metrics server installed.
121
+ */
122
+ skipMetricsLookup?: boolean;
123
+ caData?: string | undefined;
124
+ caFile?: string | undefined;
125
+ /**
126
+ * Specifies the link to the Kubernetes dashboard managing this cluster.
127
+ * @remarks
128
+ * Note that you should specify the app used for the dashboard
129
+ * using the dashboardApp property, in order to properly format
130
+ * links to kubernetes resources, otherwise it will assume that you're running the standard one.
131
+ * @see dashboardApp
132
+ * @see dashboardParameters
133
+ */
134
+ dashboardUrl?: string;
135
+ /**
136
+ * Specifies the app that provides the Kubernetes dashboard.
137
+ * This will be used for formatting links to kubernetes objects inside the dashboard.
138
+ * @remarks
139
+ * The existing apps are: standard, rancher, openshift, gke, aks, eks
140
+ * Note that it will default to the regular dashboard provided by the Kubernetes project (standard).
141
+ * Note that you can add your own formatter by registering it to the clusterLinksFormatters dictionary.
142
+ * @defaultValue standard
143
+ * @see dashboardUrl
144
+ * @example
145
+ * ```ts
146
+ * import { clusterLinksFormatters } from '@backstage/plugin-kubernetes';
147
+ * clusterLinksFormatters.myDashboard = (options) => ...;
148
+ * ```
149
+ */
150
+ dashboardApp?: string;
151
+ /**
152
+ * Specifies specific parameters used by some dashboard URL formatters.
153
+ * This is used by the GKE formatter which requires the project, region and cluster name.
154
+ * @see dashboardApp
155
+ */
156
+ dashboardParameters?: JsonObject;
157
+ /**
158
+ * Specifies which custom resources to look for when returning an entity's
159
+ * Kubernetes resources.
160
+ */
161
+ customResources?: CustomResourceMatcher[];
162
+ }
163
+ /**
164
+ * Used to load cluster details from different sources
165
+ * @public
166
+ */
167
+ interface KubernetesClustersSupplier {
168
+ /**
169
+ * Returns the cached list of clusters.
170
+ *
171
+ * Implementations _should_ cache the clusters and refresh them periodically,
172
+ * as getClusters is called whenever the list of clusters is needed.
173
+ */
174
+ getClusters(): Promise<ClusterDetails[]>;
175
+ }
176
+ /**
177
+ * Authentication data used to make a request to Kubernetes
178
+ * @public
179
+ */
180
+ type KubernetesCredential = {
181
+ type: 'bearer token';
182
+ token: string;
183
+ } | {
184
+ type: 'anonymous';
185
+ };
186
+ /**
187
+ *
188
+ * @public
189
+ */
190
+ interface AuthenticationStrategy {
191
+ getCredential(clusterDetails: ClusterDetails, authConfig: KubernetesRequestAuth): Promise<KubernetesCredential>;
192
+ validateCluster(authMetadata: AuthMetadata): Error[];
193
+ }
194
+ /**
195
+ *
196
+ * @public
197
+ */
198
+ type KubernetesObjectTypes = 'pods' | 'services' | 'configmaps' | 'deployments' | 'limitranges' | 'resourcequotas' | 'replicasets' | 'horizontalpodautoscalers' | 'jobs' | 'cronjobs' | 'ingresses' | 'customresources' | 'statefulsets' | 'daemonsets';
199
+ /**
200
+ *
201
+ * @public
202
+ */
203
+ interface ObjectToFetch {
204
+ objectType: KubernetesObjectTypes;
205
+ group: string;
206
+ apiVersion: string;
207
+ plural: string;
208
+ }
209
+ /**
210
+ *
211
+ * @public
212
+ */
213
+ interface CustomResource extends ObjectToFetch {
214
+ objectType: 'customresources';
215
+ }
216
+ /**
217
+ *
218
+ * @public
219
+ */
220
+ interface ObjectFetchParams {
221
+ serviceId: string;
222
+ clusterDetails: ClusterDetails;
223
+ credential: KubernetesCredential;
224
+ objectTypesToFetch: Set<ObjectToFetch>;
225
+ labelSelector?: string;
226
+ customResources: CustomResource[];
227
+ namespace?: string;
228
+ }
229
+ /**
230
+ *
231
+ * @public
232
+ */
233
+ interface FetchResponseWrapper {
234
+ errors: KubernetesFetchError[];
235
+ responses: FetchResponse[];
236
+ }
237
+ /**
238
+ * Fetches information from a kubernetes cluster using the cluster details object to target a specific cluster
239
+ *
240
+ * @public
241
+ */
242
+ interface KubernetesFetcher {
243
+ fetchObjectsForService(params: ObjectFetchParams): Promise<FetchResponseWrapper>;
244
+ fetchPodMetricsByNamespaces(clusterDetails: ClusterDetails, credential: KubernetesCredential, namespaces: Set<string>, labelSelector?: string): Promise<FetchResponseWrapper>;
245
+ }
246
+ /**
247
+ * @public
248
+ */
249
+ interface ServiceLocatorRequestContext {
250
+ objectTypesToFetch: Set<ObjectToFetch>;
251
+ customResources: CustomResourceMatcher[];
252
+ }
253
+ /**
254
+ * Used to locate which cluster(s) a service is running on
255
+ * @public
256
+ */
257
+ interface KubernetesServiceLocator {
258
+ getClustersByEntity(entity: Entity, requestContext: ServiceLocatorRequestContext): Promise<{
259
+ clusters: ClusterDetails[];
260
+ }>;
261
+ }
44
262
 
45
- export { CustomResourcesByEntity, KubernetesObjectsByEntity, KubernetesObjectsProvider, KubernetesObjectsProviderExtensionPoint, kubernetesObjectsProviderExtensionPoint };
263
+ export { AuthMetadata, AuthenticationStrategy, ClusterDetails, CustomResource, CustomResourcesByEntity, FetchResponseWrapper, KubernetesAuthStrategyExtensionPoint, KubernetesClusterSupplierExtensionPoint, KubernetesClustersSupplier, KubernetesCredential, KubernetesFetcher, KubernetesFetcherExtensionPoint, KubernetesObjectTypes, KubernetesObjectsByEntity, KubernetesObjectsProvider, KubernetesObjectsProviderExtensionPoint, KubernetesServiceLocator, KubernetesServiceLocatorExtensionPoint, ObjectFetchParams, ObjectToFetch, ServiceLocatorRequestContext, kubernetesAuthStrategyExtensionPoint, kubernetesClusterSupplierExtensionPoint, kubernetesFetcherExtensionPoint, kubernetesObjectsProviderExtensionPoint, kubernetesServiceLocatorExtensionPoint };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-kubernetes-node",
3
3
  "description": "Node.js library for the kubernetes plugin",
4
- "version": "0.1.2-next.2",
4
+ "version": "0.1.2",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -22,14 +22,15 @@
22
22
  "postpack": "backstage-cli package postpack"
23
23
  },
24
24
  "devDependencies": {
25
- "@backstage/cli": "^0.25.0-next.2"
25
+ "@backstage/cli": "^0.25.0"
26
26
  },
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@backstage/backend-plugin-api": "^0.6.8-next.2",
31
+ "@backstage/backend-plugin-api": "^0.6.8",
32
32
  "@backstage/catalog-model": "^1.4.3",
33
- "@backstage/plugin-kubernetes-common": "^0.7.2-next.1"
33
+ "@backstage/plugin-kubernetes-common": "^0.7.2",
34
+ "@backstage/types": "^1.1.1"
34
35
  }
35
36
  }