Mashroom Portal Remote App Registry for Kubernetes
Plugin for Mashroom Server, a Integration Platform for Microfrontends.
Adds a remote app registry to Mashroom Portal. Scans periodically Kubernetes namespaces for services that expose Remote Portal Apps (actually it scans for exposed /package.json containing a mashroom property). You can find an example remote app here: Mashroom Demo Remote Portal App.
Usage
If node_modules/@mashroom is configured as plugin path just add @mashroom/mashroom-portal-remote-app-registry-k8s as dependency.
You can override the default config in your Mashroom config file like this:
{
"plugins": {
"Mashroom Portal Remote App Registry Kubernetes": {
"k8sNamespaces": ["default"],
"socketTimeoutSec": 3,
"scanPeriodSec": 30,
"refreshIntervalSec": 300,
"serviceNameFilter": "(microfrontend-|widget-)",
"accessViaClusterIP": false
}
}
}
- k8sNamespaces: The Kubernetes namespaces to scan (Default: ["default"])
- socketTimeoutSec: Socket timeout when trying to the Kubernetes service (default: 3)
- scanPeriodSec: The interval in seconds for scans (Default: 30)
- checkIntervalSec: The time in seconds after that a registered services show be re-checked (Default: 300)
- serviceNameFilter: A regular expression for services that should be checked (case insensitive). (Default: ".*")
- accessViaClusterIP: Access services via IP address and not via <name>.<namespace> (Default: false)
The list of successful registered services will be available on http://<host>:<port>/portal-remote-app-registry-kubernetes
Setup Kubernetes access
In order to allow Mashroom to fetch services for given namespaces you need to attach a Kubernetes Service Account with the correct permissions to the deployment.
Create a role with the required permissions like this:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: list-services-cluster-role
rules:
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
And then create the Service Account and attach the role:
apiVersion: v1
kind: ServiceAccount
metadata:
name: mashroom-portal
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: mashroom-portal-role-binding
namespace: default
subjects:
- kind: ServiceAccount
name: mashroom-portal
roleRef:
kind: ClusterRole
name: list-services-cluster-role
apiGroup: rbac.authorization.k8s.io
And in your deployment resource just state the Service Account name:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mashroom-portal
namespace: default
spec:
# ...
template:
# ...
spec:
containers:
- name: mashroom-portal
# ...
serviceAccountName: mashroom-portal