Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add openfunction plugin #7634

Merged
merged 79 commits into from
Sep 2, 2022
Merged

feat: add openfunction plugin #7634

merged 79 commits into from
Sep 2, 2022

Conversation

jackkkkklee
Copy link
Contributor

Description

support openfunction serverless platform
implement proposal #7404

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@jackkkkklee jackkkkklee changed the title add openfunction plugin feat: add openfunction plugin Aug 9, 2022
end


function _M.access(conf, ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And code in init.lua, you can refer to azure-function for the detail.

}

set_container_registry_secret() {
REGISTRY_SERVER=https://index.docker.io/v1/ REGISTRY_USER=apisixtestaccount123 REGISTRY_PASSWORD=apisixtestaccount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use this? We can push the docker images through kind load docker-image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part of the openfuction building lifecycle, pushing the image to a registry, needs it.Will it be better to build locally to avoid this part?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should avoid exposing your secrets here. By the way, is this for building openfunction itself or the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure,for the function.
I 'll avoid it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a lighter way (using less runtime memory) to run these services? I'm worried that running these services will again fill up the memory of the server where github action is running CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to just run the function locally in docker with the image I created by openfunction platform previously,which doesn't need to install many services. I'll update it after test.

docs/en/latest/plugins/openfunction.md Outdated Show resolved Hide resolved

## Enabling the Plugin

Before configuring the Plugin, you need to have OpenFunction running. The example below shows OpenFunction installed in Helm:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also give a link to the installation page of OpenFunction.

docs/en/latest/plugins/openfunction.md Outdated Show resolved Hide resolved
jackkkkklee and others added 5 commits August 10, 2022 10:47
Co-authored-by: Alex Zhang <tokers@apache.org>
Co-authored-by: Alex Zhang <tokers@apache.org>
@tokers
Copy link
Contributor

tokers commented Aug 11, 2022

@jackkkkklee Please make the CI pass. Thanks!

docs/en/latest/plugins/openfunction.md Outdated Show resolved Hide resolved
docs/en/latest/plugins/openfunction.md Outdated Show resolved Hide resolved
local function request_processor(conf, ctx, params)
local headers = params.headers or {}
-- setting authorization headers if not already set
if not headers["Authorization"] and conf.authorization
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the header here need to be lower-case? And we need a test case that the user-specific Authorization header has higher priority.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminding.
Lower-case for headers is needed if you mean the local param 'headers', or you mean the header of docs above?

Test case added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local param headers.

local function request_processor(conf, ctx, params)
local headers = params.headers or {}
-- setting authorization headers if not already set
if not headers["Authorization"] and conf.authorization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local param headers.

@@ -41,3 +41,13 @@ docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin updateTopic

# prepare vault kv engine
docker exec -i vault sh -c "VAULT_TOKEN='root' VAULT_ADDR='http://0.0.0.0:8200' vault secrets enable -path=kv -version=1 kv"

# prepare openfunction env
docker pull apisixtestaccount123/sample-go-func:v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if OpenFunction releases some sample functions 🤔.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do, but the functions just print the URI of request, which doesn't meet my test cases(e.g. test body, test headers). Therefore, I just fork and change their functions a little bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we expose the Dockerfile for apisixtestaccount123/sample-go-func:v1?
My concern is that when we want to make updates based on this image later, then it will be difficult for us to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ‘ll add local function building process latter,then we just need to update the code of repositories.

jackkkkklee and others added 12 commits August 25, 2022 11:38
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
@jackkkkklee
Copy link
Contributor Author

@tokers Could you please rerun ”CI / build (ubuntu-20.04, linux_openresty, t/node t/pubsub t/router t/script t/stream-node t/utils t/w... (pull_request) Failing after 17m...“?

@tzssangglass
Copy link
Member

Could you please rerun ”CI / build (ubuntu-20.04, linux_openresty, t/node t/pubsub t/router t/script t/stream-node t/utils t/w... (pull_request) Failing after 17m...“?

done

tokers
tokers previously approved these changes Aug 30, 2022
@@ -41,3 +41,4 @@ docker exec -i rmqnamesrv /home/rocketmq/rocketmq-4.6.0/bin/mqadmin updateTopic

# prepare vault kv engine
docker exec -i vault sh -c "VAULT_TOKEN='root' VAULT_ADDR='http://0.0.0.0:8200' vault secrets enable -path=kv -version=1 kv"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to touch this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No,we don't . I just run the function image in the dockerfile . And I ’ll discard the change in this file .

docs/en/latest/plugins/openfunction.md Outdated Show resolved Hide resolved
Co-authored-by: 罗泽轩 <spacewanderlzx@gmail.com>
LCW added 4 commits August 31, 2022 14:41
� Conflicts:
�	ci/pod/docker-compose.plugin.yml
�	docs/en/latest/config.json
�	docs/zh/latest/config.json
@spacewander spacewander merged commit 47187fa into apache:master Sep 2, 2022
hongbinhsu pushed a commit to fitphp/apix that referenced this pull request Sep 10, 2022
* upstream/master: (214 commits)
  feat: set constants.apisix_lua_home for used by plugins (apache#7893)
  fix: response-rewrite plugin might cause Apache AIPSIX hanging (apache#7836)
  test: sleep 1 second in t/cli/test_upstream_mtls.sh (apache#7889)
  fix: reload once when log rotate (apache#7869)
  change: move etcd conf under deployment (apache#7860)
  fix: plugin metadata missing v3 adapter call (apache#7877)
  docs: add ClickHouse and Elasticsearch loggers. (apache#7848)
  docs(plugin): refactor limit-conn.md (apache#7857)
  feat: call `destroy` method when Nginx exits (apache#7866)
  feat: Add ability to inject headers via prefix to otel traces (apache#7822)
  docs(plugin): refactor proxy-cache.md (apache#7858)
  fix: don't enable passive healthcheck by default (apache#7850)
  feat: add openfunction plugin (apache#7634)
  fix(zipkin): send trace IDs with a reject sampling decision (apache#7833)
  fix: Change opentelemetry's span kind to server (apache#7830)
  docs(hmac-auth): additional details for generating signing_string (apache#7816)
  docs: correct the test-nginx description (apache#7818)
  docs: add docs of workflow plugin (apache#7813)
  docs(FAQ): add how to detect APISIX alive status (apache#7812)
  feat: add elasticsearch-logger (apache#7643)
  ...
Liu-Junlin pushed a commit to Liu-Junlin/apisix that referenced this pull request Nov 4, 2022
Co-authored-by: Alex Zhang <tokers@apache.org>
Co-authored-by: 罗泽轩 <spacewanderlzx@gmail.com>
Co-authored-by: Fei Han <97138894+hf400159@users.noreply.github.com>
Co-authored-by: LCW <Lcw769193516@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants