Manage NetworkPolicies

Updated at:

You can manage NetworkPolicies in the LHC console. This includes creating, updating, and deleting them.

Create a NetworkPolicy

  1. Log on to the LHC console. In the navigation pane on the left, click Cluster Management > Cluster Details.

  2. Click the name of the destination cluster. On the Cluster Details page, click the Workloads tab.

  3. In the left-side menu, choose Custom Resource Objects > NetworkPolicy, and then click Create NetworkPolicy.

  4. Enter the YAML content in the input box and click Submit.

    Example:

    kind: NetworkPolicy
    apiVersion: networking.k8s.io/v1
    metadata:
      name: allow-all-ingress-example
    spec:
      podSelector:
        matchLabels:
          run: nginx
      ingress:
      - from:
        - podSelector:
            matchLabels:
              access: "true"

Result

After the NetworkPolicy is created, the NetworkPolicy named allow-all-ingress-example appears in the list.

Related operations

  • To view the details of a NetworkPolicy, click its name in the list. On the details page, you can view the basic information and YAML configuration of the NetworkPolicy.

    1

  • To search for a NetworkPolicy, enter a keyword from its name in the search box in the upper-right corner of the list page. In this example, enter example. The search results are shown in the following figure.

  • To update a NetworkPolicy, click View/Edit in the Actions column of the list. Edit the YAML information in the Edit NetworkPolicy dialog box, and then click Submit.

  • To delete a NetworkPolicy, click Delete in the Actions column of the list. In the dialog box that appears, click OK.