Install NMState Operator

  1. Create the nmstate Operator namespace:

    cat << EOF | oc apply -f -
    apiVersion: v1
    kind: Namespace
    metadata:
      labels:
        kubernetes.io/metadata.name: openshift-nmstate
        name: openshift-nmstate
      name: openshift-nmstate
    spec:
      finalizers:
      - kubernetes
    EOF
  2. Verify the namespace is created:

    oc get ns openshift-nmstate  -o custom-columns=Name:.metadata.name,Status:.status.phase
    Sample output
    Name                Status
    openshift-nmstate   Active
  3. Create the OperatorGroup:

    cat << EOF | oc apply -f -
    apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      annotations:
        olm.providedAPIs: NMState.v1.nmstate.io
      name: openshift-nmstate
      namespace: openshift-nmstate
    spec:
      targetNamespaces:
      - openshift-nmstate
    EOF
  4. Confirm the OperatorGroup is installed in the namespace:

    oc get operatorgroup -n openshift-nmstate
    Sample output
    NAME                AGE
    openshift-nmstate   5s
  5. Subscribe to the nmstate Operator:

    cat << EOF| oc apply -f -
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      labels:
        operators.coreos.com/kubernetes-nmstate-operator.openshift-nmstate: ""
      name: kubernetes-nmstate-operator
      namespace: openshift-nmstate
    spec:
      channel: stable
      installPlanApproval: Automatic
      name: kubernetes-nmstate-operator
      source: redhat-operators
      sourceNamespace: openshift-marketplace
    EOF
  6. Confirm that NMstate operator is running. Repeat this command until you see the desired output:

    oc get clusterserviceversion -n openshift-nmstate  -o custom-columns=Name:.metadata.name,Phase:.status.phase
    Sample output
    Name                                              Phase
    kubernetes-nmstate-operator.4.13.0-202402211707   Succeeded

    Use below command to track the progress:

    while ! (oc get clusterserviceversion -n openshift-nmstate  -o custom-columns=Name:.metadata.name,Phase:.status.phase | grep kubernetes-nmstate-operator | grep Succeeded); do oc get clusterserviceversion -n openshift-nmstate; sleep 2; done
  7. Create instance of the nmstate operator:

    cat << EOF | oc apply -f -
    apiVersion: nmstate.io/v1
    kind: NMState
    metadata:
      name: nmstate
    EOF
  8. Confirm that the instance for the nmstate operator is created:

    oc get nmstates
    Sample output
    NAME      AGE
    nmstate   2s

Reference: see Installing the Kubernetes NMState Operator in the RHOCP Networking guide