About the Kubernetes NMState Operator

The Kubernetes NMState Operator provides a Kubernetes API for performing state-driven network configuration across the OKD cluster’s nodes with NMState. The Kubernetes NMState Operator provides users with functionality to configure various network interface types, DNS, and routing on cluster nodes. Additionally, the daemons on the cluster nodes periodically report on the state of each node’s network interfaces to the API server.

Red Hat supports the Kubernetes NMState Operator in production environments on bare-metal, IBM Power, IBM Z, LinuxONE, VMware vSphere, and OpenStack installations.

Before you can use NMState with OKD, you must install the Kubernetes NMState Operator.

Installing the Kubernetes NMState Operator

You can install the Kubernetes NMState Operator by using the web console or the CLI.

Installing the Kubernetes NMState Operator using the web console

You can install the Kubernetes NMState Operator by using the web console. After it is installed, the Operator can deploy the NMState State Controller as a daemon set across all of the cluster nodes.

Prerequisites

  • You are logged in as a user with cluster-admin privileges.

Procedure

  1. Select OperatorsOperatorHub.

  2. In the search field below All Items, enter nmstate and click Enter to search for the Kubernetes NMState Operator.

  3. Click on the Kubernetes NMState Operator search result.

  4. Click on Install to open the Install Operator window.

  5. Click Install to install the Operator.

  6. After the Operator finishes installing, click View Operator.

  7. Under Provided APIs, click Create Instance to open the dialog box for creating an instance of kubernetes-nmstate.

  8. In the Name field of the dialog box, ensure the name of the instance is nmstate.

    The name restriction is a known issue. The instance is a singleton for the entire cluster.

  9. Accept the default settings and click Create to create the instance.

Summary

Once complete, the Operator has deployed the NMState State Controller as a daemon set across all of the cluster nodes.

Installing the Kubernetes NMState Operator using the CLI

You can install the Kubernetes NMState Operator by using the OpenShift CLI (oc). After it is installed, the Operator can deploy the NMState State Controller as a daemon set across all of the cluster nodes.

Prerequisites

  • You have installed the OpenShift CLI (oc).

  • You are logged in as a user with cluster-admin privileges.

Procedure

  1. Create the nmstate Operator namespace:

    1. $ cat << EOF | oc apply -f -
    2. apiVersion: v1
    3. kind: Namespace
    4. metadata:
    5. labels:
    6. kubernetes.io/metadata.name: openshift-nmstate
    7. name: openshift-nmstate
    8. name: openshift-nmstate
    9. spec:
    10. finalizers:
    11. - kubernetes
    12. EOF
  2. Create the OperatorGroup:

    1. $ cat << EOF | oc apply -f -
    2. apiVersion: operators.coreos.com/v1
    3. kind: OperatorGroup
    4. metadata:
    5. annotations:
    6. olm.providedAPIs: NMState.v1.nmstate.io
    7. generateName: openshift-nmstate-
    8. name: openshift-nmstate-tn6k8
    9. namespace: openshift-nmstate
    10. spec:
    11. targetNamespaces:
    12. - openshift-nmstate
    13. EOF
  3. Subscribe to the nmstate Operator:

    1. $ cat << EOF| oc apply -f -
    2. apiVersion: operators.coreos.com/v1alpha1
    3. kind: Subscription
    4. metadata:
    5. labels:
    6. operators.coreos.com/kubernetes-nmstate-operator.openshift-nmstate: ""
    7. name: kubernetes-nmstate-operator
    8. namespace: openshift-nmstate
    9. spec:
    10. channel: stable
    11. installPlanApproval: Automatic
    12. name: kubernetes-nmstate-operator
    13. source: redhat-operators
    14. sourceNamespace: openshift-marketplace
    15. EOF
  4. Create instance of the nmstate operator:

    1. $ cat << EOF | oc apply -f -
    2. apiVersion: nmstate.io/v1
    3. kind: NMState
    4. metadata:
    5. name: nmstate
    6. EOF

Verification

  • Confirm that the deployment for the nmstate operator is running:

    1. oc get clusterserviceversion -n openshift-nmstate \
    2. -o custom-columns=Name:.metadata.name,Phase:.status.phase

    Example output

    1. Name Phase
    2. kubernetes-nmstate-operator.4.12.0-202210210157 Succeeded