diff --git a/webhosting-operator/.run/webhosting-operator process (kind).run.xml b/webhosting-operator/.run/webhosting-operator process (kind).run.xml
index 7632fb8f..2deca6af 100644
--- a/webhosting-operator/.run/webhosting-operator process (kind).run.xml
+++ b/webhosting-operator/.run/webhosting-operator process (kind).run.xml
@@ -3,10 +3,11 @@
-
-
+
+
+
diff --git a/webhosting-operator/config/policy/default/kustomization.yaml b/webhosting-operator/config/policy/default/kustomization.yaml
index b3a9f1db..e609fb24 100644
--- a/webhosting-operator/config/policy/default/kustomization.yaml
+++ b/webhosting-operator/config/policy/default/kustomization.yaml
@@ -1,5 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
-resources:
-- websites-experiment.yaml
+resources: []
diff --git a/webhosting-operator/config/policy/default/websites-experiment.yaml b/webhosting-operator/config/policy/default/websites-experiment.yaml
deleted file mode 100644
index ae374736..00000000
--- a/webhosting-operator/config/policy/default/websites-experiment.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-apiVersion: kyverno.io/v1
-kind: ClusterPolicy
-metadata:
- name: websites-experiment
-spec:
- failurePolicy: Fail
- rules:
- # don't actually run website pods in load tests
- # otherwise, we would need an immense amount of compute power for running dummy websites
- - name: scale-down-websites
- match:
- any:
- - resources:
- kinds:
- - Deployment
- selector:
- matchLabels:
- app: website
- namespaceSelector:
- matchLabels:
- generated-by: experiment
- mutate:
- patchStrategicMerge:
- spec:
- replicas: 0
- # use fake ingress class to prevent overloading ingress controller (this is not what we want to load test)
- - name: disable-ingress
- match:
- any:
- - resources:
- kinds:
- - Ingress
- selector:
- matchLabels:
- app: website
- namespaceSelector:
- matchLabels:
- generated-by: experiment
- mutate:
- patchStrategicMerge:
- spec:
- ingressClassName: fake
diff --git a/webhosting-operator/pkg/controllers/webhosting/website_controller.go b/webhosting-operator/pkg/controllers/webhosting/website_controller.go
index 468126ed..f5db6537 100644
--- a/webhosting-operator/pkg/controllers/webhosting/website_controller.go
+++ b/webhosting-operator/pkg/controllers/webhosting/website_controller.go
@@ -285,6 +285,13 @@ func (r *WebsiteReconciler) IngressForWebsite(serverName string, website *webhos
}}
applyIngressConfigToIngress(r.Config.Ingress, ingress)
+
+ if isGeneratedByExperiment(website) {
+ // don't actually expose website ingresses in load tests
+ // use fake ingress class to prevent overloading ingress controller (this is not what we want to load test)
+ ingress.Spec.IngressClassName = pointer.String("fake")
+ }
+
return ingress, ctrl.SetControllerReference(website, ingress, r.Scheme)
}
@@ -399,6 +406,12 @@ func (r *WebsiteReconciler) DeploymentForWebsite(serverName string, website *web
},
}
+ if isGeneratedByExperiment(website) {
+ // don't actually run website pods in load tests
+ // otherwise, we would need an immense amount of compute power for running dummy websites
+ deployment.Spec.Replicas = pointer.Int32(0)
+ }
+
return deployment, ctrl.SetControllerReference(website, deployment, r.Scheme)
}
@@ -597,3 +610,7 @@ func GetDeploymentCondition(conditions []appsv1.DeploymentCondition, conditionTy
}
return nil
}
+
+func isGeneratedByExperiment(obj client.Object) bool {
+ return obj.GetLabels()["generated-by"] == "experiment"
+}