如何提升Kubernetes集群部署的OpenWhisk函数最大内存限制
Absolutely! You can totally tweak that memory limit to whatever value you need—this restriction is controlled by a configuration setting in OpenWhisk's controller component. Let me break down exactly how to make this change:
1. Understand the Configuration Property
The memory threshold you're hitting is set by the actions.container.maxMemory property in OpenWhisk's controller config. The default value is 512MB (which equals 536870912 bytes, matching the error message you saw). You can update this to any value that makes sense for your use case.
2. Update the Controller's ConfigMap (Kubernetes Manifests)
If you deployed OpenWhisk using raw Kubernetes manifests or a standard setup, the controller's config lives in a ConfigMap:
- First, find the relevant ConfigMap in your OpenWhisk namespace (replace
<your-openwhisk-namespace>with your actual namespace):
Look for a ConfigMap named something likekubectl get configmaps -n <your-openwhisk-namespace>owdev-controller-config(the exact name depends on your deployment's prefix). - Edit the ConfigMap to update the memory limit:
kubectl edit configmap <controller-config-map-name> -n <your-openwhisk-namespace> - In the
whisk.propertiessection of the ConfigMap, add or modify the line:
For example, to set a 1GB limit, useactions.container.maxMemory=<your-desired-value-in-bytes>1073741824(102410241024). Some versions support human-readable suffixes like1g, but using raw bytes is the most reliable approach across all OpenWhisk versions.
3. Restart the Controller Pods
The controller needs to pick up the new config, so you'll need to restart its pods:
- Find the controller pods:
kubectl get pods -n <your-openwhisk-namespace> | grep controller - Either delete the existing pods (the deployment will automatically spin up new ones with the updated config):
Or trigger a deployment rollout for a cleaner restart:kubectl delete pod <controller-pod-name> -n <your-openwhisk-namespace>kubectl rollout restart deployment <controller-deployment-name> -n <your-openwhisk-namespace>
4. Verify the Change
Test creating an action with your new memory limit to confirm it works:
wsk action create testAction test.js --memory 1024
This should now succeed without hitting the threshold error.
If You Used Helm to Deploy
If you deployed OpenWhisk via Helm, you can set this value directly in your values.yaml file:
controller: env: whisk: actions: container: maxMemory: 1073741824
Then apply the change by upgrading your Helm release:
helm upgrade <your-helm-release-name> openwhisk/openwhisk -n <your-openwhisk-namespace> -f values.yaml
A quick heads-up: Make sure your Kubernetes cluster has enough available memory across its nodes to support the higher limits you set—otherwise, your function pods might fail to schedule.
内容的提问来源于stack exchange,提问作者pulasthi

