<p>How can I apply this file to all namespaces:</p>
<pre><code>apiVersion: v1
kind: LimitRange
metadata:
  name: resource-limits
spec:
  limits:
    -
      type: Pod
      max:
        cpu: 1000m
        memory: 1Gi
      min:
        cpu: 500m
        memory: 500Mi
</code></pre>
<p>By default it gets applied to namespace I am into. I want to make this setting a common one</p>
<p>How can I do that. Make this a global setting.</p>

cloudbud
<p>This can be very easily done using an admission controller like <a href="https://kyverno.io/" rel="nofollow noreferrer">Kyverno</a>. Kyverno has &quot;<a href="https://kyverno.io/docs/writing-policies/generate/" rel="nofollow noreferrer">generate</a>&quot; capability which can be used to generate any Kubernetes resource based on a trigger (e.g. create namespace)</p>
<p>Here is an example of a Kyverno policy to achieve this.
<a href="https://kyverno.io/policies/best-practices/add_ns_quota/add_ns_quota/" rel="nofollow noreferrer">https://kyverno.io/policies/best-practices/add_ns_quota/add_ns_quota/</a></p>
<pre><code>apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: add-ns-quota
  annotations:
    policies.kyverno.io/title: Add Quota
    policies.kyverno.io/category: Multi-Tenancy
    policies.kyverno.io/subject: ResourceQuota, LimitRange
    policies.kyverno.io/description: &gt;-
      To better control the number of resources that can be created in a given
      Namespace and provide default resource consumption limits for Pods,
      ResourceQuota and LimitRange resources are recommended.
      This policy will generate ResourceQuota and LimitRange resources when
      a new Namespace is created.      
spec:
  rules:
  - name: generate-resourcequota
    match:
      resources:
        kinds:
        - Namespace
    generate:
      apiVersion: v1
      kind: ResourceQuota
      name: default-resourcequota
      synchronize: true
      namespace: &quot;{{request.object.metadata.name}}&quot;
      data:
        spec:
          hard:
            requests.cpu: '4'
            requests.memory: '16Gi'
            limits.cpu: '4'
            limits.memory: '16Gi'
  - name: generate-limitrange
    match:
      resources:
        kinds:
        - Namespace
    generate:
      apiVersion: v1
      kind: LimitRange
      name: default-limitrange
      synchronize: true
      namespace: &quot;{{request.object.metadata.name}}&quot;
      data:
        spec:
          limits:
          - default:
              cpu: 500m
              memory: 1Gi
            defaultRequest:
              cpu: 200m
              memory: 256Mi
            type: Container
</code></pre>
