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-manager
cnrm-controller-manager
cnrm-deletiondefender
cnrm-resource-stats-recorder
cnrm-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.yaml
and 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: 256Mi
Use
kubectl apply
to 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.healthy
field set totrue
.Verify that the new custom resource configuration has been applied to the
webhook
container.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.yaml
and 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: 256Mi
Use
kubectl apply
to 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.healthy
field 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