Stderr The apiservices "v1beta1.metrics.k8s.io" is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update
1. bosh -d service-instance_xxxx run-errand apply-addons --keep-alive
2. bosh ssh -d service-instance_xxxx <APPLY-ADDONS_VM>
3. sudo -i
4. cd /var/vcap/jobs/apply-specs/specs/metrics-server
5. Copy and attempt to manually apply the manifests in this directory for the metrics apiService to reproduce the error.
TKGi 1.x deployed environment using metrics server
When Kubernetes objects are exported manually using kubectl get <OBJECT> -o yaml and then reapplied without removing the resourceVersion or other object revision specific annotations this creates a new resource but with the old resourceVersion.
The reason behind the failure in TKGi, is that when an apply-addons errand runs it tries to patch the existing resources for metrics server. The addons VM will try patching the existing resources for metric apiService using configs located at /var/vcap/jobs/apply-specs/specs/metrics-server. The kubernetes API will compare the last-applied-configuration with the current yaml being patched, and send the changes. If there is an invalid resourceVersion in last-applied-configuration, it will send the resourceVersion value as null and not replace the old value, even though that resourceVersion chain is no longer valid. This will cause an error making changes to the kubernetes objects and the apply-addons job will fail.