Configure container resources and replicas
This pages describes how to configure container resources and replicas for controllers in Config Connector.
Configure resource allocation for a Config Connector controller container
In Config Connector version 1.106 and later, you can configure the CPU and memory (RAM) resources allocated to a container in a Config Connector controller Pod. You can configure the following controllers:
cnrm-webhook-managercnrm-controller-managercnrm-deletiondefendercnrm-resource-stats-recordercnrm-unmanaged-detector(Config Connector version 1.108 and later)
For example, you can configure the memory request and limit of the webhook
container of the cnrm-webhook-manager controller by creating and applying
the following example YAML file.
Create a file named
configure-webhook-manager.yamland copy the following YAML into it:apiVersion: customize.core.cnrm.cloud.google.com/v1beta1 kind: ControllerResource metadata: name: cnrm-webhook-manager spec: containers: - name: webhook resources: limits: memory: 512Mi requests: memory: 256MiUse
kubectl applyto apply the container resource configuration to your cluster:kubectl apply -f configure-webhook-manager.yaml
Verify the successful configuration by running the following command:
kubectl get controllerresource cnrm-webhook-manager -o jsonpath='{.status.healthy}'It should display
status.healthyfield set totrue.Verify that the new custom resource configuration has been applied to the
webhookcontainer.kubectl get deployment cnrm-webhook-manager -n cnrm-system -o jsonpath='{.spec.template.spec.containers[?(@.name=="webhook")].resources}'Creating and recreating the Pods could take a few minutes.
If Config Connector is configured to run in
namespaced mode, you must
use the NamespacedControllerResource custom resource to configure container
resources for the cnrm-controller-manager controller within your designated
namespace. The configuration of container resources for a namespaced controller
is enabled in Config Connector version 1.108 and later. The following YAML file
shows an example configuration:
apiVersion: customize.core.cnrm.cloud.google.com/v1beta1
kind: NamespacedControllerResource
metadata:
name: cnrm-controller-manager # name should not contain the namespace ID suffix
namespace: NAMESPACE
spec:
containers:
- name: manager
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
Replace NAMESPACE with the name of your namespace.
Configure replicas for a Config Connector controller Pod
In Config Connector version 1.107 and later, you can configure the number of
replicas for a Config Connector controller. You can only configure the
cnrm-webhook-manager.
For example, the following steps show how to configure the number of replicas
for the cnrm-webhook-manager controller to 3.
Create a file named
configure-webhook-manager.yamland copy the following YAML into it:apiVersion: customize.core.cnrm.cloud.google.com/v1beta1 kind: ControllerResource metadata: name: cnrm-webhook-manager spec: replicas: 3 containers: - name: webhook resources: limits: memory: 512Mi requests: memory: 256MiUse
kubectl applyto apply the modified configuration to your cluster:kubectl apply -f configure-webhook-manager.yaml
Verify the successful configuration by running the following command.
kubectl get controllerresource cnrm-webhook-manager -o jsonpath='{.status.healthy}'It should display
status.healthyfield set totrue.Verify the presence of 3 webhook Pods within your cluster.
kubectl get pods -n cnrm-system -l cnrm.cloud.google.com/component=cnrm-webhook-manager
Creating and recreating the Pods could take a few minutes.
Revert configuration changes in container resources and replicas
Use kubectl
delete
to delete the ControllerResource custom resources that you configured. After
deletion, the Config Connector operator recreates the controllers with the
default container resources and replicas.
kubectl delete -f configure-webhook-manager.yaml