OpenWhisk PHP动作创建失败:kind 'php:7.3'不在支持集合中
Looks like your OpenWhisk deployment doesn’t support the PHP 7.3 runtime natively—hence the error listing only Node.js-related kinds, blackbox, and sequence as valid options. Let’s walk through the solutions based on your setup:
Why This Happens
OpenWhisk relies on pre-configured runtime "kinds" to execute actions. If your instance (whether self-hosted or a managed service) hasn’t been set up with the PHP runtime, it won’t recognize php:7.3 as a valid kind.
Solution 1: Add PHP Runtime to Self-Hosted OpenWhisk
If you’re running your own OpenWhisk instance (e.g., locally with Docker), you can add the PHP 7.3 runtime manually:
- Grab the official PHP runtime image:
apache/openwhisk-runtime-php:7.3 - Deploy this runtime to your OpenWhisk cluster. For most setups, this involves updating the platform’s runtime catalog or using
wskadmincommands to register the new kind. - Once registered, re-run your original command:
wsk action create helloPHP hello.php --kind php:7.3
Solution 2: Use Blackbox Mode (For Managed Services or Missing Runtime)
If you’re using a managed OpenWhisk service that doesn’t offer PHP runtimes, or can’t modify your self-hosted instance, use the blackbox kind to package your PHP code in a custom Docker image:
Step 1: Prepare Your PHP Code
Update your hello.php to handle input/output properly for blackbox mode (OpenWhisk sends parameters via stdin and expects JSON output to stdout):
<?php function main(array $args): array { $name = $args["name"] ?? "stranger"; $greeting = "Hello $name!"; return ["greeting" => $greeting]; } // Read input from stdin, execute main, output JSON result $input = json_decode(file_get_contents('php://stdin'), true); $result = main($input); echo json_encode($result); ?>
Step 2: Create a Dockerfile
Create a Dockerfile to build a PHP 7.3 environment with your script:
FROM php:7.3-cli WORKDIR /action COPY hello.php . CMD ["php", "hello.php"]
Step 3: Build and Push the Image
Build the image and push it to a Docker registry (like Docker Hub):
docker build -t your-username/php-hello:7.3 . docker push your-username/php-hello:7.3
Step 4: Create the OpenWhisk Action
Use the blackbox kind to create your action with the custom image:
wsk action create helloPHP --docker your-username/php-hello:7.3
Verify the Action
Test your action to make sure it works:
wsk action invoke helloPHP --param name "Rakesh" --result
You should get back:
{ "greeting": "Hello Rakesh!" }
内容的提问来源于stack exchange,提问作者Rakesh Jesadiya

