The information contained in this article has been verified as up-to-date on the date of the original publication of the article. HashiCorp endeavors to keep this information up-to-date and correct, but it makes no representations or warranties of any kind, express or implied, about the ongoing completeness, accuracy, reliability, or suitability of the information provided.
All information contained in this article is for general information purposes only. Any reliance you place on such information as it applies to your use of your HashiCorp product is therefore strictly at your own risk.
Introduction
This is a guide to demonstrate how to increase CPU and memory resources in connect-inject pods. The initial Helm chart defaults for the Consul containers are a bare minimum requirement to get Consul containers up and running for a multitude of environments, and Kubernetes resource tuning may be necessary to better suit your environment's needs as seen below.
Expected Outcome
Increasing the default resource of Consul connect-inject pod will provide faster service registration and discovery times in the Envoy sidecar.
Prerequisites
- Administrative privileges in K8s namespace for Consul
- Make sure connect-inject enabled
- For additional information review How does Consul Service Mesh Work on Kubernetes?
Use Case
In the event, there are high delays during Envoy service registration and discovery, and if any performance increase is to occur, the resources allocated to this component should help improve your case.
Procedure
Below are two types of procedures to adjust Memory and CPU on connect-inject pods.
Adjust the CPU/memory on the connect-inject deployment replicaSet
- Get the connect-inject deployment.
$ kubectl get deployment consul-connect-injector -n consul
NAME READY UP-TO-DATE AVAILABLE AGE
consul-connect-injector 1/1 1 1 47m - Edit the consul-connect-injector deployment.
$ kubectl edit deployment consul-connect-injector -n consul
- Adjust "resources" for cpu and memory to desired limits. Increments of 50 are acceptable.
resources:
limits:
cpu: 200m
memory: 150Mi
requests:
cpu: 100m
memory: 100Mi - Save the file and run the command to see the new connect-inject pod coming up with desired resources.
kubectl get pods -n consul
Adjust the CPU/memory on the connect-inject pod using the helm upgrade command
- Create a values.yaml file with desired CPU/Memory values using your favorite editor e.g VIM.
connectInject:
enabled: true
resources:
requests:
memory: "100Mi"
cpu: "100m"
limits:
memory: "150Mi"
cpu: "200m" - Use the helm command to upgrade with new values with your consul-k8s version.
helm upgrade consul hashicorp/consul -n consul -f values.yaml --version '1.1.0'
- Run the command to see the new connect-inject pod coming up with desired resources.
kubectl get pods -n consul
- Additionally, we can increase metrics for sidecarProxy and Connect injected init container with helm upgrade command using the below yaml.
connectInject:
initContainer:
resources:
requests:
memory: "150Mi"
cpu: "150m"
limits:
memory: "200Mi"
cpu: "200m"
sidecarProxy: #specific to envoy sidecars when scaling
resources:
requests:
memory: "100Mi"
cpu: "100m"
limits:
memory: "100Mi"
cpu: "100m"
More information about these metrics can be found in the following article: Service Mesh Registration Time Tuning - Consul K8s Control Plane Resources.
References
- Kubernetes site for kubectl edit
- Service Mesh Registration Time Tuning - Consul K8s Control Plane Resources