diff --git a/packages/server/config/cron.js b/packages/server/config/cron.js index 04980ac..2ea5c9f 100644 --- a/packages/server/config/cron.js +++ b/packages/server/config/cron.js @@ -17,7 +17,7 @@ async function syncRegistries () { try { strapi.service("api::registry.registry").sync(data); } catch (err) { - strapi.log.error(err.message); + console.error(err.message); } } @@ -78,7 +78,7 @@ async function syncOsm () { } } } catch (error) { - strapi.log.error(error); + console.error(error); } } diff --git a/packages/server/src/api/certificate/content-types/certificate/lifecycles.js b/packages/server/src/api/certificate/content-types/certificate/lifecycles.js index 7d3eb01..4093174 100644 --- a/packages/server/src/api/certificate/content-types/certificate/lifecycles.js +++ b/packages/server/src/api/certificate/content-types/certificate/lifecycles.js @@ -24,7 +24,7 @@ module.exports = { const k8sApi = kc.makeApiClient(k8s.CoreV1Api); await k8sApi.deleteNamespacedSecret(data.name, data.namespace.name); } catch (error) { - strapi.log.error(error); + console.error(error); } }, }; \ No newline at end of file diff --git a/packages/server/src/api/clickhouse/services/clickhouse.js b/packages/server/src/api/clickhouse/services/clickhouse.js index be42229..0a0c979 100644 --- a/packages/server/src/api/clickhouse/services/clickhouse.js +++ b/packages/server/src/api/clickhouse/services/clickhouse.js @@ -7,7 +7,7 @@ const { createCoreService } = require('@strapi/strapi').factories; const axios = require('axios'); -axios.defaults.timeout = 1000 +axios.defaults.timeout = 3000 const querystring = require('querystring'); const fs = require('fs'); @@ -150,7 +150,7 @@ module.exports = createCoreService('api::clickhouse.clickhouse', { } } } catch (error) { - strapi.log.error(error); + console.error(error); } }, }); diff --git a/packages/server/src/api/custom-event/content-types/custom-event/schema.json b/packages/server/src/api/custom-event/content-types/custom-event/schema.json new file mode 100644 index 0000000..37cdec1 --- /dev/null +++ b/packages/server/src/api/custom-event/content-types/custom-event/schema.json @@ -0,0 +1,43 @@ +{ + "kind": "collectionType", + "collectionName": "custom_events", + "info": { + "singularName": "custom-event", + "pluralName": "custom-events", + "displayName": "customEvent", + "description": "" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "action": { + "type": "string" + }, + "content": { + "type": "json" + }, + "organization": { + "type": "relation", + "relation": "manyToOne", + "target": "api::organization.organization", + "inversedBy": "customEvents" + }, + "user": { + "type": "relation", + "relation": "manyToOne", + "target": "plugin::users-permissions.user", + "inversedBy": "customEvents" + }, + "type": { + "type": "string" + }, + "from": { + "type": "string" + }, + "name": { + "type": "string" + } + } +} diff --git a/packages/server/src/api/custom-event/controllers/custom-event.js b/packages/server/src/api/custom-event/controllers/custom-event.js new file mode 100644 index 0000000..1bd6170 --- /dev/null +++ b/packages/server/src/api/custom-event/controllers/custom-event.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * custom-event controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::custom-event.custom-event'); diff --git a/packages/server/src/api/custom-event/routes/custom-event.js b/packages/server/src/api/custom-event/routes/custom-event.js new file mode 100644 index 0000000..faf24b5 --- /dev/null +++ b/packages/server/src/api/custom-event/routes/custom-event.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * custom-event router + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::custom-event.custom-event'); diff --git a/packages/server/src/api/custom-event/services/custom-event.js b/packages/server/src/api/custom-event/services/custom-event.js new file mode 100644 index 0000000..98ba93f --- /dev/null +++ b/packages/server/src/api/custom-event/services/custom-event.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * custom-event service + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::custom-event.custom-event'); diff --git a/packages/server/src/api/fleet/content-types/fleet/lifecycles.js b/packages/server/src/api/fleet/content-types/fleet/lifecycles.js index a01dc9a..8874291 100644 --- a/packages/server/src/api/fleet/content-types/fleet/lifecycles.js +++ b/packages/server/src/api/fleet/content-types/fleet/lifecycles.js @@ -55,7 +55,7 @@ module.exports = { try { await strapi.service("api::clickhouse.clickhouse").createTable(event.result); } catch (error) { - strapi.log.error(error); + console.error(error); } } }, @@ -127,7 +127,6 @@ module.exports = { try { const { result } = event; - if (result.type === 'clickhouse') { const clickhouses = await strapi.db.query('api::fleet.fleet').findOne({ where: { @@ -165,7 +164,7 @@ module.exports = { } } } catch (error) { - strapi.log.error(error); + console.error(error); } }, diff --git a/packages/server/src/api/ingress/services/ingress.js b/packages/server/src/api/ingress/services/ingress.js index 053a086..b3afe80 100644 --- a/packages/server/src/api/ingress/services/ingress.js +++ b/packages/server/src/api/ingress/services/ingress.js @@ -109,7 +109,7 @@ module.exports = createCoreService('api::ingress.ingress',{ args.data.content ); } catch (error) { - strapi.log.error(error?.response?.body) + console.error(error?.response?.body) if (error?.response?.body?.message) { throw new Error(error?.response?.body?.message); } else { @@ -142,7 +142,7 @@ module.exports = createCoreService('api::ingress.ingress',{ values.content.metadata.namespace ); } catch (error) { - strapi.log.error(error?.response?.body) + console.error(error?.response?.body) } return await strapi.db.query("api::" + type + "." + type).delete({where: { id: args.id }}); diff --git a/packages/server/src/api/mesh/services/mesh.js b/packages/server/src/api/mesh/services/mesh.js index aafb08a..fab0d98 100644 --- a/packages/server/src/api/mesh/services/mesh.js +++ b/packages/server/src/api/mesh/services/mesh.js @@ -80,7 +80,7 @@ module.exports = createCoreService('api::mesh.mesh',{ // -- Address of the remote logging service (must contain the namespace). When left empty, this is computed in helper template to "remote-logging-service..svc.cluster.local". result.options.osm.remoteLogging.address = ch.content.host; // -- Port of the remote logging service - result.options.osm.remoteLogging.port = ch.content.port; + result.options.osm.remoteLogging.port = Number(ch.content.port); // -- The authorization for remote logging service const base64Str = new Buffer.from( ch.content.user + ':' + ch.content.password @@ -159,7 +159,7 @@ module.exports = createCoreService('api::mesh.mesh',{ }); if (result.mcsEnable) { - let helmFsmCmd = `helm repo add fsm https://charts.flomesh.io && helm install --namespace ${namespace.name} --kubeconfig ${kubeconfigPath} --set fsm.logLevel=5 --version=0.2.1 fsm fsm/fsm --create-namespace`; + let helmFsmCmd = `helm repo add fsm https://charts.flomesh.io && helm install --namespace ${namespace.name} --kubeconfig ${kubeconfigPath} --set fsm.logLevel=5 --version=0.2.3 fsm fsm/fsm --create-namespace`; if (result.timeout) { helmFsmCmd += ' --timeout ${result.timeout}'; @@ -226,7 +226,7 @@ module.exports = createCoreService('api::mesh.mesh',{ ); } } catch (error) { - strapi.log.error(error) + console.error(error) } strapi.log.info('add cluster', res.body.status.loadBalancer); }; @@ -462,7 +462,7 @@ module.exports = createCoreService('api::mesh.mesh',{ ); } } catch (error) { - strapi.log.error(error) + console.error(error) } strapi.log.info('del cluster', name); }; diff --git a/packages/server/src/api/namespace/services/namespace.js b/packages/server/src/api/namespace/services/namespace.js index e88950d..817d2fc 100644 --- a/packages/server/src/api/namespace/services/namespace.js +++ b/packages/server/src/api/namespace/services/namespace.js @@ -29,7 +29,7 @@ module.exports = createCoreService('api::namespace.namespace',{ }); }); } catch (error) { - strapi.log.error(error); + console.error(error); } }, }); diff --git a/packages/server/src/api/organization/content-types/organization/lifecycles.js b/packages/server/src/api/organization/content-types/organization/lifecycles.js index b6ad19e..0d6ba64 100644 --- a/packages/server/src/api/organization/content-types/organization/lifecycles.js +++ b/packages/server/src/api/organization/content-types/organization/lifecycles.js @@ -81,7 +81,7 @@ module.exports = { } } } catch (error) { - strapi.log.error(error); + console.error(error); } }, }; \ No newline at end of file diff --git a/packages/server/src/api/organization/content-types/organization/schema.json b/packages/server/src/api/organization/content-types/organization/schema.json index 57b9391..2dc459e 100644 --- a/packages/server/src/api/organization/content-types/organization/schema.json +++ b/packages/server/src/api/organization/content-types/organization/schema.json @@ -96,6 +96,12 @@ "relation": "oneToMany", "target": "api::event.event", "mappedBy": "organization" + }, + "customEvents": { + "type": "relation", + "relation": "oneToMany", + "target": "api::custom-event.custom-event", + "mappedBy": "organization" } } } diff --git a/packages/server/src/api/registry/content-types/registry/lifecycles.js b/packages/server/src/api/registry/content-types/registry/lifecycles.js index b57e0c0..ce24c61 100644 --- a/packages/server/src/api/registry/content-types/registry/lifecycles.js +++ b/packages/server/src/api/registry/content-types/registry/lifecycles.js @@ -45,7 +45,7 @@ module.exports = { } }); } catch (error) { - strapi.log.error(error); + console.error(error); } }, beforeCreate: async (event) => { @@ -100,22 +100,23 @@ module.exports = { } }, afterUpdate: async (event) => { - const { result, params } = event; + const { result } = event; if (result.type == 'k8s') { try { strapi.log.info('fetch k8s namespace'); await strapi.service('api::registry.registry').fetchK8sNamespace(result); } catch (error) { - strapi.log.error(error) + console.error(error) } - } else if (result.type == 'eureka') { - strapi.service('api::registry.registry').fetchEurekaServices(result.id, params, true); - } + } + // already done it at beforeUpdate() + // else if (result.type == 'eureka') { + // strapi.service('api::registry.registry').fetchEurekaServices(result.id, params, true); + // } }, beforeUpdate: async (event) => { const { params } = event; - - const data = await strapi.db.query("api::registry.registry").findOne(params.where.id); + const data = await strapi.entityService.findOne('api::registry.registry', params.where.id); if (data.type == 'k8s') { if (data.config) { const json = YAML.parse(data.config) @@ -124,8 +125,7 @@ module.exports = { data.address = cluster.cluster.server } } else if (data.type == 'eureka') { - await strapi.service('api::registry.registry').fetchEurekaServices( - data, true); + await strapi.service('api::registry.registry').fetchEurekaServices(data, true); } else { strapi.log.info('fetch xxx namespace'); } diff --git a/packages/server/src/api/registry/controllers/registry.js b/packages/server/src/api/registry/controllers/registry.js index 9c6161c..558a201 100644 --- a/packages/server/src/api/registry/controllers/registry.js +++ b/packages/server/src/api/registry/controllers/registry.js @@ -26,14 +26,15 @@ module.exports = createCoreController('api::registry.registry', ({ strapi }) => async refresh(ctx, args) { await strapi.db.query("api::registry.registry").update({where:{...args}, data: {updated_at: new Date()}}) - try { - ctx.koaContext.request.header.schema_id = args.id; - ctx.koaContext.request.header.namespace = '_all'; - ctx.koaContext.request.header.schema_type = 'k8s'; - await strapi.service('api::service.service').fetchServices(ctx, args); - } catch (error) { - strapi.log.error(error) - } + // already done it at afterUpdate() + // try { + // ctx.koaContext.request.header.schema_id = args.id; + // ctx.koaContext.request.header.namespace = '_all'; + // ctx.koaContext.request.header.schema_type = 'k8s'; + // await strapi.service('api::service.service').fetchServices(ctx, args); + // } catch (error) { + // console.error(error) + // } return true; }, })); diff --git a/packages/server/src/api/registry/services/registry.js b/packages/server/src/api/registry/services/registry.js index 48adcd8..fffe4d0 100644 --- a/packages/server/src/api/registry/services/registry.js +++ b/packages/server/src/api/registry/services/registry.js @@ -57,8 +57,7 @@ async function syncKubernetes (data) { } } catch (error) { - strapi.log.error("Sync metrics"); - strapi.log.error(error); + console.error("Sync metrics: ",error.message); } } for (const item of response.data.items) { @@ -72,8 +71,7 @@ async function syncKubernetes (data) { } } catch (error) { - strapi.log.error("Get metrics"); - strapi.log.error(error) + console.error("Sync metrics: ",error.message); } } } @@ -115,9 +113,9 @@ module.exports = createCoreService('api::registry.registry', { status: 1, }; } catch (error) { - strapi.log.error(error); + console.error(error); const errMsg = error.toString(); - strapi.log.error(errMsg); + console.error(errMsg); return { isOK: false, status: -1, @@ -162,9 +160,9 @@ module.exports = createCoreService('api::registry.registry', { }; } } catch (error) { - strapi.log.error(error); + console.error(error); const errMsg = error.toString(); - strapi.log.error(errMsg); + console.error(errMsg); return { isOK: false, status: -1, @@ -189,7 +187,7 @@ module.exports = createCoreService('api::registry.registry', { result.body.items.forEach(async (item) => { if (!namespaces.find((n) => n.name == item.metadata.name)) { strapi.log.debug('fetch new namespace: ' + item.metadata.name); - strapi.entityService.create('api::namespace.namespace', { + await strapi.entityService.create('api::namespace.namespace', { data: { name: item.metadata.name, registry: regId, @@ -200,7 +198,7 @@ module.exports = createCoreService('api::registry.registry', { } }); } catch (error) { - strapi.log.error(error); + console.error(error); } }, @@ -216,8 +214,15 @@ module.exports = createCoreService('api::registry.registry', { let ns; let oldSvcs; if (isSync) { - ns = await await strapi.db.query('api::namespace.namespace').findOne({ registry: registry.id }); - oldSvcs = await strapi.db.query('api::service.service').findMany({ registry: registry.id }); + ns = await strapi.db.query('api::namespace.namespace').findOne({ + select: ['id', 'name'], + where: { registry: registry.id } + }); + oldSvcs = await strapi.entityService.findMany('api::service.service', { + filters: { + registry: registry.id + } + }); if (oldSvcs) { } else { isSync = false; @@ -235,7 +240,6 @@ module.exports = createCoreService('api::registry.registry', { // basic token const auth = registry.content.credit; const buf = Buffer.from(auth, 'ascii'); - const eurekaAxios = axios.create({ baseURL: registry.address, headers: { @@ -243,6 +247,7 @@ module.exports = createCoreService('api::registry.registry', { Authorization: 'Basic ' + buf.toString('base64'), }, }); + try { // Call eureka interface const response = await eurekaAxios.get('eureka/apps'); @@ -259,7 +264,7 @@ module.exports = createCoreService('api::registry.registry', { name: item.name, }; let isNew = true, - isGateway = false; + isGateway = false; if ( item.instance[0].port['$'] == gatewayPort && item.instance[0].ipAddr == gatewayPath @@ -271,10 +276,7 @@ module.exports = createCoreService('api::registry.registry', { if (oldSvc.uid === uid) { isNew = false; await strapi.db.query('api::service.service').update({ - where: { - id: oldSvc.id, - uid: uid - }, + where: { id: oldSvc.id }, data: { deleted: false, content: item, @@ -332,7 +334,7 @@ module.exports = createCoreService('api::registry.registry', { } } } catch (error) { - strapi.log.error(error); + console.error(error); } }, diff --git a/packages/server/src/api/service-export/content-types/service-export/lifecycles.js b/packages/server/src/api/service-export/content-types/service-export/lifecycles.js index ff94840..802175a 100644 --- a/packages/server/src/api/service-export/content-types/service-export/lifecycles.js +++ b/packages/server/src/api/service-export/content-types/service-export/lifecycles.js @@ -39,7 +39,7 @@ module.exports = { if (error.response.status === 409) { strapi.log.info('Exported already!'); } else { - strapi.log.error(error); + console.error(error); throw new Error('ErieCanal ' + error); } }); @@ -98,12 +98,12 @@ module.exports = { svcExportData.metadata.resourceVersion = response.data.metadata.resourceVersion; k8sAxios.put(svcExportsUrl, svcExportData).catch(function (error) { - strapi.log.error(error); + console.error(error); throw new Error('ErieCanal ' + error); }); }) .catch(function (error) { - strapi.log.error(error); + console.error(error); throw new Error('ErieCanal ' + error); }); }, @@ -139,7 +139,7 @@ module.exports = { '/serviceexports/' + svc.name; await k8sAxios.delete(svcExportUrl).catch(function (error) { - strapi.log.error(error); + console.error(error); }); }, async afterDelete(event) { diff --git a/packages/server/src/api/service-import/services/service-import.js b/packages/server/src/api/service-import/services/service-import.js index 6ff1b76..4282c9e 100644 --- a/packages/server/src/api/service-import/services/service-import.js +++ b/packages/server/src/api/service-import/services/service-import.js @@ -59,7 +59,7 @@ module.exports = createCoreService('api::service-import.service-import', { } }).catch(function (error) { - strapi.log.error(error) + console.error(error) }); }, @@ -108,7 +108,7 @@ module.exports = createCoreService('api::service-import.service-import', { } } }).catch(function (error) { - strapi.log.error(error); + console.error(error); }); }, @@ -162,7 +162,7 @@ module.exports = createCoreService('api::service-import.service-import', { throw new Error(response.data.reason); } }).catch(function (error) { - strapi.log.error(" --->>> " + error); + console.error(" --->>> " + error); }); }, @@ -176,7 +176,7 @@ module.exports = createCoreService('api::service-import.service-import', { throw new Error(response.data.reason); } }).catch(function (error) { // just log the err - strapi.log.error("ErieCanal " + error); + console.error("ErieCanal " + error); }); } }); diff --git a/packages/server/src/api/service/content-types/service/lifecycles.js b/packages/server/src/api/service/content-types/service/lifecycles.js index 0e70860..a64e76f 100644 --- a/packages/server/src/api/service/content-types/service/lifecycles.js +++ b/packages/server/src/api/service/content-types/service/lifecycles.js @@ -102,7 +102,7 @@ module.exports = { await strapi.service('api::service.service').deployService(service); // await strapi.service('api::service.service').deploySidecar(svcId); } catch (error) { - strapi.log.error(error); + console.error(error); } }, }; \ No newline at end of file diff --git a/packages/server/src/api/service/controllers/service.js b/packages/server/src/api/service/controllers/service.js index bd214a2..7db1ec0 100644 --- a/packages/server/src/api/service/controllers/service.js +++ b/packages/server/src/api/service/controllers/service.js @@ -21,7 +21,7 @@ module.exports = createCoreController('api::service.service',({ strapi }) => ({ try { await strapi.service('api::service.service').fetchServices(ctx, args, args.id); } catch (error) { - strapi.log.error(error); + console.error(error); } } return await strapi.db.query("api::service.service").findOne({where: {id: args.id}}); diff --git a/packages/server/src/api/service/services/service.js b/packages/server/src/api/service/services/service.js index d644d62..ff886dd 100644 --- a/packages/server/src/api/service/services/service.js +++ b/packages/server/src/api/service/services/service.js @@ -31,7 +31,14 @@ module.exports = createCoreService('api::service.service', { async fetchServices(ctx, args, id) { const schemaType = ctx.koaContext.request.header.schema_type; - if (schemaType != 'k8s') { + if (schemaType == 'eureka') { + strapi.log.info('=========>>> fetchEurekaServices()'); + const regId = ctx.koaContext.request.header.schema_id; + const regData = await strapi.entityService.findOne('api::registry.registry', regId); + await strapi.service('api::registry.registry').fetchEurekaServices(regData, true); + return true; + } + else if (schemaType != 'k8s') { return true; } if (id) { @@ -159,7 +166,7 @@ module.exports = createCoreService('api::service.service', { } } } catch (error) { - strapi.log.error(error); + console.error(error); } } return serviceDB; @@ -179,7 +186,7 @@ module.exports = createCoreService('api::service.service', { delete args.data.content.metadata.creationTimestamp; delete args.data.content.metadata.managedFields; } catch (error) { - strapi.log.error(error); + console.error(error); } try { await k8sApi.createNamespacedService( @@ -187,7 +194,7 @@ module.exports = createCoreService('api::service.service', { args.data.content ); } catch (error) { - strapi.log.error(error?.response?.body) + console.error(error?.response?.body) if (error?.response?.body?.message) { throw new Error(error?.response?.body?.message); } else { @@ -225,7 +232,7 @@ module.exports = createCoreService('api::service.service', { values.namespace ); } catch (error) { - strapi.log.error(error?.response?.body) + console.error(error?.response?.body) } return await strapi.db.query("api::" + type + "." + type).delete({where: { id: args.id }}); @@ -260,7 +267,7 @@ module.exports = createCoreService('api::service.service', { return header + '.' + payload + '.' + sig; } } catch (error) { - strapi.log.error(error); + console.error(error); } }, }); diff --git a/packages/server/src/charts/osm/Chart.lock b/packages/server/src/charts/osm/Chart.lock index 95a1cd8..758ba84 100644 --- a/packages/server/src/charts/osm/Chart.lock +++ b/packages/server/src/charts/osm/Chart.lock @@ -4,6 +4,6 @@ dependencies: version: 8.0.4 - name: fsm repository: https://charts.flomesh.io - version: 0.2.0 + version: 0.2.3 digest: sha256:be8ced3d604a29b0ba0238a3e5ce023e0481f3a4dbedb72addaa49eed1d9c665 generated: "2023-01-26T22:30:29.607702+08:00" diff --git a/packages/server/src/charts/osm/Chart.yaml b/packages/server/src/charts/osm/Chart.yaml index 454d10d..634afb2 100644 --- a/packages/server/src/charts/osm/Chart.yaml +++ b/packages/server/src/charts/osm/Chart.yaml @@ -14,11 +14,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 1.3.0 +version: 1.3.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. -appVersion: v1.3.0 +appVersion: v1.3.2 # This specifies the minimum Kubernetes version OSM is compatible with. kubeVersion: ">= 1.19.0-0" @@ -29,6 +29,6 @@ dependencies: repository: https://charts.bitnami.com/bitnami condition: contour.enabled - name: fsm - version: 0.2.0 + version: 0.2.3 repository: https://charts.flomesh.io condition: fsm.enabled diff --git a/packages/server/src/charts/osm/README.md b/packages/server/src/charts/osm/README.md index 362f2d7..0c408b3 100644 --- a/packages/server/src/charts/osm/README.md +++ b/packages/server/src/charts/osm/README.md @@ -1,6 +1,6 @@ # Open Service Mesh Edge Helm Chart -![Version: 1.3.0](https://img.shields.io/badge/Version-1.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.3.0](https://img.shields.io/badge/AppVersion-v1.3.0-informational?style=flat-square) +![Version: 1.3.2](https://img.shields.io/badge/Version-1.3.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.3.2](https://img.shields.io/badge/AppVersion-v1.3.2-informational?style=flat-square) A Helm chart to install the [osm-edge](https://github.com/flomesh-io/osm-edge) control plane on Kubernetes. @@ -130,25 +130,27 @@ The following table lists the configurable parameters of the osm chart and their | osm.grafana.port | int | `3000` | Grafana service's port | | osm.grafana.rendererImage | string | `"grafana/grafana-image-renderer:3.2.1"` | Image used for Grafana Renderer | | osm.grafana.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. | -| osm.image.digest | object | `{"osmBootstrap":"","osmCRDs":"","osmController":"","osmHealthcheck":"","osmInjector":"","osmPreinstall":"","osmSidecarInit":""}` | Image digest (defaults to latest compatible tag) | +| osm.image.digest | object | `{"osmBootstrap":"","osmCRDs":"","osmController":"","osmHealthcheck":"","osmInjector":"","osmInterceptor":"","osmPreinstall":"","osmSidecarInit":""}` | Image digest (defaults to latest compatible tag) | | osm.image.digest.osmBootstrap | string | `""` | osm-boostrap's image digest | | osm.image.digest.osmCRDs | string | `""` | osm-crds' image digest | | osm.image.digest.osmController | string | `""` | osm-controller's image digest | | osm.image.digest.osmHealthcheck | string | `""` | osm-healthcheck's image digest | | osm.image.digest.osmInjector | string | `""` | osm-injector's image digest | +| osm.image.digest.osmInterceptor | string | `""` | osm-interceptor's image digest | | osm.image.digest.osmPreinstall | string | `""` | osm-preinstall's image digest | | osm.image.digest.osmSidecarInit | string | `""` | Sidecar init container's image digest | -| osm.image.name | object | `{"osmBootstrap":"osm-edge-bootstrap","osmCRDs":"osm-edge-crds","osmController":"osm-edge-controller","osmHealthcheck":"osm-edge-healthcheck","osmInjector":"osm-edge-injector","osmPreinstall":"osm-edge-preinstall","osmSidecarInit":"osm-edge-sidecar-init"}` | Image name defaults | +| osm.image.name | object | `{"osmBootstrap":"osm-edge-bootstrap","osmCRDs":"osm-edge-crds","osmController":"osm-edge-controller","osmHealthcheck":"osm-edge-healthcheck","osmInjector":"osm-edge-injector","osmInterceptor":"osm-edge-interceptor","osmPreinstall":"osm-edge-preinstall","osmSidecarInit":"osm-edge-sidecar-init"}` | Image name defaults | | osm.image.name.osmBootstrap | string | `"osm-edge-bootstrap"` | osm-boostrap's image name | | osm.image.name.osmCRDs | string | `"osm-edge-crds"` | osm-crds' image name | | osm.image.name.osmController | string | `"osm-edge-controller"` | osm-controller's image name | | osm.image.name.osmHealthcheck | string | `"osm-edge-healthcheck"` | osm-healthcheck's image name | | osm.image.name.osmInjector | string | `"osm-edge-injector"` | osm-injector's image name | +| osm.image.name.osmInterceptor | string | `"osm-edge-interceptor"` | osm-interceptor's image name | | osm.image.name.osmPreinstall | string | `"osm-edge-preinstall"` | osm-preinstall's image name | | osm.image.name.osmSidecarInit | string | `"osm-edge-sidecar-init"` | Sidecar init container's image name | | osm.image.pullPolicy | string | `"IfNotPresent"` | Container image pull policy for control plane containers | | osm.image.registry | string | `"flomesh"` | Container image registry for control plane images | -| osm.image.tag | string | `"1.3.0"` | Container image tag for control plane images | +| osm.image.tag | string | `"1.3.2"` | Container image tag for control plane images | | osm.imagePullSecrets | list | `[]` | `osm-controller` image pull secret | | osm.inboundPortExclusionList | list | `[]` | Specifies a global list of ports to exclude from inbound traffic interception by the sidecar proxy. If specified, must be a list of positive integers. | | osm.injector.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key | string | `"kubernetes.io/os"` | | @@ -221,6 +223,24 @@ The following table lists the configurable parameters of the osm chart and their | osm.osmController.replicaCount | int | `1` | OSM controller's replica count (ignored when autoscale.enable is true) | | osm.osmController.resource | object | `{"limits":{"cpu":"1.5","memory":"1G"},"requests":{"cpu":"0.5","memory":"128M"}}` | OSM controller's container resource parameters. See https://docs.openservicemesh.io/docs/guides/ha_scale/scale/ for more details. | | osm.osmController.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key | string | `"kubernetes.io/os"` | | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator | string | `"In"` | | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values[0] | string | `"linux"` | | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].key | string | `"kubernetes.io/arch"` | | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].operator | string | `"In"` | | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].values[0] | string | `"amd64"` | | +| osm.osmInterceptor.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[1].values[1] | string | `"arm64"` | | +| osm.osmInterceptor.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].key | string | `"app"` | | +| osm.osmInterceptor.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operator | string | `"In"` | | +| osm.osmInterceptor.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0] | string | `"osm-controller"` | | +| osm.osmInterceptor.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | | +| osm.osmInterceptor.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | | +| osm.osmInterceptor.debug | bool | `false` | | +| osm.osmInterceptor.resource.limits.cpu | string | `"1.5"` | | +| osm.osmInterceptor.resource.limits.memory | string | `"1G"` | | +| osm.osmInterceptor.resource.requests.cpu | string | `"0.5"` | | +| osm.osmInterceptor.resource.requests.memory | string | `"256M"` | | +| osm.osmInterceptor.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. | | osm.osmNamespace | string | `""` | Namespace to deploy OSM in. If not specified, the Helm release namespace is used. | | osm.outboundIPRangeExclusionList | list | `[]` | Specifies a global list of IP ranges to exclude from outbound traffic interception by the sidecar proxy. If specified, must be a list of IP ranges of the form a.b.c.d/x. | | osm.outboundIPRangeInclusionList | list | `[]` | Specifies a global list of IP ranges to include for outbound traffic interception by the sidecar proxy. If specified, must be a list of IP ranges of the form a.b.c.d/x. | @@ -307,15 +327,15 @@ The following table lists the configurable parameters of the osm chart and their | osm.remoteLogging.endpoint | string | `""` | Remote logging's API path where the spans will be sent to | | osm.remoteLogging.port | int | `30514` | Port of the remote logging service | | osm.remoteLogging.sampledFraction | string | `"1.0"` | Sampled Fraction | -| osm.repoServer | object | `{"codebase":"","image":"flomesh/pipy-repo:0.90.0-18","ipaddr":"127.0.0.1","standalone":false}` | Pipy RepoServer | +| osm.repoServer | object | `{"codebase":"","image":"flomesh/pipy-repo:0.90.0-54","ipaddr":"127.0.0.1","standalone":false}` | Pipy RepoServer | | osm.repoServer.codebase | string | `""` | codebase is the folder used by osmController. | -| osm.repoServer.image | string | `"flomesh/pipy-repo:0.90.0-18"` | Image used for Pipy RepoServer | +| osm.repoServer.image | string | `"flomesh/pipy-repo:0.90.0-54"` | Image used for Pipy RepoServer | | osm.repoServer.ipaddr | string | `"127.0.0.1"` | ipaddr of host/service where Pipy RepoServer is installed | | osm.repoServer.standalone | bool | `false` | if false , Pipy RepoServer is installed within osmController pod. | | osm.sidecarClass | string | `"pipy"` | The class of the OSM Sidecar Driver | -| osm.sidecarDrivers | list | `[{"proxyServerPort":6060,"sidecarImage":"flomesh/pipy:0.90.0-18","sidecarName":"pipy"},{"proxyServerPort":15128,"sidecarImage":"envoyproxy/envoy:v1.19.3","sidecarName":"envoy","sidecarWindowsImage":"envoyproxy/envoy-windows:latest"}]` | Sidecar drivers supported by osm-edge | +| osm.sidecarDrivers | list | `[{"proxyServerPort":6060,"sidecarImage":"flomesh/pipy:0.90.0-54","sidecarName":"pipy"},{"proxyServerPort":15128,"sidecarImage":"envoyproxy/envoy:v1.19.3","sidecarName":"envoy","sidecarWindowsImage":"envoyproxy/envoy-windows:latest"}]` | Sidecar drivers supported by osm-edge | | osm.sidecarDrivers[0].proxyServerPort | int | `6060` | Remote destination port on which the Discovery Service listens for new connections from Sidecars. | -| osm.sidecarDrivers[0].sidecarImage | string | `"flomesh/pipy:0.90.0-18"` | Sidecar image for Linux workloads | +| osm.sidecarDrivers[0].sidecarImage | string | `"flomesh/pipy:0.90.0-54"` | Sidecar image for Linux workloads | | osm.sidecarDrivers[1].proxyServerPort | int | `15128` | Remote destination port on which the Discovery Service listens for new connections from Sidecars. | | osm.sidecarDrivers[1].sidecarImage | string | `"envoyproxy/envoy:v1.19.3"` | Sidecar image for Linux workloads | | osm.sidecarDrivers[1].sidecarWindowsImage | string | `"envoyproxy/envoy-windows:latest"` | Sidecar image for Windows workloads | diff --git a/packages/server/src/charts/osm/charts/fsm-0.2.0.tgz b/packages/server/src/charts/osm/charts/fsm-0.2.0.tgz deleted file mode 100644 index 40ea711..0000000 Binary files a/packages/server/src/charts/osm/charts/fsm-0.2.0.tgz and /dev/null differ diff --git a/packages/server/src/charts/osm/charts/fsm-0.2.3.tgz b/packages/server/src/charts/osm/charts/fsm-0.2.3.tgz new file mode 100644 index 0000000..71a5387 Binary files /dev/null and b/packages/server/src/charts/osm/charts/fsm-0.2.3.tgz differ diff --git a/packages/server/src/charts/osm/templates/_helpers.tpl b/packages/server/src/charts/osm/templates/_helpers.tpl index 48aaa9a..4bfd1a9 100644 --- a/packages/server/src/charts/osm/templates/_helpers.tpl +++ b/packages/server/src/charts/osm/templates/_helpers.tpl @@ -102,3 +102,12 @@ securityContext: {{- printf "%s/%s@%s" .Values.osm.image.registry .Values.osm.image.name.osmHealthcheck .Values.osm.image.digest.osmHealthcheck -}} {{- end -}} {{- end -}} + +{{/* osm-interceptor image */}} +{{- define "osmInterceptor.image" -}} +{{- if .Values.osm.image.tag -}} +{{- printf "%s/%s:%s" .Values.osm.image.registry .Values.osm.image.name.osmInterceptor .Values.osm.image.tag -}} +{{- else -}} +{{- printf "%s/%s@%s" .Values.osm.image.registry .Values.osm.image.name.osmInterceptor .Values.osm.image.digest.osmController -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/packages/server/src/charts/osm/templates/osm-interceptor-hpa.yaml b/packages/server/src/charts/osm/templates/osm-interceptor-hpa.yaml index 7406143..e7c65d7 100644 --- a/packages/server/src/charts/osm/templates/osm-interceptor-hpa.yaml +++ b/packages/server/src/charts/osm/templates/osm-interceptor-hpa.yaml @@ -59,19 +59,20 @@ spec: labels: app: osm-interceptor spec: + {{- if .Values.osm.osmInterceptor.affinity }} + affinity: + {{- toYaml .Values.osm.osmInterceptor.affinity | nindent 8 }} + {{- end }} hostNetwork: true containers: - - image: "cybwan/osm-edge-interceptor:latest" - imagePullPolicy: Always + - image: "{{ include "osmInterceptor.image" . }}" + imagePullPolicy: {{ .Values.osm.image.pullPolicy }} name: osm-interceptor args: - - /app/mbctl - - -m - - osm - - --use-reconnect=true + - /app/osm-interceptor - --cni-mode=true - - --kind=true - - --debug=true + - --kind=false + - --debug={{ .Values.osm.osmInterceptor.debug }} lifecycle: preStop: exec: @@ -80,12 +81,12 @@ spec: - -k - clean resources: - requests: - cpu: 100m - memory: 200Mi limits: - cpu: 300m - memory: 200Mi + cpu: "{{.Values.osm.osmInterceptor.resource.limits.cpu}}" + memory: "{{.Values.osm.osmInterceptor.resource.limits.memory}}" + requests: + cpu: "{{.Values.osm.osmInterceptor.resource.requests.cpu}}" + memory: "{{.Values.osm.osmInterceptor.resource.requests.memory}}" securityContext: privileged: true volumeMounts: @@ -101,8 +102,6 @@ spec: name: host-var-run mountPropagation: Bidirectional dnsPolicy: ClusterFirst - nodeSelector: - kubernetes.io/os: linux priorityClassName: system-node-critical restartPolicy: Always serviceAccount: osm-interceptor diff --git a/packages/server/src/charts/osm/values.schema.json b/packages/server/src/charts/osm/values.schema.json index d1c9c33..50a5945 100644 --- a/packages/server/src/charts/osm/values.schema.json +++ b/packages/server/src/charts/osm/values.schema.json @@ -192,6 +192,7 @@ "remoteLogging", "webhookConfigNamePrefix", "osmController", + "osmInterceptor", "enablePrivilegedInitContainer", "injector", "osmBootstrap", @@ -247,6 +248,43 @@ }, "additionalProperties": false }, + "osmInterceptor": { + "$id": "#/properties/osm/properties/osmInterceptor", + "type": "object", + "title": "The osmInterceptor schema", + "description": "The details of the osmInterceptor.", + "required": [ + "resource" + ], + "properties": { + "resource": { + "$ref": "#/definitions/containerResources" + }, + "podLabels": { + "$id": "#/properties/osm/properties/osmInterceptor/properties/podLabels", + "type": "object", + "title": "The podLabels schema", + "description": "Labels for the osmInterceptor pod.", + "default": {} + }, + "affinity": { + "type": "object" + }, + "tolerations": { + "type": "array" + }, + "debug": { + "$id": "#/properties/osm/properties/osmInterceptor/properties//debug", + "type": "boolean", + "title": "debug enable", + "description": "Indicates whether debug should be enabled or not.", + "examples": [ + false + ] + } + }, + "additionalProperties": false + }, "image": { "$id": "#/properties/osm/properties/image", "type": "object", @@ -288,7 +326,8 @@ "osmBootstrap", "osmCRDs", "osmPreinstall", - "osmHealthcheck" + "osmHealthcheck", + "osmInterceptor" ], "properties": { "osmController": { @@ -332,6 +371,12 @@ "type": "string", "title": "osm-healthcheck's image name", "description": "osm-healthcheck container's image name." + }, + "osmInterceptor": { + "$id": "#/properties/osm/properties/image/properties/name/properties/osmInterceptor", + "type": "string", + "title": "osm-interceptor's image name", + "description": "osm-interceptor container's image name." } } }, @@ -366,7 +411,8 @@ "osmCRDs", "osmBootstrap", "osmPreinstall", - "osmHealthcheck" + "osmHealthcheck", + "osmInterceptor" ], "properties": { "osmController": { @@ -410,6 +456,12 @@ "type": "string", "title": "osm-healthcheck's image digest", "description": "osm-healthcheck container's image digest." + }, + "osmInterceptor": { + "$id": "#/properties/osm/properties/image/properties/digest/properties/osmInterceptor", + "type": "string", + "title": "osm-interceptor's image digest", + "description": "osm-interceptor container's image digest." } } } diff --git a/packages/server/src/charts/osm/values.yaml b/packages/server/src/charts/osm/values.yaml index 17a9d05..ebdb1f6 100644 --- a/packages/server/src/charts/osm/values.yaml +++ b/packages/server/src/charts/osm/values.yaml @@ -12,7 +12,7 @@ osm: # -- Container image pull policy for control plane containers pullPolicy: IfNotPresent # -- Container image tag for control plane images - tag: "1.3.0" + tag: "1.3.2" # -- Image name defaults name: # -- osm-controller's image name @@ -29,6 +29,8 @@ osm: osmPreinstall: osm-edge-preinstall # -- osm-healthcheck's image name osmHealthcheck: osm-edge-healthcheck + # -- osm-interceptor's image name + osmInterceptor: osm-edge-interceptor # -- Image digest (defaults to latest compatible tag) digest: # -- osm-controller's image digest @@ -45,7 +47,8 @@ osm: osmPreinstall: "" # -- osm-healthcheck's image digest osmHealthcheck: "" - + # -- osm-interceptor's image digest + osmInterceptor: "" # -- `osm-controller` image pull secret imagePullSecrets: [ ] @@ -57,7 +60,7 @@ osm: sidecarDrivers: - sidecarName: pipy # -- Sidecar image for Linux workloads - sidecarImage: flomesh/pipy:0.90.0-18 + sidecarImage: flomesh/pipy:0.90.0-54 # -- Remote destination port on which the Discovery Service listens for new connections from Sidecars. proxyServerPort: 6060 - sidecarName: envoy @@ -73,7 +76,7 @@ osm: # -- Pipy RepoServer repoServer: # -- Image used for Pipy RepoServer - image: flomesh/pipy-repo:0.90.0-18 + image: flomesh/pipy-repo:0.90.0-54 # -- if false , Pipy RepoServer is installed within osmController pod. standalone: false # -- ipaddr of host/service where Pipy RepoServer is installed @@ -202,6 +205,48 @@ osm: tolerations: [ ] # + # -- OSM interceptor parameters + osmInterceptor: + debug: false + resource: + limits: + cpu: "1.5" + memory: "1G" + requests: + cpu: "0.5" + memory: "256M" + ## Affinity settings for pod assignment + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - linux + - key: kubernetes.io/arch + operator: In + values: + - amd64 + - arm64 + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - osm-controller + topologyKey: kubernetes.io/hostname + weight: 100 + + # -- Node tolerations applied to control plane pods. + # The specified tolerations allow pods to schedule onto nodes with matching taints. + tolerations: [ ] + # # -- Prometheus parameters prometheus: # -- Prometheus's container resource parameters diff --git a/packages/server/src/extensions/users-permissions/content-types/user/schema.json b/packages/server/src/extensions/users-permissions/content-types/user/schema.json index 077c9e2..13e8bb1 100644 --- a/packages/server/src/extensions/users-permissions/content-types/user/schema.json +++ b/packages/server/src/extensions/users-permissions/content-types/user/schema.json @@ -125,6 +125,12 @@ "relation": "oneToMany", "target": "api::kubectl.kubectl", "mappedBy": "user" + }, + "customEvents": { + "type": "relation", + "relation": "oneToMany", + "target": "api::custom-event.custom-event", + "mappedBy": "user" } } } diff --git a/packages/server/src/functions/awxUtils.js b/packages/server/src/functions/awxUtils.js index 02ad180..8b031c2 100644 --- a/packages/server/src/functions/awxUtils.js +++ b/packages/server/src/functions/awxUtils.js @@ -41,7 +41,7 @@ module.exports = { } } } catch (error) { - strapi.log.error(error.toJSON()); + console.error(error.toJSON()); } return result; diff --git a/packages/server/src/functions/emailUtils.js b/packages/server/src/functions/emailUtils.js index f212687..eba25f8 100644 --- a/packages/server/src/functions/emailUtils.js +++ b/packages/server/src/functions/emailUtils.js @@ -22,7 +22,7 @@ module.exports = { .createTransport(emailConf.content) .sendMail(mailOptions, (error) => { if (error) { - return strapi.log.error(error); + return console.error(error); } }); }, diff --git a/packages/server/src/functions/initCommonUtils.js b/packages/server/src/functions/initCommonUtils.js index 84076b0..85dae90 100644 --- a/packages/server/src/functions/initCommonUtils.js +++ b/packages/server/src/functions/initCommonUtils.js @@ -59,7 +59,7 @@ module.exports = { .query('api::fleet.fleet') .create({data: {name: component, type: component, content: components[component]}}); } catch (error) { - strapi.log.error(error) + console.error(error) } } } diff --git a/packages/server/src/functions/initUtils.js b/packages/server/src/functions/initUtils.js index b85871a..2b2d9db 100644 --- a/packages/server/src/functions/initUtils.js +++ b/packages/server/src/functions/initUtils.js @@ -62,7 +62,7 @@ module.exports = { left join namespaces n on n.id = l.namespace_id;`); } catch (error) { - strapi.log.error(error); + console.error(error); } }, async init_resource_permissions_free() { diff --git a/packages/server/src/index.js b/packages/server/src/index.js index f8ee9b3..5aa221c 100644 --- a/packages/server/src/index.js +++ b/packages/server/src/index.js @@ -4,7 +4,6 @@ const loginUtils = require("./functions/loginUtils.js"); const initCommonUtils = require("./functions/initCommonUtils.js"); const entityUtils = require("./functions/entityUtils.js"); const gqlUtils = require("./functions/gqlUtils.js"); - module.exports = { /** * An asynchronous register function that runs before diff --git a/packages/server/src/middlewares/event.js b/packages/server/src/middlewares/event.js index efe27b8..811ee54 100644 --- a/packages/server/src/middlewares/event.js +++ b/packages/server/src/middlewares/event.js @@ -24,7 +24,7 @@ module.exports = (config, { strapi }) => { } else if (method && method[0].indexOf("delete") > -1) { //console.log(ctx.response.body) const body = JSON.parse(ctx.response.body) - name = body.data[method[0]].data.attributes.name + name = body.data[method[0]]?.data?.attributes?.name //organization = body.data[method[0]].data.attributes.organization.data.attributes.id } @@ -59,7 +59,7 @@ module.exports = (config, { strapi }) => { }}); } } catch (error) { - strapi.log.error(error); + console.error(error); } }; }; \ No newline at end of file