"Resource=networkpolicystats": feature NetworkPolicyStats disabled" error in Tanzu Kubernetes Grid Integrated Edition when Antrea CNI used
search cancel

"Resource=networkpolicystats": feature NetworkPolicyStats disabled" error in Tanzu Kubernetes Grid Integrated Edition when Antrea CNI used

book

Article ID: 298673

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Integrated Edition

Issue/Introduction

Tanzu Kubernetes Grid Integrated Edition (TKGI) v1.10 supports the Antrea CNI.

The Antrea CNI provides Kubernetes Network Policy support for non-NSX-T environments. 

In certain cases (eg. using Flux), customer needs NetworkPolicyStats to be enabled, but it fails with this error:
$ kubectl get networkpolicystats -A
Error from server (BadRequest): Unable to list "stats.antrea.tanzu.vmware.com/v1alpha1, Resource=networkpolicystats": feature NetworkPolicyStats disabled


Environment

Product Version: 1.10

Resolution

To work around this issue, you need to enable collecting and exposing NetworkPolicy statistics,. To do this, you need to edit the Antrea configmap and enable NetworkPolicyStats.


1. Edit the configmap with below command:

kubectl edit configmap -n kube-system antrea-config-xxxx


2. Make the change NetworkPolicyStats: false to NetworkPolicyStats: true in the Section antrea-agent.conf and antrea-controller.conf.


3. When finished, save the configuration (esc, :wq) and restart the Antrea pods with this command:

kubectl delete pods -n kube-system --selector app=antrea


4. Check if Controller and Agents are up and running with below command:

kubectl get pods -n kube-system --selector app=antrea

 

Note: The NetworkPolicyStats shows to be FALSE when the service instance VMs are recreated.