Kubernetes Bad Request "must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'"
One fine evening, while refreshing my kubernetes concepts, I was trying to write a simple deployment with their resource limits. And I conjured up with this little yaml thing-y
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-resources
labels:
app: my-app-resources
spec:
replicas: 1
selector:
matchLabels:
app: my-app-resources
template:
metadata:
labels:
app: my-app-resources
spec:
containers:
- name: my-app-resources
image: nginx:latest
resources:
requests:
memory: "64Mib"
cpu: "250m"
limits:
memory: "128Mib"
cpu: "500m"
- name: logging-sidecar
image: busybox:1.28
command: ['sh', '-c', "while true; do echo sync app logs; sleep 10; done"]
resources:
requests:
memory: "128Mib"
cpu: "100m"
limits:
memory: "256Mib"
cpu: "200m"
Simple little thing, right! I tried deploying it and got the following beautiful error.
$ kubectl apply -f nginx-deployment-with-resource.yaml
Error from server (BadRequest): error when creating "nginx-deployment-with-resource.yaml": Deployment in version "v1" cannot be handled as a Deployment: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
And there begun my journey about losing my 10 precious minutes, I tried:-
validating the yaml. Looked fine.
Looked into different fields and found them generally okay.
After scratching my head for 10 mins, I realized that I have put the values for memory as "128 Mib" instead of the intended "128Mi". :(
Oh well, sometimes it pays to copy from the official documentation I guess.