Skip to content

Commit

Permalink
Don't use webhooks for patching websites in load tests
Browse files Browse the repository at this point in the history
Webhooks add a tremendous amount of latency to API calls, especially during load tests when the kyverno admission controller is overloaded.
High latency of API calls extremely decreases the operator's reconciliation rate which makes it difficult to achieve the desired load.
We are not load testing kyverno or the API server's webhook machinery, so get that off the critical path.
  • Loading branch information
timebertt committed Sep 4, 2023
1 parent 3ee0acf commit 5896d82
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<module name="kubernetes-controller-sharding" />
<working_directory value="$PROJECT_DIR$/webhosting-operator" />
<envs>
<env name="KUBECONFIG" value="$PROJECT_DIR$/webhosting-operator/dev/kind_kubeconfig.yaml" />
<env name="LEADER_ELECT" value="false" />
<env name="SHARD_ID" value="webhosting-operator-0" />
<env name="SHARD_MODE" value="sharder" />
<env name="SHARD_MODE" value="both" />
<env name="SHARDING_ENABLED" value="true" />
<env name="KUBECONFIG" value="$PROJECT_DIR$/webhosting-operator/dev/kind_kubeconfig.yaml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/timebertt/kubernetes-controller-sharding/webhosting-operator/cmd/webhosting-operator" />
Expand Down
3 changes: 1 addition & 2 deletions webhosting-operator/config/policy/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- websites-experiment.yaml
resources: []
42 changes: 0 additions & 42 deletions webhosting-operator/config/policy/default/websites-experiment.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -597,3 +610,7 @@ func GetDeploymentCondition(conditions []appsv1.DeploymentCondition, conditionTy
}
return nil
}

func isGeneratedByExperiment(obj client.Object) bool {
return obj.GetLabels()["generated-by"] == "experiment"
}

0 comments on commit 5896d82

Please sign in to comment.