@@ -20,7 +20,6 @@ import (
20
20
networkingv1 "k8s.io/api/networking/v1"
21
21
rbacv1 "k8s.io/api/rbac/v1"
22
22
apierrors "k8s.io/apimachinery/pkg/api/errors"
23
- "k8s.io/apimachinery/pkg/api/resource"
24
23
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
24
"k8s.io/apimachinery/pkg/types"
26
25
@@ -514,70 +513,14 @@ func (k *K8sInstaller) generateConfigMap() (*corev1.ConfigMap, error) {
514
513
return & cm , nil
515
514
}
516
515
517
- func (k * K8sInstaller ) deployResourceQuotas (ctx context.Context ) error {
518
- k .Log ("🚀 Creating Resource quotas..." )
519
-
520
- ciliumResourceQuota := & corev1.ResourceQuota {
521
- ObjectMeta : metav1.ObjectMeta {
522
- Name : defaults .AgentResourceQuota ,
523
- },
524
- Spec : corev1.ResourceQuotaSpec {
525
- Hard : corev1.ResourceList {
526
- // 5k nodes * 2 DaemonSets (Cilium and cilium node init)
527
- corev1 .ResourcePods : resource .MustParse ("10k" ),
528
- },
529
- ScopeSelector : & corev1.ScopeSelector {
530
- MatchExpressions : []corev1.ScopedResourceSelectorRequirement {
531
- {
532
- ScopeName : corev1 .ResourceQuotaScopePriorityClass ,
533
- Operator : corev1 .ScopeSelectorOpIn ,
534
- Values : []string {"system-node-critical" },
535
- },
536
- },
537
- },
538
- },
539
- }
540
-
541
- if _ , err := k .client .CreateResourceQuota (ctx , k .params .Namespace , ciliumResourceQuota , metav1.CreateOptions {}); err != nil {
542
- return err
543
- }
544
- k .pushRollbackStep (func (ctx context.Context ) {
545
- if err := k .client .DeleteResourceQuota (ctx , k .params .Namespace , defaults .AgentResourceQuota , metav1.DeleteOptions {}); err != nil {
546
- k .Log ("Cannot delete %s ResourceQuota: %s" , defaults .AgentResourceQuota , err )
547
- }
548
- })
549
-
550
- operatorResourceQuota := & corev1.ResourceQuota {
551
- ObjectMeta : metav1.ObjectMeta {
552
- Name : defaults .OperatorResourceQuota ,
553
- },
554
- Spec : corev1.ResourceQuotaSpec {
555
- Hard : corev1.ResourceList {
556
- // 15 "clusterwide" Cilium Operator pods for HA
557
- corev1 .ResourcePods : resource .MustParse ("15" ),
558
- },
559
- ScopeSelector : & corev1.ScopeSelector {
560
- MatchExpressions : []corev1.ScopedResourceSelectorRequirement {
561
- {
562
- ScopeName : corev1 .ResourceQuotaScopePriorityClass ,
563
- Operator : corev1 .ScopeSelectorOpIn ,
564
- Values : []string {"system-cluster-critical" },
565
- },
566
- },
567
- },
568
- },
569
- }
570
-
571
- if _ , err := k .client .CreateResourceQuota (ctx , k .params .Namespace , operatorResourceQuota , metav1.CreateOptions {}); err != nil {
572
- return err
516
+ func (k * K8sInstaller ) generateResourceQuotas () []* corev1.ResourceQuota {
517
+ resoureceQuotasFilename := "templates/cilium-resource-quota.yaml"
518
+ resourceQuotasFile , exists := k .manifests [resoureceQuotasFilename ]
519
+ if ! exists {
520
+ return nil
573
521
}
574
- k .pushRollbackStep (func (ctx context.Context ) {
575
- if err := k .client .DeleteResourceQuota (ctx , k .params .Namespace , defaults .OperatorResourceQuota , metav1.DeleteOptions {}); err != nil {
576
- k .Log ("Cannot delete %s ResourceQuota: %s" , defaults .OperatorResourceQuota , err )
577
- }
578
- })
579
-
580
- return nil
522
+ resourceQuotas := utils.MustUnmarshalYAMLMulti [* corev1.ResourceQuota ]([]byte (resourceQuotasFile ))
523
+ return resourceQuotas
581
524
}
582
525
583
526
func (k * K8sInstaller ) restartUnmanagedPods (ctx context.Context ) error {
@@ -729,11 +672,6 @@ func (k *K8sInstaller) Install(ctx context.Context) error {
729
672
}
730
673
}
731
674
}
732
- case k8s .KindGKE :
733
- // TODO(aanm) automate this as well in form of helm chart
734
- if err := k .deployResourceQuotas (ctx ); err != nil {
735
- return err
736
- }
737
675
738
676
case k8s .KindAKS :
739
677
// We only made the secret-based azure installation available in >= 1.12.0
@@ -760,6 +698,19 @@ func (k *K8sInstaller) Install(ctx context.Context) error {
760
698
}
761
699
}
762
700
701
+ resourceQuotas := k .generateResourceQuotas ()
702
+ for _ , resourceQuota := range resourceQuotas {
703
+ k .Log ("🚀 Creating resource quota %s..." , resourceQuota .Name )
704
+ if _ , err := k .client .CreateResourceQuota (ctx , k .params .Namespace , resourceQuota , metav1.CreateOptions {}); err != nil {
705
+ return err
706
+ }
707
+ k .pushRollbackStep (func (ctx context.Context ) {
708
+ if err := k .client .DeleteResourceQuota (ctx , k .params .Namespace , resourceQuota .Name , metav1.DeleteOptions {}); err != nil {
709
+ k .Log ("Cannot delete %s ResourceQuota: %s" , resourceQuota .Name , err )
710
+ }
711
+ })
712
+ }
713
+
763
714
k .Log ("🚀 Creating Service accounts..." )
764
715
if _ , err := k .client .CreateServiceAccount (ctx , k .params .Namespace , k .NewServiceAccount (defaults .AgentServiceAccountName ), metav1.CreateOptions {}); err != nil {
765
716
return err
0 commit comments