Fail to execute CF commands with error "This command requires Network Policy API V1. Your targeted endpoint does not expose it." returned
search cancel

Fail to execute CF commands with error "This command requires Network Policy API V1. Your targeted endpoint does not expose it." returned

book

Article ID: 298330

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

After switching CF-CLI version, especially when CF-CLI v6 is involved, it may fail to execute network-policy related commands including "cf network-policies" and "cf add-network-policy".
# When CF-CLI version is set as v6, "cf network-policies" command can be ran successfully
$ brew unlink cf-cli@8 && brew unlink cf-cli@6 && brew link cf-cli@6 && cf version
cf version 6.53.0+8e2b70a4a.2020-10-01

$ cf network-policies
Listing network policies in org system / space system as admin...

source   destination   protocol   ports   destination space   destination org

# After CF-CLI version is switched to v8, command "cf network-policies" fails to run
$ brew unlink cf-cli@6 && brew unlink cf-cli@8 && brew link cf-cli@8 && cf version

$ cf network-policies
This command requires Network Policy API V1. Your targeted endpoint does not expose it.
FAILED


Environment

Product Version: 2.11

Resolution

When network-policy related commands are executed, the request will call /networking/v1/external/policies endpoint.

  • Part of "CF_TRACE=true cf add-network-policy" command output:
REQUEST: [2022-10-21T09:53:10+09:00]
POST /networking/v1/external/policies HTTP/1.1
  • However, after switching the CF-CLI version, the value for "NetworkPolicyV1Endpoint" could be null, which triggers the error message "This command requires Network Policy API V1. Your targeted endpoint does not expose it."
$ cat ~/.cf/config.json | grep NetworkPolicyV1Endpoint
  "NetworkPolicyV1Endpoint": "",
  • To work around the issue, add the proper value for "NetworkPolicyV1Endpoint" in .cf/config.json file.
$ vi ~/.cf/config.json
$ cat ~/.cf/config.json | grep NetworkPolicyV1Endpoint
  "NetworkPolicyV1Endpoint": "https://api.run-##.####-##.#####-###-###.######.com/networking/v1/external",

$ cf network-policies
Listing network policies in org system / space system as admin...

source   destination   protocol   ports   destination space   destination org