Skip to content

Latest commit

 

History

History
178 lines (124 loc) · 7.43 KB

File metadata and controls

178 lines (124 loc) · 7.43 KB

OpenShift Console Plugin for NMState

An OpenShift web console plugin for kubernetes-nmstate. The plugin adds a web-based user interface for managing node network configuration inside the OpenShift console.

Overview

NMState is a tool for state-driven network configuration on cluster nodes. This plugin provides four main views:

  • Policies — create, edit, and delete NodeNetworkConfigurationPolicy resources
  • States — browse NodeNetworkState for each node with detailed interface info
  • Physical Networks — overview of physical network interfaces and enactment status
  • Node Network Configuration — topology visualization of node network layouts

Prerequisites

Quick Start

git clone git@github.com:openshift/nmstate-console-plugin.git
cd nmstate-console-plugin
npm install
npm run start-console

The OpenShift console runs at http://localhost:9000 with the plugin loaded on port 9001.

Requires a running OpenShift or Kubernetes cluster (see Development for cluster setup options).

Development

In-cluster development

cd nmstate-console-plugin

npm run dev -- --port 9443 \
  --server-type https \
  --server-options-key /var/serving-cert/tls.key \
  --server-options-cert /var/serving-cert/tls.crt

Local development

Requirements

Requirement Description
Node.js JavaScript runtime environment
npm Package manager for Node.js (included with Node.js)
Kubernetes An OpenShift or Kubernetes cluster
kubectl The Kubernetes command-line tool

Setting up a local cluster

You can create a small OpenShift environment using OpenShift Local or KinD. OpenShift Local installs all necessary services. When using KinD, you may need to set up the development environment manually.

# Deploy a minimal Kubernetes cluster with storage, registry, and admin user
bash scripts/deploy-cluster.sh

# Delete the cluster and local registry (removes all workloads and data)
bash scripts/clean-cluster.sh

Running virtualized workloads (e.g. virtual machines) on this cluster requires starting the cluster as root: sudo bash scripts/deploy-cluster.sh

Running with mock data

npm install
npm run start-console

The OpenShift console runs in a container connected to your current cluster. The plugin HTTP server runs on port 9001 with CORS enabled. The development server is available at http://localhost:9000.

start-console accepts these environment variables:

Variable Description
CONSOLE_IMAGE Console image to run (default: quay.io/openshift/origin-console:latest)
CONSOLE_PORT Console web application port (default: 9000)
INVENTORY_SERVER_HOST NMState inventory server URL (default: http://localhost:30088)
BRIDGE_K8S_AUTH_BEARER_TOKEN Bearer token for user account (on OpenShift defaults to $(oc whoami -t))
BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT Kubernetes API server URL (default: guessed from kubeconfig)

When running on a cluster without NMState installed, install only the missing CRDs:

kubectl apply -f scripts/yaml/crds

Running with a remote NMState API server

When running OpenShift Local, install NMState and KubeVirt via OperatorHub. On KinD, use the CI scripts.

export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(oc whoami --show-server)
export BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token)
export INVENTORY_SERVER_HOST=https://$(oc get routes -o custom-columns=HOST:.spec.host -A | grep 'nmstate-inventory' | head -n 1)

npm run dev

Deployment

OpenShift templates

oc process -f oc-manifest.yaml \
  -p PLUGIN_NAME=nmstate-console-plugin \
  -p NAMESPACE=openshift-nmstate \
  -p IMAGE=quay.io/nmstate/nmstate-console-plugin:latest \
  | oc create -f -

Enable the plugin:

oc patch consoles.operator.openshift.io cluster \
  --patch '{ "spec": { "plugins": ["nmstate-console-plugin"] } }' --type=merge

Helm

helm upgrade -i nmstate-console-plugin deployment/nmstate-console-plugin \
  -n openshift-nmstate --create-namespace

By default Helm uses quay.io/nmstate/nmstate-console-plugin:latest. Override with --set image=IMAGE_NAME.

See the chart values for all parameters.

Enable the plugin (if no other console plugins are installed):

oc patch consoles.operator.openshift.io cluster \
  --patch '{ "spec": { "plugins": ["nmstate-console-plugin"] } }' --type=merge

If other console plugins are already installed:

oc patch consoles.operator.openshift.io cluster \
  --patch '[{ "op": "add", "path": "/spec/plugins/-", "value": "nmstate-console-plugin" }]' --type=json

On OpenShift 4.10, add --set plugin.securityContext.enabled=false to omit Pod Security configurations.

Testing

npm test                 # Jest unit tests
npm run test:coverage    # Jest with coverage report
npm run cypress          # Cypress e2e (headless Chrome)
npm run cypress:open     # Cypress interactive mode

Contributing

Contributions are welcome. See CONTRIBUTING.md for coding standards and the PR process.

Learn More

Reference Description
NMState NMState project
OpenShift web console Web-based user interface for OpenShift
OpenShift Dynamic Plugin SDK Dynamic plugin SDK for OpenShift user interfaces
NMState documentation Usage documentation for NMState configuration
PatternFly Open-source design system used for OpenShift UI development

Credit

Inspired by forklift-console-plugin.