Comparing Kubernetes Pod resource values

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: Client Version: version.Info{Major:“1”, Minor:“14”, GitVersion:“v1.14.3”, GitCommit:“5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0”, GitTreeState:“clean”, BuildDate:“2019-06-06T01:44:30Z”, GoVersion:“go1.12.5”, Compiler:“gc”, Platform:“darwin/amd64”}

Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:36:19Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

Cloud being used: bare-metal
Installation method: docker-desktop
Host OS: MacOS
CNI and version:
CRI and version:

Hello,

I am writing an admission controller where it is necessary for me to compare the Pod resource values set in the Yaml with a limit (say memory should not exceed 2 Gi) and then patch/refuse pod creation if more than that.
Is there an API available where I can do this comparison? Something that tells me that 200m < 1 (for CPU) or 900Mi < 1 Gi (for memory) Else, i have to strip out the “m” (for millicores) or the Mi (MB for memory) and then do the comparison. It gets tricky

On which language, with which lib or framework are you implementing your controller?

Hi Feloy,
Apologies for the delayed reply!
Implementing in GoLang, using the k8s.io/api/admission/v1beta1 APIs to implement the admission controller.

Thanks!