cruise-automation / isopod

An expressive DSL and framework for Kubernetes configuration without YAML
Apache License 2.0
482 stars 32 forks source link

fix: app/v1 api group in kube fake #44

Closed cxuu closed 4 years ago

cxuu commented 4 years ago

Previously the Deployment resource is registered in the kube_fake's discovery client under two API groups: apps/v1 and extensions/v1beta1. Apparently, this leads to non-deterministic GVK inference from RESTMapper (https://github.com/cruise-automation/isopod/blob/master/pkg/kube/api.go#L59-L74).

The result is that kube.get(deployment="ns/myapp") maybe either of

GET /apis/apps/v1/namespaces/NS/deployments/myapp

or

GET /apis/extensions/v1beta1/namespaces/NS/deployments/myapp

but in the latter case, kube fake will return empty results (and fail the Starlark unit tests), because most users use the k8s.io.api.apps.v1 proto package to build a Deployment.