k8scontainerrequests
Basic Information
Function
This policy requires the CPU and memory Request be set and less than the configured maximum value.
Policy Example
This policy instance shows the Request configuration of CPU and memory.
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sContainerRequests metadata: name: container-must-have-requests spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] parameters: cpu: "200m" memory: "1Gi"
Resource Definition That Complies with the Policy
Request values of the CPU and memory are less than the configured maximum value, which complies with the policy instance.
apiVersion: v1 kind: Pod metadata: name: opa-allowed labels: owner: me.agilebank.demo spec: containers: - name: opa image: openpolicyagent/opa:0.9.2 args: - "run" - "--server" - "--addr=localhost:8080" resources: requests: cpu: "100m" memory: "1Gi"
Resource Definition That Does Not Comply with the Policy
The memory Request is greater than the maximum value, which does not comply with the policy instance.
apiVersion: v1 kind: Pod metadata: name: opa-disallowed labels: owner: me.agilebank.demo spec: containers: - name: opa image: openpolicyagent/opa:0.9.2 args: - "run" - "--server" - "--addr=localhost:8080" resources: requests: cpu: "100m" memory: "2Gi"
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot