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

support for using go plugin to register storage layer plugins #436

Merged
merged 4 commits into from
Nov 9, 2022

Conversation

Iceber
Copy link
Member

@Iceber Iceber commented Nov 1, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

  1. Add pkg/storage/plugins.go LoadPlugins function to load storage layer plugins
  2. Modify cmd/apiserver, cmd/binding-apiserver, cmd/clustersynchro-manager, read the plugin directory from the STORAGE_PLUGINS environment variable, and call storage.LoadPlugins
  3. Update the build flow to support the go plugin

Build flow with go plugin support

  1. Add builder.sh script for cgo to build clusterpedia components and plugins
$ ./hack/builder.sh

Build components:
    ./hack/builder.sh <apiserver|binding-apiserver|clustersynchro-manager|controller-manager>

Build plugins:
    ./hack/builder.sh plugins <plugin_name>

ENV:
    CLUSTERPEDIA_REPO: clusterpedia repo path, required if the pwd is not in the clusterpedia repository.
            eg. CLUSTERPEDIA_REPO=/clusterpedia

    PLUGIN_REPO: plugin repo path, required if the pwd is not the plugin repository.
            eg. CLUSTERPEDIA_REPO=/plugins/sample-storage-layer

    OUTPUT_DIR: default is the root of the repository or pwd,
                the component binary will be output in $OUTPUT_DIR/bin, the plugins will be output in $OUTPUT_DIR/plugins.
            eg. OUTPUT_DIR=.
  1. When building the image, to ensure that the clusterpedia component and plugin dependencies are consistent, we add a builder image that contains:
    • golang and arm64 cross-compiler package
    • clusterpedia repository code
    • builder.sh script
  1. Use the builder image as the Dockerfile for the base image
ARG BUILDER_IMAGE
ARG BASE_IMAGE
FROM --platform=$BUILDPLATFORM ${BUILDER_IMAGE} as builder
WORKDIR /clusterpedia

ARG BIN_NAME
ARG TARGETARCH
RUN GOARCH=${TARGETARCH} /builder.sh ${BIN_NAME}

FROM ${BASE_IMAGE}
RUN apk add --no-cache gcompat

ARG BIN_NAME
COPY --from=builder /clusterpedia/bin/${BIN_NAME} /usr/local/bin/${BIN_NAME}

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@clusterpedia-bot
Copy link

Hi @Iceber,
Thanks for your pull request!
If the PR is ready, use the /auto-cc command to assign Reviewer to Review.
We will review it shortly.

Details

Instructions for interacting with me using comments are available here.
If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.

@clusterpedia-bot clusterpedia-bot added the kind/feature New feature label Nov 1, 2022
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
@Iceber Iceber force-pushed the storage-plugin branch 2 times, most recently from b2c57b7 to f9d2973 Compare November 1, 2022 07:49
Makefile Outdated Show resolved Hide resolved
@Iceber Iceber force-pushed the storage-plugin branch 2 times, most recently from cc3efb4 to e9d888a Compare November 1, 2022 09:08
@Iceber
Copy link
Member Author

Iceber commented Nov 1, 2022

/label do-not-merge/hold

@Iceber Iceber force-pushed the storage-plugin branch 6 times, most recently from b74d81b to f377316 Compare November 1, 2022 12:20
@Iceber Iceber changed the title support for registering storage layer plugins support for using go plugin to register storage layer plugins Nov 1, 2022
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Nov 2, 2022
@Iceber Iceber force-pushed the storage-plugin branch 2 times, most recently from 52cb90c to faa1172 Compare November 2, 2022 02:40
@pull-request-size pull-request-size bot added size/L and removed size/XL labels Nov 2, 2022
@Iceber Iceber force-pushed the storage-plugin branch 4 times, most recently from 5daf3ad to 4a11079 Compare November 2, 2022 08:06
@Iceber Iceber force-pushed the storage-plugin branch 11 times, most recently from 72d5c20 to be909dd Compare November 2, 2022 10:54
@Iceber Iceber closed this Nov 2, 2022
@Iceber Iceber reopened this Nov 2, 2022
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
Makefile Outdated Show resolved Hide resolved
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
@wuyingjun-lucky
Copy link
Member

/assign

@wuyingjun-lucky
Copy link
Member

LGTM

@Iceber Iceber merged commit 29384a7 into clusterpedia-io:main Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants