@flowfuse/driver-kubernetes 2.25.0 → 2.25.1-334957a-202512301450.0

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.
@@ -10,7 +10,7 @@ on:
10
10
 
11
11
  jobs:
12
12
  build:
13
- uses: 'flowfuse/github-actions-workflows/.github/workflows/build_node_package.yml@v0.44.0'
13
+ uses: 'flowfuse/github-actions-workflows/.github/workflows/build_node_package.yml@v0.45.0'
14
14
  with:
15
15
  node: '[
16
16
  {"version": "18", "tests": false, "lint": true},
@@ -19,7 +19,7 @@ jobs:
19
19
  publish:
20
20
  needs: build
21
21
  if: github.event_name == 'push' && github.ref == 'refs/heads/main'
22
- uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.44.0'
22
+ uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.45.0'
23
23
  with:
24
24
  package_name: driver-k8s
25
25
  publish_package: true
package/README.md CHANGED
@@ -67,6 +67,7 @@ AWS EKS specific annotation for ALB Ingress. or `openshift` to allow running on
67
67
  - `podSecurityContext` Settings linked to the [security context of the pod](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
68
68
  - `containerSecurityContext` Settings linked to the [security context of the container](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
69
69
  - `service.type` Type of service to create for the editor (allowed `ClusterIP` or `NodePort`, default `ClusterIP`)
70
+ - `schedulerName` name of the custom Kubernetes scheduler to use for Project Pods and MQTT agent Pods (default not set, uses default Kubernetes scheduler)
70
71
 
71
72
  Expects to pick up K8s credentials from the environment
72
73
 
@@ -0,0 +1,54 @@
1
+ import globals from 'globals'
2
+ import js from '@eslint/js'
3
+ import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
4
+ import stylistic from '@stylistic/eslint-plugin'
5
+ import noOnlyTests from 'eslint-plugin-no-only-tests'
6
+
7
+ export default [
8
+ {
9
+ files: ['**/*.js'],
10
+ languageOptions: {
11
+ globals: {
12
+ ...globals.browser
13
+ },
14
+ sourceType: 'script'
15
+ }
16
+ },
17
+ {
18
+ files: ['test/**/*.js'],
19
+ languageOptions: {
20
+ globals: {
21
+ ...globals.browser,
22
+ ...globals.mocha
23
+ },
24
+ sourceType: 'script'
25
+ }
26
+ },
27
+ {
28
+ ignores: [
29
+ ...resolveIgnoresFromGitignore()
30
+ ]
31
+ },
32
+ js.configs.recommended,
33
+ ...neostandard(),
34
+ {
35
+ plugins: {
36
+ '@stylistic': stylistic,
37
+ 'no-only-tests': noOnlyTests
38
+ },
39
+ rules: {
40
+ // built-in
41
+ 'object-shorthand': ['error'],
42
+ 'no-console': ['error', { allow: ['debug', 'info', 'warn', 'error'] }],
43
+
44
+ // plugin:stylistic
45
+ '@stylistic/indent': ['warn', 4], // https://eslint.style/rules/indent#options
46
+ '@stylistic/spaced-comment': ['error', 'always'], // https://eslint.style/rules/spaced-comment
47
+ '@stylistic/no-multi-spaces': 'error', // https://eslint.style/rules/no-multi-spaces#no-multi-spaces
48
+ '@stylistic/comma-dangle': ['error', 'never'], // https://eslint.style/rules/comma-dangle#comma-dangle
49
+
50
+ // plugin:no-only-tests
51
+ 'no-only-tests/no-only-tests': 'error'
52
+ }
53
+ }
54
+ ]
package/kubernetes.js CHANGED
@@ -80,6 +80,10 @@ const createDeployment = async (project, options) => {
80
80
  localPod.metadata.labels.name = project.safeName
81
81
  localPod.spec.serviceAccount = process.env.EDITOR_SERVICE_ACCOUNT
82
82
 
83
+ if (this._schedulerName) {
84
+ localPod.spec.schedulerName = this._schedulerName
85
+ }
86
+
83
87
  if (stack.container) {
84
88
  localPod.spec.containers[0].image = stack.container
85
89
  } else {
@@ -441,7 +445,7 @@ const createPersistentVolumeClaim = async (project, options) => {
441
445
  ...this._app.config.driver.options.projectLabels
442
446
  }
443
447
  }
444
- console.log(`PVC: ${JSON.stringify(pvc, null, 2)}`)
448
+ console.error(`PVC: ${JSON.stringify(pvc, null, 2)}`)
445
449
  return pvc
446
450
  }
447
451
 
@@ -458,7 +462,7 @@ const createProject = async (project, options) => {
458
462
  try {
459
463
  await this._k8sApi.createNamespacedPersistentVolumeClaim({ namespace, body: localPVC })
460
464
  } catch (err) {
461
- console.log(JSON.stringify(err))
465
+ console.error(JSON.stringify(err))
462
466
  if (err.code === 409) {
463
467
  this._app.log.warn(`[k8s] PVC for instance ${project.id} already exists, proceeding...`)
464
468
  } else {
@@ -648,6 +652,10 @@ const createMQTTTopicAgent = async (broker) => {
648
652
  localPod.spec.nodeSelector = this._app.config.driver.options.projectSelector
649
653
  }
650
654
 
655
+ if (this._schedulerName) {
656
+ localPod.spec.schedulerName = this._schedulerName
657
+ }
658
+
651
659
  localPod.metadata.name = `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${agent ? 'team-broker' : broker.hashid.toLowerCase()}`
652
660
  localPod.metadata.labels = {
653
661
  name: `mqtt-schema-agent-${broker.Team.hashid.toLowerCase()}-${broker.hashid.toLowerCase()}`,
@@ -677,7 +685,7 @@ const createMQTTTopicAgent = async (broker) => {
677
685
  // console.log(JSON.stringify(localPod,null,2))
678
686
  // console.log(JSON.stringify(localService,null,2))
679
687
  try {
680
- console.log(namespace, localPod.metadata.name)
688
+ console.debug(namespace, localPod.metadata.name)
681
689
  await this._k8sApi.createNamespacedPod({ namespace, body: localPod })
682
690
  await this._k8sApi.createNamespacedService({ namespace, body: localService })
683
691
  } catch (err) {
@@ -709,6 +717,7 @@ module.exports = {
709
717
  this._projectIngressAnnotations = this._app.config.driver.options?.projectIngressAnnotations
710
718
  this._logPassthrough = this._app.config.driver.options?.logPassthrough || false
711
719
  this._cloudProvider = this._app.config.driver.options?.cloudProvider
720
+ this._schedulerName = this._app.config.driver.options?.schedulerName
712
721
  if (this._app.config.driver.options?.customHostname?.enabled) {
713
722
  this._app.log.info('[k8s] Enabling Custom Hostname Support')
714
723
  this._customHostname = this._app.config.driver.options?.customHostname
@@ -1383,7 +1392,7 @@ module.exports = {
1383
1392
  try {
1384
1393
  return got.get(fileUrl, { timeout: { request: 1000 } }).json()
1385
1394
  } catch (err) {
1386
- console.log(err)
1395
+ console.error(err)
1387
1396
  err.statusCode = err.response.statusCode
1388
1397
  throw err
1389
1398
  }
package/lib/aws-efs.js CHANGED
@@ -1,9 +1,8 @@
1
- const { EFSClient, DescribeFileSystemsCommand, DescribeAccessPointsCommand } = require("@aws-sdk/client-efs")
1
+ const { EFSClient, DescribeFileSystemsCommand, DescribeAccessPointsCommand } = require('@aws-sdk/client-efs')
2
2
 
3
3
  let client
4
4
 
5
5
  async function lookupStorageClass (tagName) {
6
-
7
6
  // console.log(`Looking for ${tagName}`)
8
7
 
9
8
  if (!client) {
@@ -16,14 +15,14 @@ async function lookupStorageClass (tagName) {
16
15
 
17
16
  const fileSystems = []
18
17
 
19
- for (let i = 0; i<fsList.FileSystems.length; i++) {
18
+ for (let i = 0; i < fsList.FileSystems.length; i++) {
20
19
  let found = false
21
20
  let storageClass = ''
22
- for (let j = 0; j<fsList.FileSystems[i].Tags.length; j++) {
21
+ for (let j = 0; j < fsList.FileSystems[i].Tags.length; j++) {
23
22
  const tag = fsList.FileSystems[i].Tags[j]
24
23
  if (tag.Key === tagName) {
25
24
  found = true
26
- }
25
+ }
27
26
  if (tag.Key === 'storage-class-name') {
28
27
  storageClass = tag.Value
29
28
  }
@@ -37,19 +36,18 @@ async function lookupStorageClass (tagName) {
37
36
  // console.log(apParams)
38
37
  const apListCommand = new DescribeAccessPointsCommand(apParams)
39
38
  const apList = await client.send(apListCommand)
40
- // fileSystems[fsList.FileSystems[i].FileSystemId]
39
+ // fileSystems[fsList.FileSystems[i].FileSystemId]
41
40
  fileSystems.push({
42
41
  apCount: apList.AccessPoints.length,
43
42
  storageClass
44
43
  })
45
- }
44
+ }
46
45
  }
47
- fileSystems.sort((a,b) => a.apCount - b.apCount)
46
+ fileSystems.sort((a, b) => a.apCount - b.apCount)
48
47
 
49
48
  return fileSystems[0]?.storageClass
50
49
  }
51
50
 
52
-
53
51
  module.exports = {
54
52
  lookupStorageClass
55
53
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@flowfuse/driver-kubernetes",
3
- "version": "2.25.0",
3
+ "version": "2.25.1-334957a-202512301450.0",
4
4
  "description": "Kubernetes driver for FlowFuse",
5
5
  "main": "kubernetes.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "lint": "eslint -c .eslintrc \"*.js\"",
9
- "lint:fix": "eslint -c .eslintrc \"*.js\" --fix"
8
+ "lint": "eslint -c eslint.config.mjs ",
9
+ "lint:fix": "eslint -c eslint.config.mjs --fix"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -28,7 +28,10 @@
28
28
  "lodash": "^4.17.21"
29
29
  },
30
30
  "devDependencies": {
31
- "eslint": "^8.25.0",
32
- "eslint-config-standard": "^17.0.0"
31
+ "@eslint/js": "^9.39.2",
32
+ "eslint": "^9.39.2",
33
+ "eslint-plugin-no-only-tests": "^3.3.0",
34
+ "globals": "^16.5.0",
35
+ "neostandard": "^0.12.2"
33
36
  }
34
37
  }
package/.eslintrc DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "root": true,
3
- "env": {
4
- "browser": true,
5
- "commonjs": true,
6
- "es2021": true,
7
- "mocha": true
8
- },
9
- "extends": [
10
- "standard"
11
- ],
12
- "parserOptions": {
13
- "ecmaVersion": 12
14
- },
15
- "rules": {
16
- "indent": ["error", 4],
17
- "object-shorthand": ["error"]
18
- }
19
- }