This is a cache of https://docs.openshift.com/container-platform/4.2/networking/multiple_networks/removing-pod.html. It is a snapshot of the page at 2025-02-08T02:15:02.875+0000.
Removing a <strong>pod</strong> from an additional network - Multiple networks | Networking | OpenShift Container Platform 4.2
×

As a cluster user you can remove a pod from an additional network.

Removing a pod from an additional network

You can remove a pod from an additional network.

Prerequisites
  • You have configured an additional network for your cluster.

  • You have an additional network attached to the pod.

  • Install the OpenShift Command-line Interface (CLI), commonly known as oc.

  • You must log in to the cluster.

Procedure

To remove a pod from an additional network, complete the following steps:

  1. Edit the pod resource definition by running the following command. Replace <name> with the name of the pod to edit.

    $ oc edit pod <name>
  2. Update the annotations mapping to remove the additional network from the pod by performing one of the following actions:

    • To remove all additional networks from a pod, remove the k8s.v1.cni.cncf.io/networks parameter from the pod resource definition as in the following example:

      apiVersion: v1
      kind: pod
      metadata:
        name: example-pod
        annotations: {}
      spec:
        containers:
        - name: example-pod
          command: ["/bin/bash", "-c", "sleep 2000000000000"]
          image: centos/tools
    • To remove a specific additional network from a pod, update the k8s.v1.cni.cncf.io/networks parameter by removing the name of the NetworkAttachmentDefinition for the additional network.

  3. Optional: Confirm that the pod is no longer attached to the additional network by running the following command. Replace <name> with the name of the pod.

    $ oc describe pod <name>

    In the following example, the example-pod pod is attached only to the default cluster network.

    $ oc describe pod example-pod
    
    Name:               example-pod
    ...
    Annotations:        k8s.v1.cni.cncf.io/networks-status:
                          [{
                              "name": "openshift-sdn",
                              "interface": "eth0",
                              "ips": [
                                  "10.131.0.13"
                              ],
                              "default": true, (1)
                              "dns": {}
                          }]
    Status:             Running
    ...
    1 Only the default cluster network is attached to the pod.