{{- if or .Values.resourceQuotas.enabled (and (ne .Release.Namespace "kube-system") .Values.gke.enabled) }}
apiVersion: v1
kind: ResourceQuota
metadata:
  name: cilium-resource-quota
  namespace: {{ .Release.Namespace }}
spec:
  hard:
    pods: {{ .Values.resourceQuotas.cilium.hard.pods | quote }}
  scopeSelector:
    matchExpressions:
    - operator: In
      scopeName: PriorityClass
      values:
      - system-node-critical
---
apiVersion: v1
kind: ResourceQuota
metadata:
  name: cilium-operator-resource-quota
  namespace: {{ .Release.Namespace }}
spec:
  hard:
    pods: {{ .Values.resourceQuotas.operator.hard.pods | quote }}
  scopeSelector:
    matchExpressions:
    - operator: In
      scopeName: PriorityClass
      values:
      - system-cluster-critical
{{- end }}

{{- if or .Values.resourceQuotas.enabled (and (ne .Release.Namespace "kube-system") .Values.gke.enabled) }}
{{- if .Values.agent }}
apiVersion: v1
kind: ResourceQuota
metadata:
  name: cilium-resource-quota
  namespace: {{ .Release.Namespace }}
spec:
  hard:
    pods: {{ .Values.resourceQuotas.cilium.hard.pods | quote }}
  scopeSelector:
    matchExpressions:
    - operator: In
      scopeName: PriorityClass
      values:
      - system-node-critical
{{- end }}
{{- if .Values.operator.enabled }}
---
apiVersion: v1
kind: ResourceQuota
metadata:
  name: cilium-operator-resource-quota
  namespace: {{ .Release.Namespace }}
spec:
  hard:
    pods: {{ .Values.resourceQuotas.operator.hard.pods | quote }}
  scopeSelector:
    matchExpressions:
    - operator: In
      scopeName: PriorityClass
      values:
      - system-cluster-critical
{{- end }}
{{- end }}

Fix preflight check resource quota conflict
helm: Fix preflight check resource quota conflict

This commit fixes the preflight check on GKE which currently conflicts
with the resource quotas that may be present from an already installed
Cilium version:

```
Error: rendered manifests contain a resource that already exists. Unable
to continue with install: existing resource conflict: kind:
ResourceQuota, namespace: cilium, name: cilium-resource-quota
```

Fixes: 14ff743b5bb6 ("gke: add resource quotas for Cilium namespace")

Signed-off-by: Sebastian Wicki <db043b2055cb3a47b2eb0b5aebf4e114a8c24a5a@isovalent.com>
