├── .codecov.yml ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── failing-test.md │ ├── feature-request.md │ └── question.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── ci.yaml │ ├── e2e-test.yaml │ ├── release.yaml │ ├── sync-api.yaml │ └── sync-charts.yaml ├── .gitignore ├── .golangci.yaml ├── LICENSE ├── Makefile ├── OWNERS ├── README.md ├── charts └── yurt-app-manager │ ├── .helmignore │ ├── Chart.yaml │ ├── crds │ ├── apps.openyurt.io_nodepools.yaml │ ├── apps.openyurt.io_uniteddeployments.yaml │ ├── apps.openyurt.io_yurtappdaemons.yaml │ ├── apps.openyurt.io_yurtappsets.yaml │ └── apps.openyurt.io_yurtingresses.yaml │ ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── admission-webhooks │ │ ├── job-patch │ │ │ ├── clusterrole.yaml │ │ │ ├── clusterrolebinding.yaml │ │ │ ├── job-createSecret.yaml │ │ │ ├── job-patchWebhook.yaml │ │ │ ├── role.yaml │ │ │ ├── rolebinding.yaml │ │ │ └── serviceaccount.yaml │ │ ├── mutatingwebhookconfiguration.yaml │ │ ├── validatingwebhookconfiguration.yaml │ │ └── webhookService.yaml │ ├── clusterrole.yaml │ ├── clusterrolebinding.yaml │ ├── deployment.yaml │ ├── role.yaml │ ├── rolebinding.yaml │ ├── secret.yaml │ └── serviceaccount.yaml │ └── values.yaml ├── cmd └── yurt-app-manager │ ├── app-manager.go │ ├── app │ └── core.go │ └── options │ └── options.go ├── config └── yurt-app-manager │ ├── certmanager │ ├── certificate.yaml │ ├── kustomization.yaml │ └── kustomizeconfig.yaml │ ├── crd │ ├── bases │ │ ├── apps.openyurt.io_nodepools.yaml │ │ ├── apps.openyurt.io_uniteddeployments.yaml │ │ ├── apps.openyurt.io_yurtappdaemons.yaml │ │ ├── apps.openyurt.io_yurtappsets.yaml │ │ └── apps.openyurt.io_yurtingresses.yaml │ ├── kustomization.yaml │ ├── kustomizeconfig.yaml │ └── patches │ │ ├── cainjection_in_nodepools.yaml │ │ ├── cainjection_in_yurtappsets.yaml │ │ ├── cainjection_in_yurtingresses.yaml │ │ ├── webhook_in_nodepools.yaml │ │ ├── webhook_in_yurtappsets.yaml │ │ └── webhook_in_yurtingresses.yaml │ ├── default │ ├── kustomization.yaml │ ├── manager_auth_proxy_patch.yaml │ ├── manager_webhook_patch.yaml │ └── webhookcainjection_patch.yaml │ ├── manager │ ├── kustomization.yaml │ ├── manager.yaml │ └── patches.yaml │ ├── prometheus │ ├── kustomization.yaml │ └── monitor.yaml │ ├── rbac │ ├── auth_proxy_client_clusterrole.yaml │ ├── auth_proxy_role.yaml │ ├── auth_proxy_role_binding.yaml │ ├── auth_proxy_service.yaml │ ├── kustomization.yaml │ ├── leader_election_role.yaml │ ├── leader_election_role_binding.yaml │ ├── nodepool_editor_role.yaml │ ├── nodepool_viewer_role.yaml │ ├── role.yaml │ ├── role_binding.yaml │ ├── yurtappset_editor_role.yaml │ ├── yurtappset_viewer_role.yaml │ ├── yurtingress_editor_role.yaml │ └── yurtingress_viewer_role.yaml │ └── webhook │ ├── kustomization.yaml │ ├── kustomizeconfig.yaml │ ├── manifests.yaml │ ├── patch_manifests.yaml │ ├── secret.yaml │ └── service.yaml ├── docs ├── YurtAppDaemon.md ├── images │ ├── yurtappdaemon.png │ └── yurtappset.png ├── yurt-app-manager-dev-tutorial.md └── yurt-app-manager-tutorial.md ├── go.mod ├── go.sum ├── hack ├── dockerfiles │ └── Dockerfile ├── lib │ ├── build.sh │ ├── init.sh │ ├── sync-api.sh │ └── sync-charts.sh ├── make-rules │ ├── build-e2e.sh │ ├── build.sh │ ├── check_license.sh │ ├── generate_client.sh │ ├── genyaml.sh │ └── verify_mod.sh └── run-e2e-tests.sh ├── pkg ├── projectinfo │ └── projectinfo.go └── yurtappmanager │ ├── apis │ ├── addtoscheme_apps_v1alpha1.go │ ├── apis.go │ └── apps │ │ ├── v1alpha1 │ │ ├── defaults.go │ │ ├── doc.go │ │ ├── groupversion_info.go │ │ ├── nodepool_conversion.go │ │ ├── nodepool_types.go │ │ ├── uniteddeployment_types.go │ │ ├── well_known_labels_annotations.go │ │ ├── yurtappdaemon_types.go │ │ ├── yurtappset_types.go │ │ ├── yurtingress_types.go │ │ └── zz_generated.deepcopy.go │ │ └── v1beta1 │ │ ├── doc.go │ │ ├── groupversion_info.go │ │ ├── nodepool_conversion.go │ │ ├── nodepool_types.go │ │ └── zz_generated.deepcopy.go │ ├── client │ ├── clientset │ │ └── versioned │ │ │ ├── clientset.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ ├── clientset_generated.go │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ ├── scheme │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ └── typed │ │ │ └── apps │ │ │ └── v1alpha1 │ │ │ ├── apps_client.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ ├── doc.go │ │ │ ├── fake_apps_client.go │ │ │ ├── fake_nodepool.go │ │ │ ├── fake_uniteddeployment.go │ │ │ ├── fake_yurtappdaemon.go │ │ │ ├── fake_yurtappset.go │ │ │ └── fake_yurtingress.go │ │ │ ├── generated_expansion.go │ │ │ ├── nodepool.go │ │ │ ├── uniteddeployment.go │ │ │ ├── yurtappdaemon.go │ │ │ ├── yurtappset.go │ │ │ └── yurtingress.go │ ├── generic_client.go │ ├── informers │ │ └── externalversions │ │ │ ├── apps │ │ │ ├── interface.go │ │ │ └── v1alpha1 │ │ │ │ ├── interface.go │ │ │ │ ├── nodepool.go │ │ │ │ ├── uniteddeployment.go │ │ │ │ ├── yurtappdaemon.go │ │ │ │ ├── yurtappset.go │ │ │ │ └── yurtingress.go │ │ │ ├── factory.go │ │ │ ├── generic.go │ │ │ └── internalinterfaces │ │ │ └── factory_interfaces.go │ ├── listers │ │ └── apps │ │ │ └── v1alpha1 │ │ │ ├── expansion_generated.go │ │ │ ├── nodepool.go │ │ │ ├── uniteddeployment.go │ │ │ ├── yurtappdaemon.go │ │ │ ├── yurtappset.go │ │ │ └── yurtingress.go │ └── registry.go │ ├── constant │ ├── constant.go │ └── nginx-ingress-controller-tmpl.go │ ├── controller │ ├── controllers.go │ ├── nodepool │ │ ├── nodepool_controller.go │ │ ├── nodepool_controller_test.go │ │ ├── nodepool_enqueue_handler_test.go │ │ └── nodepool_enqueue_handlers.go │ ├── uniteddeployment │ │ ├── adapter │ │ │ ├── adapter.go │ │ │ ├── adapter_util.go │ │ │ ├── adapter_util_test.go │ │ │ ├── deployment_adapter.go │ │ │ ├── deployment_adapter_test.go │ │ │ ├── statefulset_adapter.go │ │ │ └── statefulset_adapter_test.go │ │ ├── pool.go │ │ ├── pool_control.go │ │ ├── pool_control_test.go │ │ ├── revision.go │ │ ├── revision_test.go │ │ ├── uniteddeployment_controller.go │ │ ├── uniteddeployment_controller_suite_test.go │ │ ├── uniteddeployment_controller_test.go │ │ ├── uniteddeployment_controller_utils.go │ │ ├── uniteddeployment_suite_test.go │ │ └── uniteddeployment_update.go │ ├── util │ │ └── statefulset_utils.go │ ├── yurtappdaemon │ │ ├── nodepool_enqueue_handlers.go │ │ ├── nodepool_enqueue_handlers_test.go │ │ ├── revision.go │ │ ├── revision_test.go │ │ ├── util.go │ │ ├── util_test.go │ │ ├── workloadcontroller │ │ │ ├── controller.go │ │ │ ├── deployment_controller.go │ │ │ ├── deployment_controller_test.go │ │ │ ├── statefulset_controller.go │ │ │ ├── util.go │ │ │ ├── util_test.go │ │ │ ├── workload.go │ │ │ └── workload_test.go │ │ ├── yurtappdaemon_controller.go │ │ └── yurtappdaemon_controller_test.go │ ├── yurtappset │ │ ├── adapter │ │ │ ├── adapter.go │ │ │ ├── adapter_util.go │ │ │ ├── adapter_util_test.go │ │ │ ├── deployment_adapter.go │ │ │ ├── deployment_adapter_test.go │ │ │ ├── statefulset_adapter.go │ │ │ └── statefulset_adapter_test.go │ │ ├── pool.go │ │ ├── pool_control.go │ │ ├── pool_controller_test.go │ │ ├── revision.go │ │ ├── revision_test.go │ │ ├── yurtappset_controller.go │ │ ├── yurtappset_controller_statefulset_test.go │ │ ├── yurtappset_controller_suite_test.go │ │ ├── yurtappset_controller_test.go │ │ ├── yurtappset_controller_utils.go │ │ └── yurtappset_update.go │ └── yurtingress │ │ ├── yurtingress_controller.go │ │ └── yurtingress_controller_test.go │ ├── hack │ ├── boilerplate.go.txt │ └── doc.go │ ├── util │ ├── fieldindex │ │ └── register.go │ ├── gate │ │ ├── custom_resource_gate.go │ │ └── custom_resource_gate_test.go │ ├── json.go │ ├── kubernetes │ │ ├── apply_addons.go │ │ └── util.go │ ├── pods.go │ ├── refmanager │ │ ├── ref_manager.go │ │ └── ref_manager_test.go │ ├── string.go │ ├── tools.go │ └── tools_test.go │ └── webhook │ ├── nodepool │ ├── nodepool_validation.go │ ├── nodepool_webhook.go │ ├── nodepool_webhook_test.go │ └── v1beta1 │ │ └── nodepool_webhook.go │ ├── server.go │ ├── uniteddeployment │ ├── uniteddeployment_validation.go │ ├── uniteddeployment_webhook.go │ └── uniteddeployment_webhook_test.go │ ├── util │ ├── handler.go │ └── util.go │ ├── yurtappdaemon │ ├── yurtappdaemon_validation.go │ ├── yurtappdaemon_webhook.go │ └── yurtappdaemon_webhook_test.go │ ├── yurtappset │ ├── yurtappset_validation.go │ ├── yurtappset_webhook.go │ └── yurtappset_webhook_test.go │ └── yurtingress │ ├── yurtingress_validating.go │ ├── yurtingress_webhook.go │ └── yurtingress_webhook_test.go └── tests ├── e2e ├── e2e.go ├── e2e_test.go ├── nodepool │ └── nodepool.go ├── util │ ├── ginkgowrapper │ │ └── wrapper.go │ ├── nodepool_utils.go │ └── test_utils.go ├── yurtappset │ └── yurtappset.go └── yurtconfig │ └── yurtconfig.go ├── fuzz ├── Dockerfile.builder ├── go.mod ├── oss_fuzz_build.sh ├── oss_fuzz_run.sh ├── yurtappdaemon_fuzzer.go └── yurtappset_fuzzer.go └── kind-conf.yaml /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | target: auto 6 | threshold: 2% -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: kind/bug 6 | 7 | --- 8 | 9 | 10 | 11 | 12 | **What happened**: 13 | 14 | **What you expected to happen**: 15 | 16 | **How to reproduce it (as minimally and precisely as possible)**: 17 | 18 | **Anything else we need to know?**: 19 | 20 | **Environment**: 21 | - OpenYurt version: 22 | - Kubernetes version (use `kubectl version`): 23 | - OS (e.g: `cat /etc/os-release`): 24 | - Kernel (e.g. `uname -a`): 25 | - Install tools: 26 | - Others: 27 | 28 | **others** 29 | 30 | /kind bug 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/failing-test.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Failing Test 3 | about: Report continuously failing tests or jobs in Kubernetes CI 4 | labels: kind/failing-test 5 | 6 | --- 7 | 8 | 9 | 10 | #### Which jobs are failing: 11 | 12 | #### Which test(s) are failing: 13 | 14 | #### Since when has it been failing: 15 | 16 | #### Testgrid link: 17 | 18 | #### Reason for failure: 19 | 20 | #### Anything else we need to know: 21 | 22 | #### labels 23 | 24 | /kind failing-test 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: "[feature request]" 5 | labels: kind/feature 6 | 7 | --- 8 | 9 | 10 | 11 | **What would you like to be added**: 12 | 13 | 14 | **Why is this needed**: 15 | 16 | 17 | **others** 18 | /kind feature 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Question about OpenYurt. 4 | title: "[Question]" 5 | labels: kind/question 6 | 7 | --- 8 | 9 | 10 | 11 | **What happened**: 12 | 13 | **What you expected to happen**: 14 | 15 | **How to reproduce it (as minimally and precisely as possible)**: 16 | 17 | **Anything else we need to know?**: 18 | 19 | **Environment**: 20 | - OpenYurt version: 21 | - Kubernetes version (use `kubectl version`): 22 | - OS (e.g: `cat /etc/os-release`): 23 | - Kernel (e.g. `uname -a`): 24 | - Install tools: 25 | - Others: 26 | 27 | **others** 28 | /kind question 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | #### What type of PR is this? 7 | > Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespace from that line: 8 | > /kind bug 9 | > /kind documentation 10 | > /kind enhancement 11 | > /kind good-first-issue 12 | > /kind feature 13 | > /kind question 14 | > /kind design 15 | > /sig ai 16 | > /sig iot 17 | > /sig network 18 | > /sig storage 19 | > /sig storage 20 | 21 | 22 | 23 | #### What this PR does / why we need it: 24 | 25 | #### Which issue(s) this PR fixes: 26 | 30 | Fixes # 31 | 32 | #### Special notes for your reviewer: 33 | 37 | 38 | 39 | #### Does this PR introduce a user-facing change? 40 | 46 | ```release-note 47 | 48 | ``` 49 | 50 | #### other Note 51 | 55 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | tags: 8 | - "v*" 9 | paths-ignore: 10 | - '*.md' 11 | - 'charts/**' 12 | - 'config/**' 13 | - 'docs/**' 14 | - 'LICENSE' 15 | - 'OWNERS' 16 | - 'README.md' 17 | schedule: 18 | # run at UTC 1:30 every day 19 | - cron: '30 1 * * *' 20 | workflow_dispatch: {} 21 | 22 | env: 23 | ALI_REGISTRY: registry.cn-hangzhou.aliyuncs.com/openyurt 24 | 25 | jobs: 26 | docker-push: 27 | if: github.repository == 'openyurtio/yurt-app-manager' 28 | runs-on: ubuntu-20.04 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v3 32 | with: 33 | submodules: true 34 | fetch-depth: 0 35 | - name: Get the version 36 | id: get_version 37 | run: | 38 | VERSION=${GITHUB_REF#refs/tags/} 39 | if [[ ${GITHUB_REF} == "refs/heads/master" ]]; then 40 | VERSION=latest 41 | fi 42 | echo ::set-output name=VERSION::${VERSION} 43 | - name: Install Docker Buildx 44 | id: buildx 45 | uses: docker/setup-buildx-action@v1 46 | - name: Login to DockerHub 47 | uses: docker/login-action@v1 48 | with: 49 | username: ${{ secrets.DOCKERHUB_USERNAME }} 50 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 51 | - name: Release 52 | run: make docker-push TARGET_PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7 IMAGE_TAG=${{ steps.get_version.outputs.VERSION }} 53 | docker-push-ali-registry: 54 | if: github.repository == 'openyurtio/yurt-app-manager' 55 | runs-on: ubuntu-20.04 56 | steps: 57 | - name: Checkout 58 | uses: actions/checkout@v3 59 | with: 60 | submodules: true 61 | fetch-depth: 0 62 | - name: Get the version 63 | id: get_version 64 | run: | 65 | VERSION=${GITHUB_REF#refs/tags/} 66 | if [[ ${GITHUB_REF} == "refs/heads/master" ]]; then 67 | VERSION=latest 68 | fi 69 | echo ::set-output name=VERSION::${VERSION} 70 | - name: Install Docker Buildx 71 | id: buildx 72 | uses: docker/setup-buildx-action@v1 73 | - name: Login to DockerHub 74 | uses: docker/login-action@v1 75 | with: 76 | registry: ${{ env.ALI_REGISTRY }} 77 | username: ${{ secrets.ALI_REGISTRY_USERNAME }} 78 | password: ${{ secrets.ALI_REGISTRY_PASSWORD }} 79 | - name: Release 80 | run: make docker-push TARGET_PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7 IMAGE_REPO=${{ env.ALI_REGISTRY }} IMAGE_TAG=${{ steps.get_version.outputs.VERSION }} -------------------------------------------------------------------------------- /.github/workflows/sync-api.yaml: -------------------------------------------------------------------------------- 1 | name: sync-api 2 | on: 3 | push: 4 | branches: 5 | - master 6 | paths: 7 | # TODO disable match all paths when workflow run fluently 8 | - '**' 9 | # - 'pkg/yurtappmanager/apis/**' 10 | # - 'pkg/yurtappmanager/client/**' 11 | 12 | jobs: 13 | sync-core-api: 14 | runs-on: ubuntu-20.04 15 | steps: 16 | - name: Set up Go 1.17 17 | uses: actions/setup-go@v3 18 | env: 19 | GO_VERSION: '1.17' 20 | GOLANGCI_VERSION: 'v1.45' 21 | with: 22 | go-version: ${{ env.GO_VERSION }} 23 | id: go 24 | 25 | - name: Check out code into the Go module directory 26 | uses: actions/checkout@v2 27 | 28 | - name: Get the version 29 | id: get_version 30 | run: | 31 | echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} 32 | echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} 33 | 34 | - name: Sync to api Repo 35 | env: 36 | SSH_DEPLOY_KEY: ${{ secrets.SYNC_API_SECRET }} 37 | VERSION: ${{ steps.get_version.outputs.VERSION }} 38 | TAG: ${{ steps.get_version.outputs.TAG }} 39 | COMMIT_ID: ${{ github.sha }} 40 | run: | 41 | bash ./hack/lib/sync-api.sh 42 | -------------------------------------------------------------------------------- /.github/workflows/sync-charts.yaml: -------------------------------------------------------------------------------- 1 | name: Sync Charts 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - feat-sync-chart 8 | paths: 9 | - '**' 10 | # - 'charts/**' 11 | 12 | jobs: 13 | copy-file: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v2 18 | 19 | - name: Get the version 20 | id: get_version 21 | run: | 22 | echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} 23 | echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} 24 | - uses: jungwinter/split@v2 25 | id: split 26 | with: 27 | msg: '${{ github.repository }}' 28 | separator: '/' 29 | 30 | - name: Sync to openyurt-helm Repo 31 | env: 32 | REPOSITORY_OWNER: ${{ steps.split.outputs._0 }} 33 | SSH_DEPLOY_KEY: ${{ secrets.SYNC_CHARTS_SECRET }} 34 | VERSION: ${{ steps.get_version.outputs.VERSION }} 35 | TAG: ${{ steps.get_version.outputs.TAG }} 36 | COMMIT_ID: ${{ github.sha }} 37 | run: | 38 | bash ./hack/lib/sync-charts.sh 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _output 2 | .idea 3 | .vscode 4 | .DS_Store 5 | gopath 6 | dockerbuild 7 | 8 | *.out 9 | logs 10 | bin 11 | bin/controller-gen 12 | bin/kustomize 13 | -------------------------------------------------------------------------------- /.golangci.yaml: -------------------------------------------------------------------------------- 1 | # This file contains all available configuration options 2 | # with their default values. 3 | 4 | # options for analysis running 5 | run: 6 | go: '1.16' 7 | # default concurrency is a available CPU number 8 | concurrency: 4 9 | 10 | # timeout for analysis, e.g. 30s, 5m, default is 1m 11 | timeout: 15m 12 | 13 | # exit code when at least one issue was found, default is 1 14 | issues-exit-code: 1 15 | 16 | # include test files or not, default is true 17 | tests: true 18 | 19 | # output configuration options 20 | output: 21 | # colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions 22 | # default is "colored-line-number" 23 | format: colored-line-number 24 | 25 | # print lines of code with issue, default is true 26 | print-issued-lines: true 27 | 28 | # print linter name in the end of issue text, default is true 29 | print-linter-name: true 30 | 31 | # make issues output unique by line, default is true 32 | uniq-by-line: true 33 | 34 | # all available settings of specific linters 35 | linters-settings: 36 | gci: 37 | local-prefixes: github.com/openyurtio 38 | 39 | linters: 40 | disable-all: true 41 | enable: 42 | - deadcode 43 | - gofmt 44 | - goimports 45 | - gci 46 | - ineffassign 47 | - misspell 48 | - vet 49 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | approvers: 2 | - charleszheng44 3 | - kadisi 4 | - Fei-Guo 5 | - huangyuqi 6 | - rambohe-ch 7 | - zzguang 8 | reviewers: 9 | - kadisi 10 | - Fei-Guo 11 | - huangyuqi 12 | - rambohe-ch 13 | - zzguang 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Yurt-app-manager 2 | 3 | **IMPORTANT: This project is no longer being actively maintained and has been archived.** 4 | 5 | ## Archived Project 6 | 7 | This project has been archived and is no longer being actively maintained. This means you can view and copy the code, but cannot make changes or propose pull requests. 8 | 9 | While you're here, feel free to review the code and learn from it. If you wish to use the code or revive the project, you can fork it to your own GitHub account. 10 | 11 | ## Project Description 12 | 13 | This repository contains 4 CRD/controllers: NodePool, YurtAppSet, YurtAppDaemon and YurtIngress. 14 | 15 | The NodePool provides a convenient management experience for a pool of nodes within the same region or site. 16 | 17 | The YurtAppSet defines a new edge application management methodology of using per node pool workload. 18 | 19 | The YurtAppDaemon provides a similar K8S DaemonSet support for user app workload from the NodePool level. 20 | 21 | The YurtIngress is responsible to deploy configurable ingress controller to the user specified NodePools. 22 | 23 | For details of the design, please see the documents below: 24 | 25 | NodePool and YurtAppSet: [document](https://github.com/openyurtio/openyurt/blob/master/docs/enhancements/20201211-nodepool_uniteddeployment.md). 26 | 27 | YurtAppDaemon: [document](https://github.com/openyurtio/openyurt/blob/master/docs/enhancements/20210729-yurtappdaemon.md). 28 | 29 | YurtIngress: [document](https://github.com/openyurtio/openyurt/blob/master/docs/proposals/20210628-nodepool-ingress-support.md). 30 | 31 | ## Previous Contributions 32 | 33 | We want to take a moment to thank all of the previous contributors to this project. Your work has been greatly appreciated and has made a significant impact. 34 | 35 | - [huiwq1990](https://github.com/huiwq1990) 36 | - [kadisi](https://github.com/kadisi) 37 | - [rambohe-ch](https://github.com/rambohe-ch) 38 | - [luc99hen](https://github.com/luc99hen) 39 | - [charleszheng44](https://github.com/charleszheng44) 40 | - [rudolf-chy](https://github.com/rudolf-chy) 41 | - [River-sh](https://github.com/River-sh) 42 | - [YTGhost](https://github.com/YTGhost) 43 | - [LindaYu17](https://github.com/LindaYu17) 44 | - [JameKeal](https://github.com/JameKeal) 45 | - [xavier-hou](https://github.com/xavier-hou) 46 | - [ahmedwaleedmalik](https://github.com/ahmedwaleedmalik) 47 | - [kyakdan](https://github.com/kyakdan) 48 | - [donychen1134](https://github.com/donychen1134) 49 | - [Congrool](https://github.com/Congrool) 50 | - [cndoit18](https://github.com/cndoit18) 51 | - [maoyangLiu](https://github.com/maoyangLiu) 52 | - [wawlian](https://github.com/wawlian) 53 | - [gnunu](https://github.com/gnunu) 54 | - [cuisongliu](https://github.com/cuisongliu) 55 | - [ZBoIsHere](https://github.com/ZBoIsHere) 56 | - [yanyhui](https://github.com/yanyhui) 57 | 58 | ## Alternative Projects 59 | 60 | All the functions of this project have been migrated into `yurt-manager` component in [openyurt](https://github.com/openyurtio/openyurt) repo. 61 | 62 | - [controllers](https://github.com/openyurtio/openyurt/tree/master/pkg/yurtmanager/controller) 63 | - [webhooks](https://github.com/openyurtio/openyurt/tree/master/pkg/yurtmanager/webhook) -------------------------------------------------------------------------------- /charts/yurt-app-manager/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: yurt-app-manager 3 | description: The controller manager that contains the nodepool controller and yurtappset controller. 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.1.3 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | # It is recommended to use it with quotes. 24 | appVersion: "0.6.0" 25 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | This application contains 4 CRD/controllers: NodePool, YurtAppSet, YurtAppDaemon and YurtIngress. 2 | 3 | The NodePool provides a convenient management experience for a pool of nodes within the same region or site. 4 | The YurtAppSet defines a new edge application management methodology of using per node pool workload. 5 | The YurtAppDaemon provides a similar K8S DaemonSet support for user app workload from the NodePool level. 6 | The YurtIngress is responsible to deploy configurable ingress controller to the user specified NodePools. 7 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Expand the name of the chart. 3 | */}} 4 | {{- define "yurt-app-manager.name" -}} 5 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 6 | {{- end }} 7 | 8 | {{/* 9 | Create a default fully qualified app name. 10 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 11 | If release name contains chart name it will be used as a full name. 12 | */}} 13 | {{- define "yurt-app-manager.fullname" -}} 14 | {{- if .Values.fullnameOverride }} 15 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 16 | {{- else }} 17 | {{- $name := default .Chart.Name .Values.nameOverride }} 18 | {{- if contains $name .Release.Name }} 19 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 20 | {{- else }} 21 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 22 | {{- end }} 23 | {{- end }} 24 | {{- end }} 25 | 26 | {{/* 27 | Create chart name and version as used by the chart label. 28 | */}} 29 | {{- define "yurt-app-manager.chart" -}} 30 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 31 | {{- end }} 32 | 33 | {{/* 34 | Common labels 35 | */}} 36 | {{- define "yurt-app-manager.labels" -}} 37 | helm.sh/chart: {{ include "yurt-app-manager.chart" . }} 38 | {{ include "yurt-app-manager.selectorLabels" . }} 39 | {{- if .Chart.AppVersion }} 40 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 41 | {{- end }} 42 | app.kubernetes.io/managed-by: {{ .Release.Service }} 43 | {{- end }} 44 | 45 | {{/* 46 | Selector labels 47 | */}} 48 | {{- define "yurt-app-manager.selectorLabels" -}} 49 | app.kubernetes.io/name: {{ include "yurt-app-manager.name" . }} 50 | app.kubernetes.io/instance: {{ .Release.Name }} 51 | {{- end }} 52 | 53 | {{/* 54 | Create the name of the service account to use 55 | */}} 56 | {{- define "yurt-app-manager.serviceAccountName" -}} 57 | {{- if .Values.serviceAccount.create }} 58 | {{- default (include "yurt-app-manager.fullname" .) .Values.serviceAccount.name }} 59 | {{- else }} 60 | {{- default "default" .Values.serviceAccount.name }} 61 | {{- end }} 62 | {{- end }} 63 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission 6 | annotations: 7 | "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade 8 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 9 | labels: 10 | app: {{ template "yurt-app-manager.name" . }}-admission 11 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 12 | rules: 13 | - apiGroups: 14 | - admissionregistration.k8s.io 15 | resources: 16 | - validatingwebhookconfigurations 17 | - mutatingwebhookconfigurations 18 | verbs: 19 | - get 20 | - update 21 | - apiGroups: 22 | - apiextensions.k8s.io 23 | resources: 24 | - customresourcedefinitions 25 | verbs: 26 | - get 27 | - update 28 | {{- end }} -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission 6 | annotations: 7 | "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade 8 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 9 | labels: 10 | app: {{ template "yurt-app-manager.name" . }}-admission 11 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 12 | roleRef: 13 | apiGroup: rbac.authorization.k8s.io 14 | kind: ClusterRole 15 | name: {{ template "yurt-app-manager.fullname" . }}-admission 16 | subjects: 17 | - kind: ServiceAccount 18 | name: {{ template "yurt-app-manager.fullname" . }}-admission 19 | namespace: {{ .Release.Namespace }} 20 | {{- end }} 21 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/job-createSecret.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: batch/v1 3 | kind: Job 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission-create 6 | namespace: {{ .Release.Namespace }} 7 | annotations: 8 | "helm.sh/hook": pre-install,pre-upgrade 9 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 10 | labels: 11 | app: {{ template "yurt-app-manager.name" . }}-admission-create 12 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 13 | spec: 14 | {{- if .Capabilities.APIVersions.Has "batch/v1alpha1" }} 15 | # Alpha feature since k8s 1.12 16 | ttlSecondsAfterFinished: 0 17 | {{- end }} 18 | template: 19 | metadata: 20 | name: {{ template "yurt-app-manager.fullname" . }}-admission-create 21 | labels: 22 | app: {{ template "yurt-app-manager.name" . }}-admission-create 23 | {{- include "yurt-app-manager.labels" . | nindent 8 }} 24 | spec: 25 | {{- with .Values.imagePullSecrets }} 26 | imagePullSecrets: 27 | {{- toYaml . | nindent 8 }} 28 | {{- end }} 29 | containers: 30 | - name: create 31 | image: {{ .Values.imageRegistry }}/{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }} 32 | imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }} 33 | args: 34 | - create 35 | - --host={{ template "yurt-app-manager.name" . }}-webhook,{{ template "yurt-app-manager.fullname" . }}-webhook.{{ .Release.Namespace }}.svc 36 | - --namespace={{ .Release.Namespace }} 37 | - --secret-name={{ template "yurt-app-manager.fullname" . }}-admission 38 | - --key-name=tls.key 39 | - --cert-name=tls.crt 40 | restartPolicy: OnFailure 41 | serviceAccountName: {{ template "yurt-app-manager.fullname" . }}-admission 42 | {{- with .Values.admissionWebhooks.patch.affinity }} 43 | affinity: 44 | {{ toYaml . | indent 8 }} 45 | {{- end }} 46 | {{- with .Values.admissionWebhooks.patch.tolerations }} 47 | tolerations: 48 | {{ toYaml . | indent 8 }} 49 | {{- end }} 50 | securityContext: 51 | runAsGroup: 2000 52 | runAsNonRoot: true 53 | runAsUser: 2000 54 | {{- end }} 55 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/job-patchWebhook.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: batch/v1 3 | kind: Job 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission-patch 6 | namespace: {{ .Release.Namespace }} 7 | annotations: 8 | "helm.sh/hook": post-install,post-upgrade 9 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 10 | labels: 11 | app: {{ template "yurt-app-manager.name" . }}-admission-patch 12 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 13 | spec: 14 | {{- if .Capabilities.APIVersions.Has "batch/v1alpha1" }} 15 | # Alpha feature since k8s 1.12 16 | ttlSecondsAfterFinished: 0 17 | {{- end }} 18 | template: 19 | metadata: 20 | name: {{ template "yurt-app-manager.fullname" . }}-admission-patch 21 | labels: 22 | app: {{ template "yurt-app-manager.name" . }}-admission-patch 23 | {{- include "yurt-app-manager.labels" . | nindent 8 }} 24 | spec: 25 | {{- with .Values.imagePullSecrets }} 26 | imagePullSecrets: 27 | {{- toYaml . | nindent 8 }} 28 | {{- end }} 29 | containers: 30 | - name: patch 31 | image: {{ .Values.imageRegistry }}/{{ .Values.admissionWebhooks.patch.image.repository }}:{{ .Values.admissionWebhooks.patch.image.tag }} 32 | imagePullPolicy: {{ .Values.admissionWebhooks.patch.image.pullPolicy }} 33 | args: 34 | - patch 35 | - --webhook-name={{ template "yurt-app-manager.fullname" . }} 36 | - --namespace={{ .Release.Namespace }} 37 | - --secret-name={{ template "yurt-app-manager.fullname" . }}-admission 38 | - --patch-failure-policy={{ .Values.admissionWebhooks.failurePolicy }} 39 | - --crds={"name":"nodepools.apps.openyurt.io","conversion":{"strategy":"Webhook","webhook":{"clientConfig":{"service":{"name":"{{ template "yurt-app-manager.name" . }}-webhook","namespace":"{{ .Release.Namespace }}","path":"/convert","port":443}},"conversionReviewVersions":["v1beta1","v1alpha1"]}}} 40 | - --patch-mutating=true 41 | - --patch-validating=true 42 | - --log-level=trace 43 | restartPolicy: OnFailure 44 | serviceAccountName: {{ template "yurt-app-manager.fullname" . }}-admission 45 | {{- with .Values.admissionWebhooks.patch.affinity }} 46 | affinity: 47 | {{ toYaml . | indent 8 }} 48 | {{- end }} 49 | {{- with .Values.admissionWebhooks.patch.tolerations }} 50 | tolerations: 51 | {{ toYaml . | indent 8 }} 52 | {{- end }} 53 | securityContext: 54 | runAsGroup: 2000 55 | runAsNonRoot: true 56 | runAsUser: 2000 57 | {{- end }} 58 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/role.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: Role 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission 6 | namespace: {{ .Release.Namespace }} 7 | annotations: 8 | "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade 9 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 10 | labels: 11 | app: {{ template "yurt-app-manager.name" . }}-admission 12 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 13 | rules: 14 | - apiGroups: 15 | - "" 16 | resources: 17 | - secrets 18 | verbs: 19 | - get 20 | - create 21 | {{- end }} 22 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/rolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: RoleBinding 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission 6 | namespace: {{ .Release.Namespace }} 7 | annotations: 8 | "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade 9 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 10 | labels: 11 | app: {{ template "yurt-app-manager.name" . }}-admission 12 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 13 | roleRef: 14 | apiGroup: rbac.authorization.k8s.io 15 | kind: Role 16 | name: {{ template "yurt-app-manager.fullname" . }}-admission 17 | subjects: 18 | - kind: ServiceAccount 19 | name: {{ template "yurt-app-manager.fullname" . }}-admission 20 | namespace: {{ .Release.Namespace }} 21 | {{- end }} 22 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/job-patch/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.admissionWebhooks.enabled .Values.admissionWebhooks.patch.enabled (not .Values.admissionWebhooks.certManager.enabled) }} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ template "yurt-app-manager.fullname" . }}-admission 6 | namespace: {{ .Release.Namespace }} 7 | annotations: 8 | "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade 9 | "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded 10 | labels: 11 | app: {{ template "yurt-app-manager.name" . }}-admission 12 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 13 | {{- end }} 14 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/mutatingwebhookconfiguration.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: admissionregistration.k8s.io/v1 2 | kind: MutatingWebhookConfiguration 3 | metadata: 4 | name: {{ include "yurt-app-manager.fullname" . }} 5 | webhooks: 6 | - clientConfig: 7 | caBundle: Cg== 8 | service: 9 | name: {{ template "yurt-app-manager.name" . }}-webhook 10 | namespace: {{ .Release.Namespace }} 11 | path: /mutate-apps-openyurt-io-v1alpha1-nodepool 12 | admissionReviewVersions: 13 | - v1 14 | sideEffects: None 15 | failurePolicy: Fail 16 | name: mnodepool.kb.io 17 | rules: 18 | - apiGroups: 19 | - apps.openyurt.io 20 | apiVersions: 21 | - v1alpha1 22 | operations: 23 | - CREATE 24 | - UPDATE 25 | resources: 26 | - nodepools 27 | - clientConfig: 28 | caBundle: Cg== 29 | service: 30 | name: {{ template "yurt-app-manager.name" . }}-webhook 31 | namespace: {{ .Release.Namespace }} 32 | path: /mutate-apps-openyurt-io-v1alpha1-uniteddeployment 33 | admissionReviewVersions: 34 | - v1 35 | sideEffects: None 36 | failurePolicy: Fail 37 | name: muniteddeployment.kb.io 38 | rules: 39 | - apiGroups: 40 | - apps.openyurt.io 41 | apiVersions: 42 | - v1alpha1 43 | operations: 44 | - CREATE 45 | - UPDATE 46 | resources: 47 | - uniteddeployments 48 | - clientConfig: 49 | caBundle: Cg== 50 | service: 51 | name: {{ template "yurt-app-manager.name" . }}-webhook 52 | namespace: {{ .Release.Namespace }} 53 | path: /mutate-apps-openyurt-io-v1alpha1-yurtappset 54 | admissionReviewVersions: 55 | - v1 56 | sideEffects: None 57 | failurePolicy: Fail 58 | name: myurtappset.kb.io 59 | rules: 60 | - apiGroups: 61 | - apps.openyurt.io 62 | apiVersions: 63 | - v1alpha1 64 | operations: 65 | - CREATE 66 | - UPDATE 67 | resources: 68 | - yurtappsets 69 | - clientConfig: 70 | caBundle: Cg== 71 | service: 72 | name: {{ template "yurt-app-manager.name" . }}-webhook 73 | namespace: {{ .Release.Namespace }} 74 | path: /mutate-apps-openyurt-io-v1alpha1-yurtappdaemon 75 | admissionReviewVersions: 76 | - v1 77 | sideEffects: None 78 | failurePolicy: Fail 79 | name: myurtappdaemon.kb.io 80 | rules: 81 | - apiGroups: 82 | - apps.openyurt.io 83 | apiVersions: 84 | - v1alpha1 85 | operations: 86 | - CREATE 87 | - UPDATE 88 | resources: 89 | - yurtappdaemons 90 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/validatingwebhookconfiguration.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: admissionregistration.k8s.io/v1 2 | kind: ValidatingWebhookConfiguration 3 | metadata: 4 | name: {{ include "yurt-app-manager.fullname" . }} 5 | webhooks: 6 | - clientConfig: 7 | caBundle: Cg== 8 | service: 9 | name: {{ template "yurt-app-manager.name" . }}-webhook 10 | namespace: {{ .Release.Namespace }} 11 | path: /validate-apps-openyurt-io-v1alpha1-nodepool 12 | admissionReviewVersions: 13 | - v1 14 | sideEffects: None 15 | failurePolicy: Fail 16 | name: vnodepool.kb.io 17 | rules: 18 | - apiGroups: 19 | - apps.openyurt.io 20 | apiVersions: 21 | - v1alpha1 22 | operations: 23 | - CREATE 24 | - UPDATE 25 | - DELETE 26 | resources: 27 | - nodepools 28 | - clientConfig: 29 | caBundle: Cg== 30 | service: 31 | name: {{ template "yurt-app-manager.name" . }}-webhook 32 | namespace: {{ .Release.Namespace }} 33 | path: /validate-apps-openyurt-io-v1alpha1-uniteddeployment 34 | admissionReviewVersions: 35 | - v1 36 | sideEffects: None 37 | failurePolicy: Fail 38 | name: vuniteddeployment.kb.io 39 | rules: 40 | - apiGroups: 41 | - apps.openyurt.io 42 | apiVersions: 43 | - v1alpha1 44 | operations: 45 | - CREATE 46 | - UPDATE 47 | resources: 48 | - uniteddeployments 49 | - clientConfig: 50 | caBundle: Cg== 51 | service: 52 | name: {{ template "yurt-app-manager.name" . }}-webhook 53 | namespace: {{ .Release.Namespace }} 54 | path: /validate-apps-openyurt-io-v1alpha1-yurtappset 55 | admissionReviewVersions: 56 | - v1 57 | sideEffects: None 58 | failurePolicy: Fail 59 | name: vyurtappset.kb.io 60 | rules: 61 | - apiGroups: 62 | - apps.openyurt.io 63 | apiVersions: 64 | - v1alpha1 65 | operations: 66 | - CREATE 67 | - UPDATE 68 | resources: 69 | - yurtappsets 70 | - clientConfig: 71 | caBundle: Cg== 72 | service: 73 | name: {{ template "yurt-app-manager.name" . }}-webhook 74 | namespace: {{ .Release.Namespace }} 75 | path: /validate-apps-openyurt-io-v1alpha1-yurtappdaemon 76 | admissionReviewVersions: 77 | - v1 78 | sideEffects: None 79 | failurePolicy: Fail 80 | name: vyurtappdaemon.kb.io 81 | rules: 82 | - apiGroups: 83 | - apps.openyurt.io 84 | apiVersions: 85 | - v1alpha1 86 | operations: 87 | - CREATE 88 | - UPDATE 89 | resources: 90 | - yurtappdaemons 91 | - clientConfig: 92 | caBundle: Cg== 93 | service: 94 | name: {{ template "yurt-app-manager.name" . }}-webhook 95 | namespace: {{ .Release.Namespace }} 96 | path: /validate-apps-openyurt-io-v1alpha1-yurtingress 97 | admissionReviewVersions: 98 | - v1 99 | sideEffects: None 100 | failurePolicy: Fail 101 | name: vyurtingress.kb.io 102 | rules: 103 | - apiGroups: 104 | - apps.openyurt.io 105 | apiVersions: 106 | - v1alpha1 107 | operations: 108 | - CREATE 109 | - UPDATE 110 | - DELETE 111 | resources: 112 | - yurtingresses 113 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/admission-webhooks/webhookService.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.admissionWebhooks.enabled -}} 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: {{ template "yurt-app-manager.name" . }}-webhook 6 | namespace: {{ .Release.Namespace }} 7 | labels: 8 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 9 | spec: 10 | type: {{ .Values.admissionWebhooks.service.type }} 11 | ports: 12 | - port: 443 13 | targetPort: {{ .Values.admissionWebhooks.service.port }} 14 | protocol: TCP 15 | name: https 16 | selector: 17 | {{ include "yurt-app-manager.selectorLabels" . | nindent 6 }} 18 | 19 | {{- end -}} 20 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 9 | subjects: 10 | - kind: ServiceAccount 11 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 12 | namespace: {{ .Release.Namespace }} -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 5 | rules: 6 | - apiGroups: 7 | - "" 8 | resources: 9 | - configmaps 10 | verbs: 11 | - get 12 | - list 13 | - watch 14 | - create 15 | - update 16 | - patch 17 | - delete 18 | - apiGroups: 19 | - "" 20 | resources: 21 | - configmaps/status 22 | verbs: 23 | - get 24 | - update 25 | - patch 26 | - apiGroups: 27 | - "" 28 | resources: 29 | - events 30 | verbs: 31 | - create -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/rolebinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: Role 8 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 9 | subjects: 10 | - kind: ServiceAccount 11 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 12 | namespace: {{ .Release.Namespace }} -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: {{ include "yurt-app-manager.fullname" . }} -------------------------------------------------------------------------------- /charts/yurt-app-manager/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "yurt-app-manager.serviceAccountName" . }} 6 | labels: 7 | {{- include "yurt-app-manager.labels" . | nindent 4 }} 8 | {{- with .Values.serviceAccount.annotations }} 9 | annotations: 10 | {{- toYaml . | nindent 4 }} 11 | {{- end }} 12 | {{- end }} 13 | -------------------------------------------------------------------------------- /charts/yurt-app-manager/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for yurt-app-manager. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicaCount: 1 6 | 7 | image: 8 | repository: openyurt/yurt-app-manager 9 | pullPolicy: IfNotPresent 10 | # Overrides the image tag whose default is the chart appVersion. 11 | tag: v0.6.0 12 | 13 | imageRegistry: "docker.io" 14 | imagePullSecrets: [] 15 | nameOverride: "" 16 | fullnameOverride: "" 17 | 18 | serviceAccount: 19 | # Specifies whether a service account should be created 20 | create: true 21 | # Annotations to add to the service account 22 | annotations: {} 23 | # The name of the service account to use. 24 | # If not set and create is true, a name is generated using the fullname template 25 | name: "" 26 | 27 | podAnnotations: {} 28 | 29 | podSecurityContext: {} 30 | # fsGroup: 2000 31 | 32 | securityContext: {} 33 | # capabilities: 34 | # drop: 35 | # - ALL 36 | # readOnlyRootFilesystem: true 37 | # runAsNonRoot: true 38 | # runAsUser: 1000 39 | 40 | resources: {} 41 | # We usually recommend not to specify default resources and to leave this as a conscious 42 | # choice for the user. This also increases chances charts run on environments with little 43 | # resources, such as Minikube. If you do want to specify resources, uncomment the following 44 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 45 | # limits: 46 | # cpu: 100m 47 | # memory: 128Mi 48 | # requests: 49 | # cpu: 100m 50 | # memory: 128Mi 51 | 52 | nodeSelector: {} 53 | 54 | tolerations: [{"key": "node-role.kubernetes.io/master", "operator": "Exists", "effect": "NoSchedule"}] 55 | 56 | affinity: {} 57 | 58 | priorityClassName: system-node-critical 59 | 60 | admissionWebhooks: 61 | enabled: true 62 | service: 63 | type: ClusterIP 64 | port: 9443 65 | failurePolicy: Fail 66 | certificate: 67 | mountPath: /tmp/k8s-webhook-server/serving-certs 68 | patch: 69 | enabled: true 70 | image: 71 | repository: oamdev/kube-webhook-certgen 72 | tag: v2.4.1 73 | pullPolicy: IfNotPresent 74 | affinity: {} 75 | tolerations: [{"key": "node-role.kubernetes.io/master", "operator": "Exists", "effect": "NoSchedule"}] 76 | certManager: 77 | enabled: false 78 | revisionHistoryLimit: 3 79 | -------------------------------------------------------------------------------- /cmd/yurt-app-manager/app-manager.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "flag" 21 | "math/rand" 22 | "time" 23 | 24 | "k8s.io/apimachinery/pkg/util/wait" 25 | "k8s.io/klog" 26 | 27 | "github.com/openyurtio/yurt-app-manager/cmd/yurt-app-manager/app" 28 | ) 29 | 30 | func main() { 31 | rand.Seed(time.Now().UnixNano()) 32 | klog.InitFlags(nil) 33 | defer klog.Flush() 34 | 35 | cmd := app.NewCmdYurtAppManager(wait.NeverStop) 36 | cmd.Flags().AddGoFlagSet(flag.CommandLine) 37 | if err := cmd.Execute(); err != nil { 38 | panic(err) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cmd/yurt-app-manager/options/options.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package options 18 | 19 | import ( 20 | "github.com/spf13/pflag" 21 | ) 22 | 23 | // YurtAppOptions is the main settings for the yurtapp-manger 24 | type YurtAppOptions struct { 25 | MetricsAddr string 26 | PprofAddr string 27 | HealthProbeAddr string 28 | EnableLeaderElection bool 29 | EnablePprof bool 30 | LeaderElectionNamespace string 31 | Namespace string 32 | CreateDefaultPool bool 33 | Version bool 34 | } 35 | 36 | // NewYurtAppOptions creates a new YurtAppOptions with a default config. 37 | func NewYurtAppOptions() *YurtAppOptions { 38 | o := &YurtAppOptions{ 39 | MetricsAddr: ":8080", 40 | PprofAddr: ":8090", 41 | HealthProbeAddr: ":8000", 42 | EnableLeaderElection: true, 43 | EnablePprof: false, 44 | LeaderElectionNamespace: "kube-system", 45 | Namespace: "", 46 | CreateDefaultPool: false, 47 | } 48 | 49 | return o 50 | } 51 | 52 | // ValidateOptions validates YurtAppOptions 53 | func ValidateOptions(options *YurtAppOptions) error { 54 | // TODO 55 | return nil 56 | } 57 | 58 | // AddFlags returns flags for a specific yurthub by section name 59 | func (o *YurtAppOptions) AddFlags(fs *pflag.FlagSet) { 60 | fs.StringVar(&o.MetricsAddr, "metrics-addr", o.MetricsAddr, "The address the metric endpoint binds to.") 61 | fs.StringVar(&o.PprofAddr, "pprof-addr", o.PprofAddr, "The address the pprof binds to.") 62 | fs.StringVar(&o.HealthProbeAddr, "health-probe-addr", o.HealthProbeAddr, "The address the healthz/readyz endpoint binds to.") 63 | fs.BoolVar(&o.EnableLeaderElection, "enable-leader-election", o.EnableLeaderElection, "Whether you need to enable leader election.") 64 | fs.BoolVar(&o.EnablePprof, "enable-pprof", o.EnablePprof, "Enable pprof for controller manager.") 65 | fs.StringVar(&o.LeaderElectionNamespace, "leader-election-namespace", o.LeaderElectionNamespace, "This determines the namespace in which the leader election configmap will be created, it will use in-cluster namespace if empty.") 66 | fs.StringVar(&o.Namespace, "namespace", o.Namespace, "Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.") 67 | fs.BoolVar(&o.CreateDefaultPool, "create-default-pool", o.CreateDefaultPool, "Create default cloud/edge pools if indicated.") 68 | fs.BoolVar(&o.Version, "version", o.Version, "print the version information.") 69 | } 70 | -------------------------------------------------------------------------------- /config/yurt-app-manager/certmanager/certificate.yaml: -------------------------------------------------------------------------------- 1 | # The following manifests contain a self-signed issuer CR and a certificate CR. 2 | # More document can be found at https://docs.cert-manager.io 3 | # WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for 4 | # breaking changes 5 | apiVersion: cert-manager.io/v1alpha2 6 | kind: Issuer 7 | metadata: 8 | name: selfsigned-issuer 9 | namespace: kube-system 10 | spec: 11 | selfSigned: {} 12 | --- 13 | apiVersion: cert-manager.io/v1alpha2 14 | kind: Certificate 15 | metadata: 16 | name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml 17 | namespace: kube-system 18 | spec: 19 | # $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize 20 | dnsNames: 21 | - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc 22 | - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local 23 | issuerRef: 24 | kind: Issuer 25 | name: selfsigned-issuer 26 | secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize 27 | -------------------------------------------------------------------------------- /config/yurt-app-manager/certmanager/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - certificate.yaml 3 | 4 | configurations: 5 | - kustomizeconfig.yaml 6 | -------------------------------------------------------------------------------- /config/yurt-app-manager/certmanager/kustomizeconfig.yaml: -------------------------------------------------------------------------------- 1 | # This configuration is for teaching kustomize how to update name ref and var substitution 2 | nameReference: 3 | - kind: Issuer 4 | group: cert-manager.io 5 | fieldSpecs: 6 | - kind: Certificate 7 | group: cert-manager.io 8 | path: spec/issuerRef/name 9 | 10 | varReference: 11 | - kind: Certificate 12 | group: cert-manager.io 13 | path: spec/commonName 14 | - kind: Certificate 15 | group: cert-manager.io 16 | path: spec/dnsNames 17 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # This kustomization.yaml is not intended to be run by itself, 2 | # since it depends on service name and namespace that are out of this kustomize package. 3 | # It should be run by config/default 4 | resources: 5 | - bases/apps.openyurt.io_yurtappsets.yaml 6 | - bases/apps.openyurt.io_nodepools.yaml 7 | - bases/apps.openyurt.io_yurtappdaemons.yaml 8 | - bases/apps.openyurt.io_yurtingresses.yaml 9 | 10 | patchesStrategicMerge: 11 | # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. 12 | # patches here are for enabling the conversion webhook for each CRD 13 | #- patches/webhook_in_clonesets.yaml 14 | #- patches/webhook_in_broadcastjobs.yaml 15 | #- patches/webhook_in_sidecarsets.yaml 16 | #- patches/webhook_in_statefulsets.yaml 17 | #- patches/webhook_in_yurtappsets.yaml 18 | #- patches/webhook_in_daemonsets.yaml 19 | #- patches/webhook_in_nodeimages.yaml 20 | #- patches/webhook_in_imagepulljobs.yaml 21 | #- patches/webhook_in_nodepools.yaml 22 | # +kubebuilder:scaffold:crdkustomizewebhookpatch 23 | 24 | # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. 25 | # patches here are for enabling the CA injection for each CRD 26 | #- patches/cainjection_in_clonesets.yaml 27 | #- patches/cainjection_in_broadcastjobs.yaml 28 | #- patches/cainjection_in_sidecarsets.yaml 29 | #- patches/cainjection_in_statefulsets.yaml 30 | #- patches/cainjection_in_yurtappsets.yaml 31 | #- patches/cainjection_in_daemonsets.yaml 32 | #- patches/cainjection_in_nodeimages.yaml 33 | #- patches/cainjection_in_imagepulljobs.yaml 34 | #- patches/cainjection_in_nodepools.yaml 35 | # +kubebuilder:scaffold:crdkustomizecainjectionpatch 36 | 37 | # the following config is for teaching kustomize how to do kustomization for CRDs. 38 | configurations: 39 | - kustomizeconfig.yaml 40 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/kustomizeconfig.yaml: -------------------------------------------------------------------------------- 1 | # This file is for teaching kustomize how to substitute name and namespace reference in CRD 2 | nameReference: 3 | - kind: Service 4 | version: v1 5 | fieldSpecs: 6 | - kind: CustomResourceDefinition 7 | group: apiextensions.k8s.io 8 | path: spec/conversion/webhookClientConfig/service/name 9 | 10 | namespace: 11 | - kind: CustomResourceDefinition 12 | group: apiextensions.k8s.io 13 | path: spec/conversion/webhookClientConfig/service/namespace 14 | create: false 15 | 16 | varReference: 17 | - path: metadata/annotations 18 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/patches/cainjection_in_nodepools.yaml: -------------------------------------------------------------------------------- 1 | # The following patch adds a directive for certmanager to inject CA into the CRD 2 | # CRD conversion requires k8s 1.13 or later. 3 | apiVersion: apiextensions.k8s.io/v1 4 | kind: CustomResourceDefinition 5 | metadata: 6 | annotations: 7 | cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) 8 | name: nodepools.apps.openyurt.io 9 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/patches/cainjection_in_yurtappsets.yaml: -------------------------------------------------------------------------------- 1 | # The following patch adds a directive for certmanager to inject CA into the CRD 2 | # CRD conversion requires k8s 1.13 or later. 3 | apiVersion: apiextensions.k8s.io/v1 4 | kind: CustomResourceDefinition 5 | metadata: 6 | annotations: 7 | cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) 8 | name: yurtappsets.apps.openyurt.io 9 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/patches/cainjection_in_yurtingresses.yaml: -------------------------------------------------------------------------------- 1 | # The following patch adds a directive for certmanager to inject CA into the CRD 2 | # CRD conversion requires k8s 1.13 or later. 3 | apiVersion: apiextensions.k8s.io/v1 4 | kind: CustomResourceDefinition 5 | metadata: 6 | annotations: 7 | cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) 8 | name: yurtingresses.apps.openyurt.io 9 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/patches/webhook_in_nodepools.yaml: -------------------------------------------------------------------------------- 1 | # The following patch enables conversion webhook for CRD 2 | # CRD conversion requires k8s 1.13 or later. 3 | apiVersion: apiextensions.k8s.io/v1 4 | kind: CustomResourceDefinition 5 | metadata: 6 | name: nodepools.apps.openyurt.io 7 | spec: 8 | conversion: 9 | strategy: Webhook 10 | webhookClientConfig: 11 | # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, 12 | # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) 13 | caBundle: Cg== 14 | service: 15 | namespace: kube-system 16 | name: webhook-service 17 | path: /convert 18 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/patches/webhook_in_yurtappsets.yaml: -------------------------------------------------------------------------------- 1 | # The following patch enables conversion webhook for CRD 2 | # CRD conversion requires k8s 1.13 or later. 3 | apiVersion: apiextensions.k8s.io/v1 4 | kind: CustomResourceDefinition 5 | metadata: 6 | name: yurtappsets.apps.openyurt.io 7 | spec: 8 | conversion: 9 | strategy: Webhook 10 | webhookClientConfig: 11 | # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, 12 | # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) 13 | caBundle: Cg== 14 | service: 15 | namespace: kube-system 16 | name: webhook-service 17 | path: /convert 18 | -------------------------------------------------------------------------------- /config/yurt-app-manager/crd/patches/webhook_in_yurtingresses.yaml: -------------------------------------------------------------------------------- 1 | # The following patch enables conversion webhook for CRD 2 | # CRD conversion requires k8s 1.13 or later. 3 | apiVersion: apiextensions.k8s.io/v1 4 | kind: CustomResourceDefinition 5 | metadata: 6 | name: yurtingresses.apps.openyurt.io 7 | spec: 8 | conversion: 9 | strategy: Webhook 10 | webhookClientConfig: 11 | # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, 12 | # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) 13 | caBundle: Cg== 14 | service: 15 | namespace: kube-system 16 | name: webhook-service 17 | path: /convert 18 | -------------------------------------------------------------------------------- /config/yurt-app-manager/default/kustomization.yaml: -------------------------------------------------------------------------------- 1 | # Adds namespace to all resources. 2 | namespace: kube-system 3 | 4 | # Value of this field is prepended to the 5 | # names of all resources, e.g. a deployment named 6 | # "wordpress" becomes "alices-wordpress". 7 | # Note that it should also match with the prefix (text before '-') of the namespace 8 | # field above. 9 | namePrefix: yurt-app- 10 | 11 | # Labels to add to all resources and selectors. 12 | #commonLabels: 13 | # someName: someValue 14 | 15 | bases: 16 | - ../crd 17 | - ../rbac 18 | - ../manager 19 | # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in 20 | # crd/kustomization.yaml 21 | - ../webhook 22 | # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. 23 | #- ../certmanager 24 | # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. 25 | #- ../prometheus 26 | 27 | patchesStrategicMerge: 28 | # Protect the /metrics endpoint by putting it behind auth. 29 | # If you want your yurt-app-manager to expose the /metrics 30 | # endpoint w/o any authn/z, please comment the following line. 31 | # - manager_auth_proxy_patch.yaml 32 | 33 | # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in 34 | # crd/kustomization.yaml 35 | - manager_webhook_patch.yaml 36 | 37 | # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 38 | # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. 39 | # 'CERTMANAGER' needs to be enabled to use ca injection 40 | #- webhookcainjection_patch.yaml 41 | 42 | # the following config is for teaching kustomize how to do var substitution 43 | vars: 44 | # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. 45 | #- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR 46 | # objref: 47 | # kind: Certificate 48 | # group: cert-manager.io 49 | # version: v1alpha2 50 | # name: serving-cert # this name should match the one in certificate.yaml 51 | # fieldref: 52 | # fieldpath: metadata.namespace 53 | #- name: CERTIFICATE_NAME 54 | # objref: 55 | # kind: Certificate 56 | # group: cert-manager.io 57 | # version: v1alpha2 58 | # name: serving-cert # this name should match the one in certificate.yaml 59 | #- name: SERVICE_NAMESPACE # namespace of the service 60 | # objref: 61 | # kind: Service 62 | # version: v1 63 | # name: webhook-service 64 | # fieldref: 65 | # fieldpath: metadata.namespace 66 | #- name: SERVICE_NAME 67 | # objref: 68 | # kind: Service 69 | # version: v1 70 | # name: webhook-service 71 | -------------------------------------------------------------------------------- /config/yurt-app-manager/default/manager_auth_proxy_patch.yaml: -------------------------------------------------------------------------------- 1 | # This patch inject a sidecar container which is a HTTP proxy for the 2 | # controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. 3 | apiVersion: apps/v1 4 | kind: Deployment 5 | metadata: 6 | name: manager 7 | namespace: kube-system 8 | spec: 9 | template: 10 | spec: 11 | containers: 12 | - name: kube-rbac-proxy 13 | image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 14 | args: 15 | - "--secure-listen-address=0.0.0.0:8443" 16 | - "--upstream=http://127.0.0.1:8080/" 17 | - "--logtostderr=true" 18 | - "--v=10" 19 | ports: 20 | - containerPort: 8443 21 | name: https 22 | - name: manager 23 | args: 24 | - "--metrics-addr=127.0.0.1:8080" 25 | - "--enable-leader-election" 26 | -------------------------------------------------------------------------------- /config/yurt-app-manager/default/manager_webhook_patch.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: manager 5 | namespace: kube-system 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: manager 11 | ports: 12 | - containerPort: 9443 13 | name: webhook-server 14 | protocol: TCP 15 | volumeMounts: 16 | - mountPath: /tmp/k8s-webhook-server/serving-certs 17 | name: cert 18 | readOnly: true 19 | volumes: 20 | - name: cert 21 | secret: 22 | defaultMode: 420 23 | secretName: yurt-app-webhook-certs 24 | -------------------------------------------------------------------------------- /config/yurt-app-manager/default/webhookcainjection_patch.yaml: -------------------------------------------------------------------------------- 1 | # This patch add annotation to admission webhook config and 2 | # the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. 3 | apiVersion: admissionregistration.k8s.io/v1 4 | kind: MutatingWebhookConfiguration 5 | metadata: 6 | name: mutating-webhook-configuration 7 | annotations: 8 | cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) 9 | --- 10 | apiVersion: admissionregistration.k8s.io/v1beta1 11 | kind: ValidatingWebhookConfiguration 12 | metadata: 13 | name: validating-webhook-configuration 14 | annotations: 15 | cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) 16 | -------------------------------------------------------------------------------- /config/yurt-app-manager/manager/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - manager.yaml 3 | apiVersion: kustomize.config.k8s.io/v1beta1 4 | kind: Kustomization 5 | images: 6 | - name: controller 7 | newName: registry.cn-hangzhou.aliyuncs.com/edge-kubernetes/yurt-app-manager 8 | newTag: test-e0768f3 9 | patchesStrategicMerge: 10 | - patches.yaml 11 | -------------------------------------------------------------------------------- /config/yurt-app-manager/manager/manager.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: manager 6 | namespace: kube-system 7 | labels: 8 | control-plane: yurt-app-manager 9 | spec: 10 | selector: 11 | matchLabels: 12 | control-plane: yurt-app-manager 13 | replicas: 2 14 | template: 15 | metadata: 16 | labels: 17 | control-plane: yurt-app-manager 18 | spec: 19 | tolerations: 20 | nodeSelector: 21 | priorityClassName: system-node-critical 22 | containers: 23 | - command: 24 | - /usr/local/bin/yurt-app-manager 25 | args: 26 | - --enable-leader-election 27 | - --v=4 28 | image: controller:latest 29 | imagePullPolicy: Always 30 | name: manager 31 | terminationGracePeriodSeconds: 10 32 | -------------------------------------------------------------------------------- /config/yurt-app-manager/manager/patches.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: manager 6 | namespace: kube-system 7 | spec: 8 | template: 9 | spec: 10 | tolerations: 11 | - key: "node-role.alibabacloud.com/addon" 12 | operator: "Exists" 13 | effect: "NoSchedule" 14 | - key: "node-role.kubernetes.io/master" 15 | operator: "Exists" 16 | effect: "NoSchedule" 17 | nodeSelector: 18 | beta.kubernetes.io/arch: amd64 19 | beta.kubernetes.io/os: linux 20 | openyurt.io/is-edge-worker: "false" 21 | -------------------------------------------------------------------------------- /config/yurt-app-manager/prometheus/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - monitor.yaml 3 | -------------------------------------------------------------------------------- /config/yurt-app-manager/prometheus/monitor.yaml: -------------------------------------------------------------------------------- 1 | 2 | # Prometheus Monitor Service (Metrics) 3 | apiVersion: monitoring.coreos.com/v1 4 | kind: ServiceMonitor 5 | metadata: 6 | labels: 7 | control-plane: yurt-app-manager 8 | name: manager-metrics-monitor 9 | namespace: kube-system 10 | spec: 11 | endpoints: 12 | - path: /metrics 13 | port: https 14 | selector: 15 | matchLabels: 16 | control-plane: yurt-app-manager 17 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/auth_proxy_client_clusterrole.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1beta1 2 | kind: ClusterRole 3 | metadata: 4 | name: metrics-reader 5 | rules: 6 | - nonResourceURLs: ["/metrics"] 7 | verbs: ["get"] 8 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/auth_proxy_role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: proxy-role 5 | rules: 6 | - apiGroups: ["authentication.k8s.io"] 7 | resources: 8 | - tokenreviews 9 | verbs: ["create"] 10 | - apiGroups: ["authorization.k8s.io"] 11 | resources: 12 | - subjectaccessreviews 13 | verbs: ["create"] 14 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/auth_proxy_role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: proxy-rolebinding 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: proxy-role 9 | subjects: 10 | - kind: ServiceAccount 11 | name: default 12 | namespace: kube-system 13 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/auth_proxy_service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | control-plane: yurt-app-manager 6 | name: manager-metrics-service 7 | namespace: kube-system 8 | spec: 9 | ports: 10 | - name: https 11 | port: 8443 12 | targetPort: https 13 | selector: 14 | control-plane: yurt-app-manager 15 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - role.yaml 3 | - role_binding.yaml 4 | - leader_election_role.yaml 5 | - leader_election_role_binding.yaml 6 | # Comment the following 4 lines if you want to disable 7 | # the auth proxy (https://github.com/brancz/kube-rbac-proxy) 8 | # which protects your /metrics endpoint. 9 | #- auth_proxy_service.yaml 10 | #- auth_proxy_role.yaml 11 | #- auth_proxy_role_binding.yaml 12 | #- auth_proxy_client_clusterrole.yaml 13 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/leader_election_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions to do leader election. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: Role 4 | metadata: 5 | name: leader-election-role 6 | rules: 7 | - apiGroups: 8 | - "" 9 | resources: 10 | - configmaps 11 | verbs: 12 | - get 13 | - list 14 | - watch 15 | - create 16 | - update 17 | - patch 18 | - delete 19 | - apiGroups: 20 | - "" 21 | resources: 22 | - configmaps/status 23 | verbs: 24 | - get 25 | - update 26 | - patch 27 | - apiGroups: 28 | - "" 29 | resources: 30 | - events 31 | verbs: 32 | - create 33 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/leader_election_role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: leader-election-rolebinding 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: Role 8 | name: leader-election-role 9 | subjects: 10 | - kind: ServiceAccount 11 | name: default 12 | namespace: kube-system 13 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/nodepool_editor_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to edit nodepools. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: nodepool-editor-role 6 | rules: 7 | - apiGroups: 8 | - apps.openyurt.io 9 | resources: 10 | - nodepools 11 | verbs: 12 | - create 13 | - delete 14 | - get 15 | - list 16 | - patch 17 | - update 18 | - watch 19 | - apiGroups: 20 | - apps.openyurt.io 21 | resources: 22 | - nodepools/status 23 | verbs: 24 | - get 25 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/nodepool_viewer_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to view nodepools. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: nodepool-viewer-role 6 | rules: 7 | - apiGroups: 8 | - apps.openyurt.io 9 | resources: 10 | - nodepools 11 | verbs: 12 | - get 13 | - list 14 | - watch 15 | - apiGroups: 16 | - apps.openyurt.io 17 | resources: 18 | - nodepools/status 19 | verbs: 20 | - get 21 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: manager-rolebinding 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: manager-role 9 | subjects: 10 | - kind: ServiceAccount 11 | name: default 12 | namespace: kube-system 13 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/yurtappset_editor_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to edit yurtappsets. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: yurtappset-editor-role 6 | rules: 7 | - apiGroups: 8 | - apps.openyurt.io 9 | resources: 10 | - yurtappsets 11 | verbs: 12 | - create 13 | - delete 14 | - get 15 | - list 16 | - patch 17 | - update 18 | - watch 19 | - apiGroups: 20 | - apps.openyurt.io 21 | resources: 22 | - yurtappsets/status 23 | verbs: 24 | - get 25 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/yurtappset_viewer_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to view yurtappsets. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: yurtappset-viewer-role 6 | rules: 7 | - apiGroups: 8 | - apps.openyurt.io 9 | resources: 10 | - yurtappsets 11 | verbs: 12 | - get 13 | - list 14 | - watch 15 | - apiGroups: 16 | - apps.openyurt.io 17 | resources: 18 | - yurtappsets/status 19 | verbs: 20 | - get 21 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/yurtingress_editor_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to edit yurtingresses. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: yurtingress-editor-role 6 | rules: 7 | - apiGroups: 8 | - apps.openyurt.io 9 | resources: 10 | - yurtingresses 11 | verbs: 12 | - create 13 | - delete 14 | - get 15 | - list 16 | - patch 17 | - update 18 | - watch 19 | - apiGroups: 20 | - apps.openyurt.io 21 | resources: 22 | - yurtingresses/status 23 | verbs: 24 | - get 25 | -------------------------------------------------------------------------------- /config/yurt-app-manager/rbac/yurtingress_viewer_role.yaml: -------------------------------------------------------------------------------- 1 | # permissions for end users to view yurtingresses. 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRole 4 | metadata: 5 | name: yurtingress-viewer-role 6 | rules: 7 | - apiGroups: 8 | - apps.openyurt.io 9 | resources: 10 | - yurtingresses 11 | verbs: 12 | - get 13 | - list 14 | - watch 15 | - apiGroups: 16 | - apps.openyurt.io 17 | resources: 18 | - yurtingresses/status 19 | verbs: 20 | - get 21 | -------------------------------------------------------------------------------- /config/yurt-app-manager/webhook/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - manifests.yaml 3 | - service.yaml 4 | - secret.yaml 5 | 6 | configurations: 7 | - kustomizeconfig.yaml 8 | 9 | patchesStrategicMerge: 10 | - patch_manifests.yaml 11 | -------------------------------------------------------------------------------- /config/yurt-app-manager/webhook/kustomizeconfig.yaml: -------------------------------------------------------------------------------- 1 | # the following config is for teaching kustomize where to look at when substituting vars. 2 | # It requires kustomize v2.1.0 or newer to work properly. 3 | nameReference: 4 | - kind: Service 5 | version: v1 6 | fieldSpecs: 7 | - kind: MutatingWebhookConfiguration 8 | group: admissionregistration.k8s.io 9 | path: webhooks/clientConfig/service/name 10 | - kind: ValidatingWebhookConfiguration 11 | group: admissionregistration.k8s.io 12 | path: webhooks/clientConfig/service/name 13 | 14 | namespace: 15 | - kind: MutatingWebhookConfiguration 16 | group: admissionregistration.k8s.io 17 | path: webhooks/clientConfig/service/namespace 18 | create: true 19 | - kind: ValidatingWebhookConfiguration 20 | group: admissionregistration.k8s.io 21 | path: webhooks/clientConfig/service/namespace 22 | create: true 23 | 24 | varReference: 25 | - path: metadata/annotations 26 | -------------------------------------------------------------------------------- /config/yurt-app-manager/webhook/patch_manifests.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: admissionregistration.k8s.io/v1 3 | kind: MutatingWebhookConfiguration 4 | metadata: 5 | name: mutating-webhook-configuration 6 | annotations: 7 | template: "" 8 | --- 9 | apiVersion: admissionregistration.k8s.io/v1 10 | kind: ValidatingWebhookConfiguration 11 | metadata: 12 | name: validating-webhook-configuration 13 | annotations: 14 | template: "" 15 | -------------------------------------------------------------------------------- /config/yurt-app-manager/webhook/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: webhook-certs 5 | namespace: kube-system 6 | -------------------------------------------------------------------------------- /config/yurt-app-manager/webhook/service.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: webhook-service 6 | namespace: kube-system 7 | spec: 8 | ports: 9 | - port: 443 10 | targetPort: 9876 11 | selector: 12 | control-plane: yurt-app-manager 13 | -------------------------------------------------------------------------------- /docs/images/yurtappdaemon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openyurtio/yurt-app-manager/c4e65977bcc78ac2936f1be9aa5872095a1777c2/docs/images/yurtappdaemon.png -------------------------------------------------------------------------------- /docs/images/yurtappset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openyurtio/yurt-app-manager/c4e65977bcc78ac2936f1be9aa5872095a1777c2/docs/images/yurtappset.png -------------------------------------------------------------------------------- /docs/yurt-app-manager-dev-tutorial.md: -------------------------------------------------------------------------------- 1 | # Yurt-app-manager Tutorial for Developor 2 | 3 | This document introduces how to build and install yurt-app-manager controller. 4 | 5 | ## Label cloud nodes and edge nodes 6 | ``` bash 7 | $ kubectl get nodes -o wide 8 | 9 | NAME STATUS ROLES AGE VERSION INTERNAL-IP 10 | k8s-node1 Ready 20d v1.16.2 10.48.115.9 11 | k8s-node2 Ready 20d v1.16.2 10.48.115.10 12 | master Ready master 20d v1.16.2 10.48.115.8 13 | ``` 14 | and we will use node `master` as the cloud node. 15 | 16 | We label the cloud node with value `false`, 17 | ```bash 18 | $ kubectl label node master openyurt.io/is-edge-worker=false 19 | master labeled 20 | ``` 21 | 22 | and the edge node with value `true`. 23 | ```bash 24 | $ kubectl label node k8s-node1 openyurt.io/is-edge-worker=true 25 | k8s-node1 labeled 26 | $ kubectl label node k8s-node2 openyurt.io/is-edge-worker=true 27 | k8s-node2 labeled 28 | ``` 29 | 30 | ## clone yurt-app-manger code 31 | ``` 32 | # cd $GOPATH/src/github.com/openyurtio 33 | # git clone git@github.com:openyurtio/yurt-app-manager.git 34 | # cd yurt-app-manager 35 | ``` 36 | 37 | ## push yurt-app-manager image to your own registry 38 | 39 | for example 40 | ``` 41 | make push REPO=registry.cn-your-registry.com/edge-kubernetes 42 | ``` 43 | 44 | if REPO value is assigned `registry.cn-your-registry.com/edge-kubernetes`, the `make push` command will eventually build an image named registry.cn-your-registry.com/edge-kubernetes/yurt-app-manager:{git commit id} and push it into your own repository. And `make push` command will also create a file named `yurt-app-manager.yaml` in _output/yamls dir. You need to set the REPO variable correctly。 45 | 46 | ## install nodepool and yurtappset controller 47 | ``` 48 | kubectl apply -f _output/yamls/yurt-app-manager.yaml 49 | ``` 50 | 51 | ## check 52 | 53 | > use `kubectl get crd` command to check that the CRD is successfully installed 54 | ``` 55 | # kubectl get crd 56 | nodepools.apps.openyurt.io 2021-04-23T08:54:31Z 57 | yurtappsets.apps.openyurt.io 2021-04-23T08:54:31Z 58 | ``` 59 | > use `kubectl get pod -n kube-system` command to check whether the yurt-app-manager pod is running 60 | ``` 61 | # kubectl get pod -n kube-system 62 | yurt-app-manager-78f657cbf4-c94gm 1/1 Running 0 5d2h 63 | yurt-app-manager-78f657cbf4-zwt22 1/1 Running 0 5d2h 64 | ``` 65 | 66 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/openyurtio/yurt-app-manager 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/onsi/ginkgo v1.16.4 7 | github.com/onsi/ginkgo/v2 v2.1.4 8 | github.com/onsi/gomega v1.19.0 9 | github.com/pkg/errors v0.9.1 10 | github.com/spf13/cobra v1.1.3 11 | github.com/spf13/pflag v1.0.5 12 | github.com/stretchr/testify v1.7.0 13 | k8s.io/api v0.22.3 14 | k8s.io/apimachinery v0.22.3 15 | k8s.io/client-go v0.22.3 16 | k8s.io/component-helpers v0.22.3 17 | k8s.io/klog v1.0.0 18 | k8s.io/kubernetes v1.22.3 19 | k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a 20 | sigs.k8s.io/controller-runtime v0.10.3 21 | sigs.k8s.io/yaml v1.2.0 22 | ) 23 | 24 | replace ( 25 | k8s.io/api => k8s.io/api v0.22.3 26 | k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.22.3 27 | k8s.io/apimachinery => k8s.io/apimachinery v0.22.3 28 | k8s.io/apiserver => k8s.io/apiserver v0.22.3 29 | k8s.io/cli-runtime => k8s.io/cli-runtime v0.22.3 30 | k8s.io/client-go => k8s.io/client-go v0.22.3 31 | k8s.io/cloud-provider => k8s.io/cloud-provider v0.22.3 32 | k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.22.3 33 | k8s.io/code-generator => k8s.io/code-generator v0.22.3 34 | k8s.io/component-base => k8s.io/component-base v0.22.3 35 | k8s.io/component-helpers => k8s.io/component-helpers v0.22.3 36 | k8s.io/controller-manager => k8s.io/controller-manager v0.22.3 37 | k8s.io/cri-api => k8s.io/cri-api v0.22.3 38 | k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.22.3 39 | k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.22.3 40 | k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.22.3 41 | k8s.io/kube-proxy => k8s.io/kube-proxy v0.22.3 42 | k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.22.3 43 | k8s.io/kubectl => k8s.io/kubectl v0.22.3 44 | k8s.io/kubelet => k8s.io/kubelet v0.22.3 45 | k8s.io/kubernetes => github.com/kubernetes/kubernetes v1.22.3 46 | k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.22.3 47 | k8s.io/metrics => k8s.io/metrics v0.22.3 48 | k8s.io/mount-utils => k8s.io/mount-utils v0.22.3 49 | k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.22.3 50 | k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.22.3 51 | ) 52 | -------------------------------------------------------------------------------- /hack/dockerfiles/Dockerfile: -------------------------------------------------------------------------------- 1 | # multi-arch image building for yurthub 2 | 3 | FROM --platform=${BUILDPLATFORM} golang:1.17.1 as builder 4 | ADD . /build 5 | ARG TARGETOS TARGETARCH GIT_VERSION GOPROXY MIRROR_REPO 6 | WORKDIR /build/ 7 | RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GIT_VERSION=${GIT_VERSION:-undefined} make build 8 | 9 | FROM --platform=${TARGETPLATFORM} alpine:3.14 10 | ARG TARGETOS TARGETARCH MIRROR_REPO 11 | RUN if [ ! -z "${MIRROR_REPO+x}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${MIRROR_REPO}/g" /etc/apk/repositories; fi && \ 12 | apk add ca-certificates bash libc6-compat && update-ca-certificates && rm /var/cache/apk/* 13 | COPY --from=builder /build/_output/local/bin/${TARGETOS}/${TARGETARCH}/yurt-app-manager /usr/local/bin/yurt-app-manager 14 | ENTRYPOINT ["/usr/local/bin/yurt-app-manager"] -------------------------------------------------------------------------------- /hack/lib/build.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The OpenYurt Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | #!/usr/bin/env bash 16 | 17 | set -x 18 | 19 | # project_info generates the project information and the corresponding valuse 20 | # for 'ldflags -X' option 21 | # gitVersion: "vX.Y" used to indicate the last release version 22 | # gitCommit: the git commit id corresponding to this source code 23 | project_info() { 24 | PROJECT_INFO_PKG=${YURT_MOD}/pkg/projectinfo 25 | echo "-X ${PROJECT_INFO_PKG}.projectPrefix=${PROJECT_PREFIX}" 26 | echo "-X ${PROJECT_INFO_PKG}.labelPrefix=${LABEL_PREFIX}" 27 | echo "-X ${PROJECT_INFO_PKG}.gitVersion=${GIT_VERSION}" 28 | echo "-X ${PROJECT_INFO_PKG}.gitCommit=${GIT_COMMIT}" 29 | echo "-X ${PROJECT_INFO_PKG}.buildDate=${BUILD_DATE}" 30 | } 31 | 32 | # get_binary_dir_with_arch generated the binary's directory with GOOS and GOARCH. 33 | # eg: ./_output/bin/darwin/arm64/ 34 | get_binary_dir_with_arch(){ 35 | echo $1/$(go env GOOS)/$(go env GOARCH) 36 | } 37 | 38 | build_binary() { 39 | local goflags goldflags gcflags 40 | goldflags="${GOLDFLAGS:--s -w $(project_info)}" 41 | gcflags="${GOGCFLAGS:-}" 42 | goflags=${GOFLAGS:-} 43 | 44 | local arg 45 | for arg; do 46 | if [[ "${arg}" == -* ]]; then 47 | # Assume arguments starting with a dash are flags to pass to go. 48 | goflags+=("${arg}") 49 | fi 50 | done 51 | 52 | local bin_name=${BIN_NAME:-yurt-app-manager} 53 | local target_bin_dir=$(get_binary_dir_with_arch ${YURT_LOCAL_BIN_DIR}) 54 | rm -rf ${target_bin_dir} 55 | mkdir -p ${target_bin_dir} 56 | 57 | echo "Building ${bin_name}" 58 | go build -o ${target_bin_dir}/${bin_name} \ 59 | -ldflags "${goldflags:-}" \ 60 | -gcflags "${gcflags:-}" ${goflags} ${YURT_ROOT}/cmd/yurt-app-manager 61 | } 62 | 63 | # gen_yamls generates yaml files for the yurt-app-manager 64 | gen_yamls() { 65 | local OUT_YAML_DIR=$YURT_ROOT/_output/yamls 66 | local BUILD_YAML_DIR=${OUT_YAML_DIR}/build 67 | [ -f $BUILD_YAML_DIR ] || mkdir -p $BUILD_YAML_DIR 68 | mkdir -p ${BUILD_YAML_DIR} 69 | ( 70 | rm -rf ${BUILD_YAML_DIR}/yurt-app-manager 71 | cp -rf $YURT_ROOT/config/yurt-app-manager ${BUILD_YAML_DIR} 72 | cd ${BUILD_YAML_DIR}/yurt-app-manager/manager 73 | kustomize edit set image controller=$REPO/yurt-app-manager:${TAG} 74 | ) 75 | set +x 76 | echo "==== create yurt-app-manager.yaml in $OUT_YAML_DIR ====" 77 | kustomize build ${BUILD_YAML_DIR}/yurt-app-manager/default > ${OUT_YAML_DIR}/yurt-app-manager.yaml 78 | rm -Rf ${BUILD_YAML_DIR} 79 | } 80 | 81 | -------------------------------------------------------------------------------- /hack/lib/init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | YURT_MOD="$(head -1 $YURT_ROOT/go.mod | awk '{print $2}')" 22 | YURT_OUTPUT_DIR=${YURT_ROOT}/_output 23 | YURT_LOCAL_BIN_DIR=${YURT_OUTPUT_DIR}/local/bin 24 | 25 | YURT_E2E_TARGETS="tests/e2e/yurt-e2e-test" 26 | 27 | PROJECT_PREFIX=${PROJECT_PREFIX:-yurt} 28 | LABEL_PREFIX=${LABEL_PREFIX:-openyurt.io} 29 | GIT_COMMIT=$(git rev-parse --short HEAD) 30 | GIT_COMMIT_SHORT=$GIT_COMMIT 31 | GIT_VERSION=${GIT_VERSION:-$(git describe --abbrev=0 --tags)} 32 | BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') 33 | REPO=${REPO:-openyurt} 34 | TAG=${TAG:-${GIT_COMMIT_SHORT}} 35 | BIN_NAME=yurt-app-manager -------------------------------------------------------------------------------- /hack/lib/sync-api.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -l 2 | # Copyright 2022 The OpenYurt Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -e 17 | 18 | if [[ -n "$SSH_DEPLOY_KEY" ]] 19 | then 20 | mkdir -p ~/.ssh 21 | echo "$SSH_DEPLOY_KEY" > ~/.ssh/id_rsa 22 | chmod 600 ~/.ssh/id_rsa 23 | fi 24 | 25 | echo "git clone" 26 | cd .. 27 | git config --global user.email "openyurt-bot@openyurt.io" 28 | git config --global user.name "openyurt-bot" 29 | git clone --single-branch --depth 1 git@github.com:openyurtio/api.git yurt-api 30 | 31 | if [ -d "yurt-api/apps" ] 32 | then 33 | echo "api apps exists, remove it" 34 | rm -r yurt-api/apps/* 35 | else 36 | mkdir -p yurt-api/apps 37 | fi 38 | 39 | echo "update apps" 40 | cp -R yurt-app-manager/pkg/yurtappmanager/apis/apps/* yurt-api/apps/ 41 | # remove controller depends functions 42 | rm -rf yurt-api/apps/v1alpha1/defaults.go 43 | 44 | echo "update addtoschema" 45 | rm -rf yurt-api/addtoscheme_apps_v1alpha1.go 46 | cp yurt-app-manager/pkg/yurtappmanager/apis/addtoscheme_apps_v1alpha1.go yurt-api/addtoscheme_apps_v1alpha1.go 47 | 48 | echo "find import paths, and change them" 49 | find ./yurt-api -type f -name "*.go" -print0 | xargs -0 sed -i 's|github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/|github.com/openyurtio/api/apps/|g' 50 | 51 | cd yurt-api 52 | 53 | echo "test api" 54 | go mod tidy 55 | 56 | echo "push to yurt-api" 57 | echo "version: $VERSION, commit: $COMMIT_ID, tag: $TAG" 58 | 59 | if [ -z "$(git status --porcelain)" ]; then 60 | echo "nothing need to push, finished!" 61 | else 62 | git add . 63 | git commit -m "align with yurt-app-manager $VERSION from commit $COMMIT_ID" 64 | git tag "$VERSION" 65 | git push origin main 66 | fi 67 | 68 | if [[ $TAG == v* ]] ; 69 | then 70 | echo "push tag: TAG" 71 | git push origin "$TAG" 72 | fi -------------------------------------------------------------------------------- /hack/lib/sync-charts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -l 2 | # Copyright 2020 The OpenYurt Authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -e 17 | 18 | if [[ -n "$SSH_DEPLOY_KEY" ]] 19 | then 20 | mkdir -p ~/.ssh 21 | echo "$SSH_DEPLOY_KEY" > ~/.ssh/id_rsa 22 | chmod 600 ~/.ssh/id_rsa 23 | fi 24 | 25 | echo "git clone ${REPOSITORY_OWNER}/openyurt-helm" 26 | cd .. 27 | git config --global user.email "openyurt-bot@openyurt.io" 28 | git config --global user.name "openyurt-bot" 29 | git clone --single-branch --depth 1 git@github.com:${REPOSITORY_OWNER}/openyurt-helm.git openyurt-helm 30 | 31 | repoName=yurt-app-manager 32 | chartName=yurt-app-manager 33 | echo "clear openyurt-helm/charts/${chartName}" 34 | 35 | if [ -d "openyurt-helm/charts/${chartName}" ] 36 | then 37 | echo "charts ${chartName} exists, remove it" 38 | rm -r openyurt-helm/charts/${chartName}/* 39 | else 40 | mkdir -p openyurt-helm/charts/${chartName} 41 | fi 42 | 43 | echo "copy folder ${repoName}/charts/${chartName} to openyurt-helm/charts" 44 | 45 | cp -R ${repoName}/charts/${chartName}/* openyurt-helm/charts/${chartName}/ 46 | 47 | echo "push to repo openyurt-helm" 48 | echo "version: $VERSION, commit: $COMMIT_ID, tag: $TAG" 49 | 50 | cd openyurt-helm 51 | 52 | if [ -z "$(git status --porcelain)" ]; then 53 | echo "nothing need to push, finished!" 54 | else 55 | git add . 56 | git commit -m "align with charts ${repoName}/charts/${chartName} $VERSION from commit $COMMIT_ID" 57 | #git tag "$VERSION" 58 | git push origin main 59 | fi 60 | -------------------------------------------------------------------------------- /hack/make-rules/build-e2e.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" 18 | source "${YURT_ROOT}/hack/lib/init.sh" 19 | source "${YURT_ROOT}/hack/lib/build.sh" 20 | 21 | function build_e2e() { 22 | local goflags goldflags gcflags 23 | goldflags="${GOLDFLAGS:--s -w $(project_info)}" 24 | gcflags="${GOGCFLAGS:-}" 25 | goflags=${GOFLAGS:-} 26 | 27 | 28 | local target_bin_dir=$(get_binary_dir_with_arch ${YURT_LOCAL_BIN_DIR}) 29 | mkdir -p ${target_bin_dir} 30 | cd ${target_bin_dir} 31 | echo "Building ${YURT_E2E_TARGETS}" 32 | local testpkg="$(dirname ${YURT_E2E_TARGETS})" 33 | local filename="$(basename ${YURT_E2E_TARGETS})" 34 | go test -c -gcflags "${gcflags:-}" ${goflags} -o $filename "$YURT_ROOT/${testpkg}" 35 | } 36 | 37 | build_e2e 38 | -------------------------------------------------------------------------------- /hack/make-rules/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -x 18 | 19 | YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" 20 | source "${YURT_ROOT}/hack/lib/init.sh" 21 | source "${YURT_ROOT}/hack/lib/build.sh" 22 | 23 | build_binary "$@" 24 | -------------------------------------------------------------------------------- /hack/make-rules/check_license.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # exit immediately when a command fails 18 | set -e 19 | # only exit with zero if all commands of the pipeline exit successfully 20 | set -o pipefail 21 | # error on unset variables 22 | set -u 23 | 24 | licRes=$( 25 | find . -type f -regex '.*\.go\|.*\.sh' ! -path '*/vendor/*' -exec \ 26 | sh -c 'head -n5 $1 | grep -Eq "(Copyright|generated|GENERATED)" || echo -e $1' {} {} \; 27 | ) 28 | 29 | if [ -n "${licRes}" ]; then 30 | echo -e "license header checking failed:\\n${licRes}" 31 | exit 255 32 | fi -------------------------------------------------------------------------------- /hack/make-rules/generate_client.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2022 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -x 18 | set -e 19 | 20 | YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" 21 | 22 | TMP_DIR=$(mktemp -d) 23 | mkdir -p "${TMP_DIR}"/src/github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client 24 | cp -r ${YURT_ROOT}/{go.mod,go.sum} "${TMP_DIR}"/src/github.com/openyurtio/yurt-app-manager/ 25 | cp -r ${YURT_ROOT}/pkg/yurtappmanager/{apis,hack} "${TMP_DIR}"/src/github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/ 26 | 27 | ( 28 | cd "${TMP_DIR}"/src/github.com/openyurtio/yurt-app-manager/; 29 | HOLD_GO="${TMP_DIR}/src/github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/hack/hold.go" 30 | printf 'package hack\nimport "k8s.io/code-generator"\n' > ${HOLD_GO} 31 | go mod vendor 32 | GOPATH=${TMP_DIR} GO111MODULE=off /bin/bash vendor/k8s.io/code-generator/generate-groups.sh all \ 33 | github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis apps:v1alpha1 -h ./pkg/yurtappmanager/hack/boilerplate.go.txt 34 | ) 35 | 36 | rm -rf ./pkg/yurtappmanager/client/{clientset,informers,listers} 37 | mv "${TMP_DIR}"/src/github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/* ./pkg/yurtappmanager/client 38 | 39 | -------------------------------------------------------------------------------- /hack/make-rules/genyaml.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2022 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" 18 | source "${YURT_ROOT}/hack/lib/init.sh" 19 | source "${YURT_ROOT}/hack/lib/build.sh" 20 | 21 | gen_yamls "$@" 22 | -------------------------------------------------------------------------------- /hack/make-rules/verify_mod.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2022 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | set -u 19 | 20 | YURT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" 21 | 22 | go mod tidy 23 | 24 | if [ ! -z "$(git diff ${YURT_ROOT}/go.mod ${YURT_ROOT}/go.sum)" ]; then 25 | echo "Verify go mod error, please ensure go.mod has been tidied" 26 | exit -1 27 | fi -------------------------------------------------------------------------------- /hack/run-e2e-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 The OpenYurt Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -x 18 | set -e 19 | set -u 20 | 21 | YURT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P) 22 | source "${YURT_ROOT}/hack/lib/init.sh" 23 | source "${YURT_ROOT}/hack/lib/build.sh" 24 | 25 | KUBECONFIG=${KUBECONFIG:-${HOME}/.kube/config} 26 | 27 | 28 | # run e2e tests 29 | function run_e2e_tests { 30 | # check kubeconfig 31 | if [ ! -f "${KUBECONFIG}" ]; then 32 | echo "kubeconfig does not exist at ${KUBECONFIG}" 33 | exit -1 34 | fi 35 | 36 | local target_bin_dir=$(get_binary_dir_with_arch ${YURT_LOCAL_BIN_DIR}) 37 | local e2e_test_file_name=$(basename ${YURT_E2E_TARGETS}) 38 | ${target_bin_dir}/${e2e_test_file_name} -kubeconfig ${KUBECONFIG} 39 | } 40 | 41 | #deploy_app_manager 42 | 43 | run_e2e_tests 44 | -------------------------------------------------------------------------------- /pkg/projectinfo/projectinfo.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package projectinfo 18 | 19 | import ( 20 | "fmt" 21 | "runtime" 22 | ) 23 | 24 | var ( 25 | projectPrefix = "yurt" 26 | gitVersion = "v0.0.0" 27 | gitCommit = "unknown" 28 | buildDate = "1970-01-01T00:00:00Z" 29 | ) 30 | 31 | // GetYurtAppManagerName returns name of tunnel 32 | func GetYurtAppManagerName() string { 33 | return projectPrefix + "-app-manager" 34 | } 35 | 36 | // normalizeGitCommit reserve 7 characters for gitCommit 37 | func normalizeGitCommit(commit string) string { 38 | if len(commit) > 7 { 39 | return commit[:7] 40 | } 41 | 42 | return commit 43 | } 44 | 45 | // Info contains version information. 46 | type Info struct { 47 | GitVersion string `json:"gitVersion"` 48 | GitCommit string `json:"gitCommit"` 49 | BuildDate string `json:"buildDate"` 50 | GoVersion string `json:"goVersion"` 51 | Compiler string `json:"compiler"` 52 | Platform string `json:"platform"` 53 | } 54 | 55 | // Get returns the overall codebase version. 56 | func Get() Info { 57 | return Info{ 58 | GitVersion: gitVersion, 59 | GitCommit: normalizeGitCommit(gitCommit), 60 | BuildDate: buildDate, 61 | GoVersion: runtime.Version(), 62 | Compiler: runtime.Compiler, 63 | Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/addtoscheme_apps_v1alpha1.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package apis 18 | 19 | import ( 20 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 21 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1beta1" 22 | ) 23 | 24 | func init() { 25 | // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back 26 | AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme, v1beta1.SchemeBuilder.AddToScheme) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apis.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package apis 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | // AddToSchemes may be used to add all resources defined in the project to a Scheme 24 | var AddToSchemes runtime.SchemeBuilder 25 | 26 | // AddToScheme adds all Resources to the Scheme 27 | func AddToScheme(s *runtime.Scheme) error { 28 | return AddToSchemes.AddToScheme(s) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +groupName=apps.openyurt.io 18 | package v1alpha1 19 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1alpha1/groupversion_info.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package v1alpha1 contains API Schema definitions for the apps v1alpha1 API group 18 | // +kubebuilder:object:generate=true 19 | // +groupName=apps.openyurt.io 20 | package v1alpha1 21 | 22 | import ( 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | "sigs.k8s.io/controller-runtime/pkg/scheme" 25 | ) 26 | 27 | var ( 28 | // GroupVersion is group version used to register these objects 29 | GroupVersion = schema.GroupVersion{Group: "apps.openyurt.io", Version: "v1alpha1"} 30 | 31 | SchemeGroupVersion = GroupVersion 32 | 33 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme 34 | SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} 35 | 36 | // AddToScheme adds the types in this group-version to the given scheme. 37 | AddToScheme = SchemeBuilder.AddToScheme 38 | ) 39 | 40 | // Resource is required by pkg/client/listers/... 41 | func Resource(resource string) schema.GroupResource { 42 | return SchemeGroupVersion.WithResource(resource).GroupResource() 43 | } 44 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1alpha1/nodepool_conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // +kubebuilder:docs-gen:collapse=Apache License 17 | 18 | package v1alpha1 19 | 20 | /* 21 | Implementing the hub method is pretty easy -- we just have to add an empty 22 | method called `Hub()` to serve as a 23 | [marker](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/conversion?tab=doc#Hub). 24 | */ 25 | 26 | // Hub marks this type as a conversion hub. 27 | func (*NodePool) Hub() {} 28 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1alpha1/well_known_labels_annotations.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | @CHANGELOG 17 | OpenYurt Authors: 18 | change some const value 19 | */ 20 | 21 | package v1alpha1 22 | 23 | // YurtAppSet related labels and annotations 24 | const ( 25 | // ControllerRevisionHashLabelKey is used to record the controller revision of current resource. 26 | ControllerRevisionHashLabelKey = "apps.openyurt.io/controller-revision-hash" 27 | 28 | // PoolNameLabelKey is used to record the name of current pool. 29 | PoolNameLabelKey = "apps.openyurt.io/pool-name" 30 | 31 | // SpecifiedDeleteKey indicates this object should be deleted, and the value could be the deletion option. 32 | SpecifiedDeleteKey = "apps.openyurt.io/specified-delete" 33 | 34 | // AnnotationPatchKey indicates the patch for every sub pool 35 | AnnotationPatchKey = "apps.openyurt.io/patch" 36 | 37 | AnnotationRefNodePool = "apps.openyurt.io/ref-nodepool" 38 | ) 39 | 40 | // NodePool related labels and annotations 41 | const ( 42 | // LabelDesiredNodePool indicates which nodepool the node want to join 43 | LabelDesiredNodePool = "apps.openyurt.io/desired-nodepool" 44 | 45 | // LabelCurrentNodePool indicates which nodepool the node is currently 46 | // belonging to 47 | LabelCurrentNodePool = "apps.openyurt.io/nodepool" 48 | 49 | // LabelCurrentYurtAppDaemon indicates which service the yurtappdaemon is currently 50 | // belonging to 51 | LabelCurrentYurtAppDaemon = "apps.openyurt.io/yurtappdaemon" 52 | 53 | AnnotationPrevAttrs = "nodepool.openyurt.io/previous-attributes" 54 | 55 | // DefaultCloudNodePoolName defines the name of the default cloud nodepool 56 | DefaultCloudNodePoolName = "default-nodepool" 57 | 58 | // DefaultEdgeNodePoolName defines the name of the default edge nodepool 59 | DefaultEdgeNodePoolName = "default-edge-nodepool" 60 | 61 | // ServiceTopologyKey is the toplogy key that will be attached to node, 62 | // the value will be the name of the nodepool 63 | ServiceTopologyKey = "topology.kubernetes.io/zone" 64 | ) 65 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +groupName=apps.openyurt.io 18 | package v1beta1 19 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1beta1/groupversion_info.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package v1beta1 contains API Schema definitions for the apps v1beta1 API group 18 | // +kubebuilder:object:generate=true 19 | // +groupName=apps.openyurt.io 20 | package v1beta1 21 | 22 | import ( 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | "sigs.k8s.io/controller-runtime/pkg/scheme" 25 | ) 26 | 27 | var ( 28 | // GroupVersion is group version used to register these objects 29 | GroupVersion = schema.GroupVersion{Group: "apps.openyurt.io", Version: "v1beta1"} 30 | 31 | SchemeGroupVersion = GroupVersion 32 | 33 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme 34 | SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} 35 | 36 | // AddToScheme adds the types in this group-version to the given scheme. 37 | AddToScheme = SchemeBuilder.AddToScheme 38 | ) 39 | 40 | // Resource is required by pkg/client/listers/... 41 | func Resource(resource string) schema.GroupResource { 42 | return SchemeGroupVersion.WithResource(resource).GroupResource() 43 | } 44 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/apis/apps/v1beta1/nodepool_conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // +kubebuilder:docs-gen:collapse=Apache License 17 | 18 | package v1beta1 19 | 20 | /* 21 | For imports, we'll need the controller-runtime 22 | [`conversion`](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/conversion?tab=doc) 23 | package, plus the API version for our hub type (v1), and finally some of the 24 | standard packages. 25 | */ 26 | import ( 27 | "k8s.io/klog" 28 | "sigs.k8s.io/controller-runtime/pkg/conversion" 29 | 30 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 31 | ) 32 | 33 | // +kubebuilder:docs-gen:collapse=Imports 34 | 35 | func (src *NodePool) ConvertTo(dstRaw conversion.Hub) error { 36 | dst := dstRaw.(*v1alpha1.NodePool) 37 | 38 | dst.ObjectMeta = src.ObjectMeta 39 | 40 | dst.Spec.Type = v1alpha1.NodePoolType(src.Spec.Type) 41 | dst.Spec.Selector = src.Spec.Selector 42 | dst.Spec.Annotations = src.Spec.Annotations 43 | dst.Spec.Taints = src.Spec.Taints 44 | 45 | dst.Status.ReadyNodeNum = src.Status.ReadyNodeNum 46 | dst.Status.UnreadyNodeNum = src.Status.UnreadyNodeNum 47 | dst.Status.Nodes = src.Status.Nodes 48 | 49 | klog.Infof("convert from v1beta1 to v1alpha1 for %s", dst.Name) 50 | 51 | return nil 52 | } 53 | 54 | func (dst *NodePool) ConvertFrom(srcRaw conversion.Hub) error { 55 | src := srcRaw.(*v1alpha1.NodePool) 56 | 57 | dst.ObjectMeta = src.ObjectMeta 58 | 59 | dst.Spec.Type = NodePoolType(src.Spec.Type) 60 | dst.Spec.Selector = src.Spec.Selector 61 | dst.Spec.Annotations = src.Spec.Annotations 62 | dst.Spec.Taints = src.Spec.Taints 63 | 64 | dst.Status.ReadyNodeNum = src.Status.ReadyNodeNum 65 | dst.Status.UnreadyNodeNum = src.Status.UnreadyNodeNum 66 | dst.Status.Nodes = src.Status.Nodes 67 | 68 | klog.Infof("convert from v1alpha1 to v1beta1 for %s", dst.Name) 69 | return nil 70 | } 71 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated clientset. 20 | package versioned 21 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/fake/clientset_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | clientset "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/clientset/versioned" 23 | appsv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1" 24 | fakeappsv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1/fake" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | "k8s.io/apimachinery/pkg/watch" 27 | "k8s.io/client-go/discovery" 28 | fakediscovery "k8s.io/client-go/discovery/fake" 29 | "k8s.io/client-go/testing" 30 | ) 31 | 32 | // NewSimpleClientset returns a clientset that will respond with the provided objects. 33 | // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, 34 | // without applying any validations and/or defaults. It shouldn't be considered a replacement 35 | // for a real clientset and is mostly useful in simple unit tests. 36 | func NewSimpleClientset(objects ...runtime.Object) *Clientset { 37 | o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) 38 | for _, obj := range objects { 39 | if err := o.Add(obj); err != nil { 40 | panic(err) 41 | } 42 | } 43 | 44 | cs := &Clientset{tracker: o} 45 | cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} 46 | cs.AddReactor("*", "*", testing.ObjectReaction(o)) 47 | cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { 48 | gvr := action.GetResource() 49 | ns := action.GetNamespace() 50 | watch, err := o.Watch(gvr, ns) 51 | if err != nil { 52 | return false, nil, err 53 | } 54 | return true, watch, nil 55 | }) 56 | 57 | return cs 58 | } 59 | 60 | // Clientset implements clientset.Interface. Meant to be embedded into a 61 | // struct to get a default implementation. This makes faking out just the method 62 | // you want to test easier. 63 | type Clientset struct { 64 | testing.Fake 65 | discovery *fakediscovery.FakeDiscovery 66 | tracker testing.ObjectTracker 67 | } 68 | 69 | func (c *Clientset) Discovery() discovery.DiscoveryInterface { 70 | return c.discovery 71 | } 72 | 73 | func (c *Clientset) Tracker() testing.ObjectTracker { 74 | return c.tracker 75 | } 76 | 77 | var ( 78 | _ clientset.Interface = &Clientset{} 79 | _ testing.FakeClient = &Clientset{} 80 | ) 81 | 82 | // AppsV1alpha1 retrieves the AppsV1alpha1Client 83 | func (c *Clientset) AppsV1alpha1() appsv1alpha1.AppsV1alpha1Interface { 84 | return &fakeappsv1alpha1.FakeAppsV1alpha1{Fake: &c.Fake} 85 | } 86 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/fake/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | appsv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var scheme = runtime.NewScheme() 31 | var codecs = serializer.NewCodecFactory(scheme) 32 | 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | appsv1alpha1.AddToScheme, 35 | } 36 | 37 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 38 | // of clientsets, like in: 39 | // 40 | // import ( 41 | // "k8s.io/client-go/kubernetes" 42 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 43 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 44 | // ) 45 | // 46 | // kclientset, _ := kubernetes.NewForConfig(c) 47 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 48 | // 49 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 50 | // correctly. 51 | var AddToScheme = localSchemeBuilder.AddToScheme 52 | 53 | func init() { 54 | v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) 55 | utilruntime.Must(AddToScheme(scheme)) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/scheme/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package scheme 20 | 21 | import ( 22 | appsv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var Scheme = runtime.NewScheme() 31 | var Codecs = serializer.NewCodecFactory(Scheme) 32 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | appsv1alpha1.AddToScheme, 35 | } 36 | 37 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 38 | // of clientsets, like in: 39 | // 40 | // import ( 41 | // "k8s.io/client-go/kubernetes" 42 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 43 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 44 | // ) 45 | // 46 | // kclientset, _ := kubernetes.NewForConfig(c) 47 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 48 | // 49 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 50 | // correctly. 51 | var AddToScheme = localSchemeBuilder.AddToScheme 52 | 53 | func init() { 54 | v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 55 | utilruntime.Must(AddToScheme(Scheme)) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1alpha1 21 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeAppsV1alpha1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeAppsV1alpha1) NodePools() v1alpha1.NodePoolInterface { 32 | return &FakeNodePools{c} 33 | } 34 | 35 | func (c *FakeAppsV1alpha1) UnitedDeployments(namespace string) v1alpha1.UnitedDeploymentInterface { 36 | return &FakeUnitedDeployments{c, namespace} 37 | } 38 | 39 | func (c *FakeAppsV1alpha1) YurtAppDaemons(namespace string) v1alpha1.YurtAppDaemonInterface { 40 | return &FakeYurtAppDaemons{c, namespace} 41 | } 42 | 43 | func (c *FakeAppsV1alpha1) YurtAppSets(namespace string) v1alpha1.YurtAppSetInterface { 44 | return &FakeYurtAppSets{c, namespace} 45 | } 46 | 47 | func (c *FakeAppsV1alpha1) YurtIngresses() v1alpha1.YurtIngressInterface { 48 | return &FakeYurtIngresses{c} 49 | } 50 | 51 | // RESTClient returns a RESTClient that is used to communicate 52 | // with API server by this client implementation. 53 | func (c *FakeAppsV1alpha1) RESTClient() rest.Interface { 54 | var ret *rest.RESTClient 55 | return ret 56 | } 57 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | type NodePoolExpansion interface{} 22 | 23 | type UnitedDeploymentExpansion interface{} 24 | 25 | type YurtAppDaemonExpansion interface{} 26 | 27 | type YurtAppSetExpansion interface{} 28 | 29 | type YurtIngressExpansion interface{} 30 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/generic_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package client 18 | 19 | import ( 20 | kubeclientset "k8s.io/client-go/kubernetes" 21 | "k8s.io/client-go/rest" 22 | 23 | yurtappclientset "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/clientset/versioned" 24 | ) 25 | 26 | // GenericClientset defines a generic client 27 | type GenericClientset struct { 28 | KubeClient kubeclientset.Interface 29 | YurtappClient yurtappclientset.Interface 30 | } 31 | 32 | // NewForConfig creates a new Clientset for the given config. 33 | func newForConfig(c *rest.Config) (*GenericClientset, error) { 34 | kubeClient, err := kubeclientset.NewForConfig(c) 35 | if err != nil { 36 | return nil, err 37 | } 38 | yurtClient, err := yurtappclientset.NewForConfig(c) 39 | if err != nil { 40 | return nil, err 41 | } 42 | return &GenericClientset{ 43 | KubeClient: kubeClient, 44 | YurtappClient: yurtClient, 45 | }, nil 46 | } 47 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/informers/externalversions/apps/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package apps 20 | 21 | import ( 22 | v1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/informers/externalversions/apps/v1alpha1" 23 | internalinterfaces "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/informers/externalversions/internalinterfaces" 24 | ) 25 | 26 | // Interface provides access to each of this group's versions. 27 | type Interface interface { 28 | // V1alpha1 provides access to shared informers for resources in V1alpha1. 29 | V1alpha1() v1alpha1.Interface 30 | } 31 | 32 | type group struct { 33 | factory internalinterfaces.SharedInformerFactory 34 | namespace string 35 | tweakListOptions internalinterfaces.TweakListOptionsFunc 36 | } 37 | 38 | // New returns a new Interface. 39 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 40 | return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 41 | } 42 | 43 | // V1alpha1 returns a new v1alpha1.Interface. 44 | func (g *group) V1alpha1() v1alpha1.Interface { 45 | return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) 46 | } 47 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/informers/externalversions/apps/v1alpha1/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | import ( 22 | internalinterfaces "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to all the informers in this group version. 26 | type Interface interface { 27 | // NodePools returns a NodePoolInformer. 28 | NodePools() NodePoolInformer 29 | // UnitedDeployments returns a UnitedDeploymentInformer. 30 | UnitedDeployments() UnitedDeploymentInformer 31 | // YurtAppDaemons returns a YurtAppDaemonInformer. 32 | YurtAppDaemons() YurtAppDaemonInformer 33 | // YurtAppSets returns a YurtAppSetInformer. 34 | YurtAppSets() YurtAppSetInformer 35 | // YurtIngresses returns a YurtIngressInformer. 36 | YurtIngresses() YurtIngressInformer 37 | } 38 | 39 | type version struct { 40 | factory internalinterfaces.SharedInformerFactory 41 | namespace string 42 | tweakListOptions internalinterfaces.TweakListOptionsFunc 43 | } 44 | 45 | // New returns a new Interface. 46 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 47 | return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 48 | } 49 | 50 | // NodePools returns a NodePoolInformer. 51 | func (v *version) NodePools() NodePoolInformer { 52 | return &nodePoolInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} 53 | } 54 | 55 | // UnitedDeployments returns a UnitedDeploymentInformer. 56 | func (v *version) UnitedDeployments() UnitedDeploymentInformer { 57 | return &unitedDeploymentInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 58 | } 59 | 60 | // YurtAppDaemons returns a YurtAppDaemonInformer. 61 | func (v *version) YurtAppDaemons() YurtAppDaemonInformer { 62 | return &yurtAppDaemonInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 63 | } 64 | 65 | // YurtAppSets returns a YurtAppSetInformer. 66 | func (v *version) YurtAppSets() YurtAppSetInformer { 67 | return &yurtAppSetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 68 | } 69 | 70 | // YurtIngresses returns a YurtIngressInformer. 71 | func (v *version) YurtIngresses() YurtIngressInformer { 72 | return &yurtIngressInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} 73 | } 74 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/informers/externalversions/generic.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package externalversions 20 | 21 | import ( 22 | "fmt" 23 | 24 | v1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | cache "k8s.io/client-go/tools/cache" 27 | ) 28 | 29 | // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 30 | // sharedInformers based on type 31 | type GenericInformer interface { 32 | Informer() cache.SharedIndexInformer 33 | Lister() cache.GenericLister 34 | } 35 | 36 | type genericInformer struct { 37 | informer cache.SharedIndexInformer 38 | resource schema.GroupResource 39 | } 40 | 41 | // Informer returns the SharedIndexInformer. 42 | func (f *genericInformer) Informer() cache.SharedIndexInformer { 43 | return f.informer 44 | } 45 | 46 | // Lister returns the GenericLister. 47 | func (f *genericInformer) Lister() cache.GenericLister { 48 | return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 49 | } 50 | 51 | // ForResource gives generic access to a shared informer of the matching type 52 | // TODO extend this to unknown resources with a client pool 53 | func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 54 | switch resource { 55 | // Group=apps.openyurt.io, Version=v1alpha1 56 | case v1alpha1.SchemeGroupVersion.WithResource("nodepools"): 57 | return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().NodePools().Informer()}, nil 58 | case v1alpha1.SchemeGroupVersion.WithResource("uniteddeployments"): 59 | return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().UnitedDeployments().Informer()}, nil 60 | case v1alpha1.SchemeGroupVersion.WithResource("yurtappdaemons"): 61 | return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().YurtAppDaemons().Informer()}, nil 62 | case v1alpha1.SchemeGroupVersion.WithResource("yurtappsets"): 63 | return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().YurtAppSets().Informer()}, nil 64 | case v1alpha1.SchemeGroupVersion.WithResource("yurtingresses"): 65 | return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().YurtIngresses().Informer()}, nil 66 | 67 | } 68 | 69 | return nil, fmt.Errorf("no informer found for %v", resource) 70 | } 71 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/informers/externalversions/internalinterfaces/factory_interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by informer-gen. DO NOT EDIT. 18 | 19 | package internalinterfaces 20 | 21 | import ( 22 | time "time" 23 | 24 | versioned "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/client/clientset/versioned" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | runtime "k8s.io/apimachinery/pkg/runtime" 27 | cache "k8s.io/client-go/tools/cache" 28 | ) 29 | 30 | // NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. 31 | type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer 32 | 33 | // SharedInformerFactory a small interface to allow for adding an informer without an import cycle 34 | type SharedInformerFactory interface { 35 | Start(stopCh <-chan struct{}) 36 | InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer 37 | } 38 | 39 | // TweakListOptionsFunc is a function that transforms a v1.ListOptions. 40 | type TweakListOptionsFunc func(*v1.ListOptions) 41 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/listers/apps/v1alpha1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | // NodePoolListerExpansion allows custom methods to be added to 22 | // NodePoolLister. 23 | type NodePoolListerExpansion interface{} 24 | 25 | // UnitedDeploymentListerExpansion allows custom methods to be added to 26 | // UnitedDeploymentLister. 27 | type UnitedDeploymentListerExpansion interface{} 28 | 29 | // UnitedDeploymentNamespaceListerExpansion allows custom methods to be added to 30 | // UnitedDeploymentNamespaceLister. 31 | type UnitedDeploymentNamespaceListerExpansion interface{} 32 | 33 | // YurtAppDaemonListerExpansion allows custom methods to be added to 34 | // YurtAppDaemonLister. 35 | type YurtAppDaemonListerExpansion interface{} 36 | 37 | // YurtAppDaemonNamespaceListerExpansion allows custom methods to be added to 38 | // YurtAppDaemonNamespaceLister. 39 | type YurtAppDaemonNamespaceListerExpansion interface{} 40 | 41 | // YurtAppSetListerExpansion allows custom methods to be added to 42 | // YurtAppSetLister. 43 | type YurtAppSetListerExpansion interface{} 44 | 45 | // YurtAppSetNamespaceListerExpansion allows custom methods to be added to 46 | // YurtAppSetNamespaceLister. 47 | type YurtAppSetNamespaceListerExpansion interface{} 48 | 49 | // YurtIngressListerExpansion allows custom methods to be added to 50 | // YurtIngressLister. 51 | type YurtIngressListerExpansion interface{} 52 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/listers/apps/v1alpha1/nodepool.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | import ( 22 | v1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 23 | "k8s.io/apimachinery/pkg/api/errors" 24 | "k8s.io/apimachinery/pkg/labels" 25 | "k8s.io/client-go/tools/cache" 26 | ) 27 | 28 | // NodePoolLister helps list NodePools. 29 | // All objects returned here must be treated as read-only. 30 | type NodePoolLister interface { 31 | // List lists all NodePools in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*v1alpha1.NodePool, err error) 34 | // Get retrieves the NodePool from the index for a given name. 35 | // Objects returned here must be treated as read-only. 36 | Get(name string) (*v1alpha1.NodePool, error) 37 | NodePoolListerExpansion 38 | } 39 | 40 | // nodePoolLister implements the NodePoolLister interface. 41 | type nodePoolLister struct { 42 | indexer cache.Indexer 43 | } 44 | 45 | // NewNodePoolLister returns a new NodePoolLister. 46 | func NewNodePoolLister(indexer cache.Indexer) NodePoolLister { 47 | return &nodePoolLister{indexer: indexer} 48 | } 49 | 50 | // List lists all NodePools in the indexer. 51 | func (s *nodePoolLister) List(selector labels.Selector) (ret []*v1alpha1.NodePool, err error) { 52 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 53 | ret = append(ret, m.(*v1alpha1.NodePool)) 54 | }) 55 | return ret, err 56 | } 57 | 58 | // Get retrieves the NodePool from the index for a given name. 59 | func (s *nodePoolLister) Get(name string) (*v1alpha1.NodePool, error) { 60 | obj, exists, err := s.indexer.GetByKey(name) 61 | if err != nil { 62 | return nil, err 63 | } 64 | if !exists { 65 | return nil, errors.NewNotFound(v1alpha1.Resource("nodepool"), name) 66 | } 67 | return obj.(*v1alpha1.NodePool), nil 68 | } 69 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/listers/apps/v1alpha1/yurtingress.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by lister-gen. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | import ( 22 | v1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 23 | "k8s.io/apimachinery/pkg/api/errors" 24 | "k8s.io/apimachinery/pkg/labels" 25 | "k8s.io/client-go/tools/cache" 26 | ) 27 | 28 | // YurtIngressLister helps list YurtIngresses. 29 | // All objects returned here must be treated as read-only. 30 | type YurtIngressLister interface { 31 | // List lists all YurtIngresses in the indexer. 32 | // Objects returned here must be treated as read-only. 33 | List(selector labels.Selector) (ret []*v1alpha1.YurtIngress, err error) 34 | // Get retrieves the YurtIngress from the index for a given name. 35 | // Objects returned here must be treated as read-only. 36 | Get(name string) (*v1alpha1.YurtIngress, error) 37 | YurtIngressListerExpansion 38 | } 39 | 40 | // yurtIngressLister implements the YurtIngressLister interface. 41 | type yurtIngressLister struct { 42 | indexer cache.Indexer 43 | } 44 | 45 | // NewYurtIngressLister returns a new YurtIngressLister. 46 | func NewYurtIngressLister(indexer cache.Indexer) YurtIngressLister { 47 | return &yurtIngressLister{indexer: indexer} 48 | } 49 | 50 | // List lists all YurtIngresses in the indexer. 51 | func (s *yurtIngressLister) List(selector labels.Selector) (ret []*v1alpha1.YurtIngress, err error) { 52 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 53 | ret = append(ret, m.(*v1alpha1.YurtIngress)) 54 | }) 55 | return ret, err 56 | } 57 | 58 | // Get retrieves the YurtIngress from the index for a given name. 59 | func (s *yurtIngressLister) Get(name string) (*v1alpha1.YurtIngress, error) { 60 | obj, exists, err := s.indexer.GetByKey(name) 61 | if err != nil { 62 | return nil, err 63 | } 64 | if !exists { 65 | return nil, errors.NewNotFound(v1alpha1.Resource("yurtingress"), name) 66 | } 67 | return obj.(*v1alpha1.YurtIngress), nil 68 | } 69 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/client/registry.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package client 18 | 19 | import ( 20 | "sigs.k8s.io/controller-runtime/pkg/manager" 21 | ) 22 | 23 | var ( 24 | genericClient *GenericClientset 25 | ) 26 | 27 | // NewRegistry creates clientset by client-go 28 | func NewRegistry(mgr manager.Manager) error { 29 | var err error 30 | genericClient, err = newForConfig(mgr.GetConfig()) 31 | if err != nil { 32 | return err 33 | } 34 | return nil 35 | } 36 | 37 | // GetGenericClient returns clientset 38 | func GetGenericClient() *GenericClientset { 39 | return genericClient 40 | } 41 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/constant/constant.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package constant 18 | 19 | const ( 20 | // ContextKeyCreateDefaultPool indicate whether creating the default nodepools 21 | ContextKeyCreateDefaultPool = "CreateDefaultPool" 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/controllers.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2020 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package controller 19 | 20 | import ( 21 | "context" 22 | 23 | "k8s.io/apimachinery/pkg/api/meta" 24 | "k8s.io/klog" 25 | "sigs.k8s.io/controller-runtime/pkg/manager" 26 | 27 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/nodepool" 28 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/uniteddeployment" 29 | yurtappdaemon "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappdaemon" 30 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappset" 31 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtingress" 32 | ) 33 | 34 | var controllerAddFuncs []func(manager.Manager, context.Context) error 35 | 36 | func init() { 37 | controllerAddFuncs = append(controllerAddFuncs, uniteddeployment.Add, yurtappset.Add, nodepool.Add, yurtappdaemon.Add, yurtingress.Add) 38 | } 39 | 40 | func SetupWithManager(m manager.Manager, ctx context.Context) error { 41 | for _, f := range controllerAddFuncs { 42 | if err := f(m, ctx); err != nil { 43 | if kindMatchErr, ok := err.(*meta.NoKindMatchError); ok { 44 | klog.Infof("CRD %v is not installed, its controller will perform noops!", kindMatchErr.GroupKind) 45 | continue 46 | } 47 | return err 48 | } 49 | } 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/uniteddeployment/adapter/adapter.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | @CHANGELOG 17 | OpenYurt Authors: 18 | change Adapter interface 19 | */ 20 | 21 | package adapter 22 | 23 | import ( 24 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | 27 | alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 28 | ) 29 | 30 | type Adapter interface { 31 | // NewResourceObject creates a empty pool object. 32 | NewResourceObject() runtime.Object 33 | // NewResourceListObject creates a empty pool list object. 34 | NewResourceListObject() runtime.Object 35 | // GetStatusObservedGeneration returns the observed generation of the pool. 36 | GetStatusObservedGeneration(pool metav1.Object) int64 37 | // GetDetails returns the replicas information of the pool status. 38 | GetDetails(pool metav1.Object) (replicasInfo ReplicasInfo, err error) 39 | // GetPoolFailure returns failure information of the pool. 40 | GetPoolFailure() *string 41 | // ApplyPoolTemplate updates the pool to the latest revision. 42 | ApplyPoolTemplate(ud *alpha1.UnitedDeployment, poolName, revision string, replicas int32, pool runtime.Object) error 43 | // IsExpected checks the pool is the expected revision or not. 44 | // If not, UnitedDeployment will call ApplyPoolTemplate to update it. 45 | IsExpected(pool metav1.Object, revision string) bool 46 | // PostUpdate does some works after pool updated 47 | PostUpdate(ud *alpha1.UnitedDeployment, pool runtime.Object, revision string) error 48 | } 49 | 50 | type ReplicasInfo struct { 51 | Replicas int32 52 | ReadyReplicas int32 53 | } 54 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/uniteddeployment/pool.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package uniteddeployment 19 | 20 | import ( 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | 23 | unitv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 24 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/uniteddeployment/adapter" 25 | ) 26 | 27 | // Pool stores the details of a pool resource owned by one UnitedDeployment. 28 | type Pool struct { 29 | Name string 30 | Namespace string 31 | Spec PoolSpec 32 | Status PoolStatus 33 | } 34 | 35 | // PoolSpec stores the spec details of the Pool 36 | type PoolSpec struct { 37 | PoolRef metav1.Object 38 | } 39 | 40 | // PoolStatus stores the observed state of the Pool. 41 | type PoolStatus struct { 42 | ObservedGeneration int64 43 | adapter.ReplicasInfo 44 | PatchInfo string 45 | } 46 | 47 | // ResourceRef stores the Pool resource it represents. 48 | type ResourceRef struct { 49 | Resources []metav1.Object 50 | } 51 | 52 | // ControlInterface defines the interface that UnitedDeployment uses to list, create, update, and delete Pools. 53 | type ControlInterface interface { 54 | // GetAllPools returns the pools which are managed by the UnitedDeployment. 55 | GetAllPools(ud *unitv1alpha1.UnitedDeployment) ([]*Pool, error) 56 | // CreatePool creates the pool depending on the inputs. 57 | CreatePool(ud *unitv1alpha1.UnitedDeployment, unit string, revision string, replicas int32) error 58 | // UpdatePool updates the target pool with the input information. 59 | UpdatePool(pool *Pool, ud *unitv1alpha1.UnitedDeployment, revision string, replicas int32) error 60 | // DeletePool is used to delete the input pool. 61 | DeletePool(*Pool) error 62 | // GetPoolFailure extracts the pool failure message to expose on UnitedDeployment status. 63 | GetPoolFailure(*Pool) *string 64 | // IsExpected check the pool is the expected revision 65 | IsExpected(pool *Pool, revision string) bool 66 | } 67 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/uniteddeployment/uniteddeployment_controller_suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package uniteddeployment 19 | 20 | /* 21 | import ( 22 | "context" 23 | stdlog "log" 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/onsi/gomega" 29 | "k8s.io/client-go/kubernetes/scheme" 30 | "k8s.io/client-go/rest" 31 | "sigs.k8s.io/controller-runtime/pkg/envtest" 32 | "sigs.k8s.io/controller-runtime/pkg/manager" 33 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 34 | 35 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis" 36 | ) 37 | 38 | var cfg *rest.Config 39 | 40 | func TestMain(m *testing.M) { 41 | t := &envtest.Environment{ 42 | CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "yurt-app-manager", "crd", "bases")}, 43 | } 44 | apis.AddToScheme(scheme.Scheme) 45 | 46 | var err error 47 | if cfg, err = t.Start(); err != nil { 48 | stdlog.Fatal(err) 49 | } 50 | 51 | code := m.Run() 52 | t.Stop() 53 | os.Exit(code) 54 | } 55 | 56 | // SetupTestReconcile returns a reconcile.Reconcile implementation that delegates to inner and 57 | // writes the request to requests after Reconcile is finished. 58 | func SetupTestReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan reconcile.Request) { 59 | requests := make(chan reconcile.Request) 60 | fn := reconcile.Func(func(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 61 | result, err := inner.Reconcile(ctx, req) 62 | requests <- req 63 | return result, err 64 | }) 65 | return fn, requests 66 | } 67 | 68 | // StartTestManager adds recFn 69 | func StartTestManager(mgr manager.Manager, g *gomega.GomegaWithT) context.CancelFunc { 70 | ctx, cancel := context.WithCancel(context.Background()) 71 | go func() { 72 | g.Expect(mgr.Start(ctx)).NotTo(gomega.HaveOccurred()) 73 | }() 74 | return cancel 75 | } 76 | */ 77 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/uniteddeployment/uniteddeployment_suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package uniteddeployment 15 | 16 | import ( 17 | "testing" 18 | 19 | . "github.com/onsi/ginkgo/v2" 20 | . "github.com/onsi/gomega" 21 | ) 22 | 23 | func TestPluginengine(t *testing.T) { 24 | RegisterFailHandler(Fail) 25 | RunSpecs(t, "UnitedDeployment Controller Suite") 26 | } 27 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/util/statefulset_utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package util 19 | 20 | import ( 21 | "regexp" 22 | "strconv" 23 | 24 | corev1 "k8s.io/api/core/v1" 25 | ) 26 | 27 | var statefulPodRegex = regexp.MustCompile("(.*)-([0-9]+)$") 28 | 29 | func GetOrdinal(pod *corev1.Pod) int32 { 30 | _, ordinal := getParentNameAndOrdinal(pod) 31 | return ordinal 32 | } 33 | 34 | func getParentNameAndOrdinal(pod *corev1.Pod) (string, int32) { 35 | parent := "" 36 | var ordinal int32 = -1 37 | subMatches := statefulPodRegex.FindStringSubmatch(pod.Name) 38 | if len(subMatches) < 3 { 39 | return parent, ordinal 40 | } 41 | parent = subMatches[1] 42 | if i, err := strconv.ParseInt(subMatches[2], 10, 32); err == nil { 43 | ordinal = int32(i) 44 | } 45 | return parent, ordinal 46 | } 47 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappdaemon/nodepool_enqueue_handlers.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package yurtappdaemon 18 | 19 | import ( 20 | "context" 21 | 22 | "k8s.io/apimachinery/pkg/types" 23 | "k8s.io/client-go/util/workqueue" 24 | "sigs.k8s.io/controller-runtime/pkg/client" 25 | "sigs.k8s.io/controller-runtime/pkg/event" 26 | "sigs.k8s.io/controller-runtime/pkg/handler" 27 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 28 | 29 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 30 | ) 31 | 32 | type EnqueueYurtAppDaemonForNodePool struct { 33 | client client.Client 34 | } 35 | 36 | func (e *EnqueueYurtAppDaemonForNodePool) Create(event event.CreateEvent, limitingInterface workqueue.RateLimitingInterface) { 37 | e.addAllYurtAppDaemonToWorkQueue(limitingInterface) 38 | } 39 | 40 | func (e *EnqueueYurtAppDaemonForNodePool) Update(event event.UpdateEvent, limitingInterface workqueue.RateLimitingInterface) { 41 | e.addAllYurtAppDaemonToWorkQueue(limitingInterface) 42 | } 43 | 44 | func (e *EnqueueYurtAppDaemonForNodePool) Delete(event event.DeleteEvent, limitingInterface workqueue.RateLimitingInterface) { 45 | e.addAllYurtAppDaemonToWorkQueue(limitingInterface) 46 | } 47 | 48 | func (e *EnqueueYurtAppDaemonForNodePool) Generic(event event.GenericEvent, limitingInterface workqueue.RateLimitingInterface) { 49 | return 50 | } 51 | 52 | func (e *EnqueueYurtAppDaemonForNodePool) addAllYurtAppDaemonToWorkQueue(limitingInterface workqueue.RateLimitingInterface) { 53 | ydas := &v1alpha1.YurtAppDaemonList{} 54 | if err := e.client.List(context.TODO(), ydas); err != nil { 55 | return 56 | } 57 | 58 | for _, ud := range ydas.Items { 59 | addYurtAppDaemonToWorkQueue(ud.GetNamespace(), ud.GetName(), limitingInterface) 60 | } 61 | } 62 | 63 | var _ handler.EventHandler = &EnqueueYurtAppDaemonForNodePool{} 64 | 65 | // addYurtAppDaemonToWorkQueue adds the YurtAppDaemon the reconciler's workqueue 66 | func addYurtAppDaemonToWorkQueue(namespace, name string, 67 | q workqueue.RateLimitingInterface) { 68 | q.Add(reconcile.Request{ 69 | NamespacedName: types.NamespacedName{Name: name, Namespace: namespace}, 70 | }) 71 | } 72 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappdaemon/workloadcontroller/controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package workloadcontroller 18 | 19 | import ( 20 | "sigs.k8s.io/controller-runtime/pkg/client" 21 | 22 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 23 | ) 24 | 25 | type WorkloadControllor interface { 26 | ObjectKey(load *Workload) client.ObjectKey 27 | GetAllWorkloads(set *v1alpha1.YurtAppDaemon) ([]*Workload, error) 28 | CreateWorkload(set *v1alpha1.YurtAppDaemon, nodepool v1alpha1.NodePool, revision string) error 29 | UpdateWorkload(load *Workload, set *v1alpha1.YurtAppDaemon, nodepool v1alpha1.NodePool, revision string) error 30 | DeleteWorkload(set *v1alpha1.YurtAppDaemon, load *Workload) error 31 | GetTemplateType() v1alpha1.TemplateType 32 | } 33 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappdaemon/workloadcontroller/statefulset_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The Openyurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package workloadcontroller 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "sigs.k8s.io/controller-runtime/pkg/client" 22 | ) 23 | 24 | type StatefulSetControllor struct { 25 | client.Client 26 | 27 | scheme *runtime.Scheme 28 | } 29 | 30 | // var _ WorkloadControllor = &StatefulSetControllor{} 31 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappdaemon/workloadcontroller/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package workloadcontroller 18 | 19 | import ( 20 | "fmt" 21 | 22 | corev1 "k8s.io/api/core/v1" 23 | "k8s.io/apimachinery/pkg/api/validation" 24 | 25 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 26 | ) 27 | 28 | func getWorkloadPrefix(controllerName, nodepoolName string) string { 29 | prefix := fmt.Sprintf("%s-%s-", controllerName, nodepoolName) 30 | if len(validation.NameIsDNSSubdomain(prefix, true)) != 0 { 31 | prefix = fmt.Sprintf("%s-", controllerName) 32 | } 33 | return prefix 34 | } 35 | 36 | func CreateNodeSelectorByNodepoolName(nodepool string) map[string]string { 37 | return map[string]string{ 38 | v1alpha1.LabelCurrentNodePool: nodepool, 39 | } 40 | } 41 | 42 | func TaintsToTolerations(taints []corev1.Taint) []corev1.Toleration { 43 | tolerations := []corev1.Toleration{} 44 | for _, taint := range taints { 45 | toleation := corev1.Toleration{ 46 | Key: taint.Key, 47 | Operator: corev1.TolerationOpExists, 48 | Effect: taint.Effect, 49 | } 50 | tolerations = append(tolerations, toleation) 51 | } 52 | return tolerations 53 | } 54 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappdaemon/workloadcontroller/workload.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package workloadcontroller 18 | 19 | import ( 20 | corev1 "k8s.io/api/core/v1" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | 23 | unitv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 24 | ) 25 | 26 | type Workload struct { 27 | Name string 28 | Namespace string 29 | Kind string 30 | Spec WorkloadSpec 31 | Status WorkloadStatus 32 | } 33 | 34 | // WorkloadSpec stores the spec details of the workload 35 | type WorkloadSpec struct { 36 | Ref metav1.Object 37 | Toleration []corev1.Toleration 38 | NodeSelector map[string]string 39 | } 40 | 41 | // WorkloadStatus stores the observed state of the Workload. 42 | type WorkloadStatus struct { 43 | } 44 | 45 | func (w *Workload) GetRevision() string { 46 | return w.Spec.Ref.GetLabels()[unitv1alpha1.ControllerRevisionHashLabelKey] 47 | } 48 | 49 | func (w *Workload) GetNodePoolName() string { 50 | return w.Spec.Ref.GetAnnotations()[unitv1alpha1.AnnotationRefNodePool] 51 | } 52 | 53 | func (w *Workload) GetToleration() []corev1.Toleration { 54 | return w.Spec.Toleration 55 | } 56 | 57 | func (w *Workload) GetNodeSelector() map[string]string { 58 | return w.Spec.NodeSelector 59 | } 60 | 61 | func (w *Workload) GetKind() string { 62 | return w.Kind 63 | } 64 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappset/adapter/adapter.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | @CHANGELOG 17 | OpenYurt Authors: 18 | change Adapter interface 19 | */ 20 | 21 | package adapter 22 | 23 | import ( 24 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | "k8s.io/apimachinery/pkg/runtime" 26 | 27 | alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 28 | ) 29 | 30 | type Adapter interface { 31 | // NewResourceObject creates a empty pool object. 32 | NewResourceObject() runtime.Object 33 | // NewResourceListObject creates a empty pool list object. 34 | NewResourceListObject() runtime.Object 35 | // GetStatusObservedGeneration returns the observed generation of the pool. 36 | GetStatusObservedGeneration(pool metav1.Object) int64 37 | // GetDetails returns the replicas information of the pool status. 38 | GetDetails(pool metav1.Object) (replicasInfo ReplicasInfo, err error) 39 | // GetPoolFailure returns failure information of the pool. 40 | GetPoolFailure() *string 41 | // ApplyPoolTemplate updates the pool to the latest revision. 42 | ApplyPoolTemplate(yas *alpha1.YurtAppSet, poolName, revision string, replicas int32, pool runtime.Object) error 43 | // IsExpected checks the pool is the expected revision or not. 44 | // If not, YurtAppSet will call ApplyPoolTemplate to update it. 45 | IsExpected(pool metav1.Object, revision string) bool 46 | // PostUpdate does some works after pool updated 47 | PostUpdate(yas *alpha1.YurtAppSet, pool runtime.Object, revision string) error 48 | } 49 | 50 | type ReplicasInfo struct { 51 | Replicas int32 52 | ReadyReplicas int32 53 | } 54 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappset/pool.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package yurtappset 19 | 20 | import ( 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | 23 | unitv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 24 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappset/adapter" 25 | ) 26 | 27 | // Pool stores the details of a pool resource owned by one YurtAppSet. 28 | type Pool struct { 29 | Name string 30 | Namespace string 31 | Spec PoolSpec 32 | Status PoolStatus 33 | } 34 | 35 | // PoolSpec stores the spec details of the Pool 36 | type PoolSpec struct { 37 | PoolRef metav1.Object 38 | } 39 | 40 | // PoolStatus stores the observed state of the Pool. 41 | type PoolStatus struct { 42 | ObservedGeneration int64 43 | adapter.ReplicasInfo 44 | PatchInfo string 45 | } 46 | 47 | // ResourceRef stores the Pool resource it represents. 48 | type ResourceRef struct { 49 | Resources []metav1.Object 50 | } 51 | 52 | // ControlInterface defines the interface that YurtAppSet uses to list, create, update, and delete Pools. 53 | type ControlInterface interface { 54 | // GetAllPools returns the pools which are managed by the YurtAppSet. 55 | GetAllPools(yas *unitv1alpha1.YurtAppSet) ([]*Pool, error) 56 | // CreatePool creates the pool depending on the inputs. 57 | CreatePool(yas *unitv1alpha1.YurtAppSet, unit string, revision string, replicas int32) error 58 | // UpdatePool updates the target pool with the input information. 59 | UpdatePool(pool *Pool, yas *unitv1alpha1.YurtAppSet, revision string, replicas int32) error 60 | // DeletePool is used to delete the input pool. 61 | DeletePool(*Pool) error 62 | // GetPoolFailure extracts the pool failure message to expose on YurtAppSet status. 63 | GetPoolFailure(*Pool) *string 64 | // IsExpected check the pool is the expected revision 65 | IsExpected(pool *Pool, revision string) bool 66 | } 67 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/controller/yurtappset/yurtappset_controller_suite_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package yurtappset 19 | 20 | /* 21 | import ( 22 | stdlog "log" 23 | "os" 24 | "path/filepath" 25 | "sync" 26 | "testing" 27 | 28 | "github.com/onsi/gomega" 29 | "k8s.io/client-go/kubernetes/scheme" 30 | "k8s.io/client-go/rest" 31 | "sigs.k8s.io/controller-runtime/pkg/envtest" 32 | "sigs.k8s.io/controller-runtime/pkg/manager" 33 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 34 | 35 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis" 36 | ) 37 | 38 | var cfg *rest.Config 39 | 40 | func TestMain(m *testing.M) { 41 | t := &envtest.Environment{ 42 | CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, 43 | } 44 | apis.AddToScheme(scheme.Scheme) 45 | 46 | var err error 47 | if cfg, err = t.Start(); err != nil { 48 | stdlog.Fatal(err) 49 | } 50 | 51 | code := m.Run() 52 | t.Stop() 53 | os.Exit(code) 54 | } 55 | 56 | // SetupTestReconcile returns a reconcile.Reconcile implementation that delegates to inner and 57 | // writes the request to requests after Reconcile is finished. 58 | func SetupTestReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan reconcile.Request) { 59 | requests := make(chan reconcile.Request) 60 | fn := reconcile.Func(func(req reconcile.Request) (reconcile.Result, error) { 61 | result, err := inner.Reconcile(req) 62 | requests <- req 63 | return result, err 64 | }) 65 | return fn, requests 66 | } 67 | 68 | // StartTestManager adds recFn 69 | func StartTestManager(mgr manager.Manager, g *gomega.GomegaWithT) (chan struct{}, *sync.WaitGroup) { 70 | stop := make(chan struct{}) 71 | wg := &sync.WaitGroup{} 72 | go func() { 73 | wg.Add(1) 74 | g.Expect(mgr.Start(stop)).NotTo(gomega.HaveOccurred()) 75 | wg.Done() 76 | }() 77 | return stop, wg 78 | } 79 | */ 80 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/hack/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/hack/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The Openyurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package hack 18 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/util/fieldindex/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package fieldindex 19 | 20 | import ( 21 | "context" 22 | "sync" 23 | 24 | v1 "k8s.io/api/core/v1" 25 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | "sigs.k8s.io/controller-runtime/pkg/cache" 27 | "sigs.k8s.io/controller-runtime/pkg/client" 28 | ) 29 | 30 | const ( 31 | IndexNameForPodNodeName = "spec.nodeName" 32 | IndexNameForOwnerRefUID = "ownerRefUID" 33 | ) 34 | 35 | var registerOnce sync.Once 36 | 37 | func RegisterFieldIndexes(c cache.Cache) error { 38 | var err error 39 | registerOnce.Do(func() { 40 | // pod nodeName 41 | err = c.IndexField(context.TODO(), &v1.Pod{}, IndexNameForPodNodeName, func(obj client.Object) []string { 42 | pod, ok := obj.(*v1.Pod) 43 | if !ok { 44 | return []string{} 45 | } 46 | if len(pod.Spec.NodeName) == 0 { 47 | return []string{} 48 | } 49 | return []string{pod.Spec.NodeName} 50 | }) 51 | if err != nil { 52 | return 53 | } 54 | 55 | ownerIndexFunc := func(obj client.Object) []string { 56 | metaObj, ok := obj.(metav1.Object) 57 | if !ok { 58 | return []string{} 59 | } 60 | var owners []string 61 | for _, ref := range metaObj.GetOwnerReferences() { 62 | owners = append(owners, string(ref.UID)) 63 | } 64 | return owners 65 | } 66 | 67 | // pod ownerReference 68 | if err = c.IndexField(context.TODO(), &v1.Pod{}, IndexNameForOwnerRefUID, ownerIndexFunc); err != nil { 69 | return 70 | } 71 | // pvc ownerReference 72 | if err = c.IndexField(context.TODO(), &v1.PersistentVolumeClaim{}, IndexNameForOwnerRefUID, ownerIndexFunc); err != nil { 73 | return 74 | } 75 | }) 76 | return err 77 | } 78 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/util/json.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package util 19 | 20 | import "encoding/json" 21 | 22 | // DumpJSON returns the JSON encoding 23 | func DumpJSON(o interface{}) string { 24 | j, _ := json.Marshal(o) 25 | return string(j) 26 | } 27 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/util/pods.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2020 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package util 19 | 20 | import ( 21 | v1 "k8s.io/api/core/v1" 22 | "k8s.io/apimachinery/pkg/util/sets" 23 | ) 24 | 25 | // GetPodNames returns names of the given Pods array 26 | func GetPodNames(pods []*v1.Pod) sets.String { 27 | set := sets.NewString() 28 | for _, pod := range pods { 29 | set.Insert(pod.Name) 30 | } 31 | return set 32 | } 33 | 34 | // MergePods merges two pods arrays 35 | func MergePods(pods1, pods2 []*v1.Pod) []*v1.Pod { 36 | var ret []*v1.Pod 37 | names := sets.NewString() 38 | 39 | for _, pod := range pods1 { 40 | if !names.Has(pod.Name) { 41 | ret = append(ret, pod) 42 | names.Insert(pod.Name) 43 | } 44 | } 45 | for _, pod := range pods2 { 46 | if !names.Has(pod.Name) { 47 | ret = append(ret, pod) 48 | names.Insert(pod.Name) 49 | } 50 | } 51 | return ret 52 | } 53 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/util/string.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | func ContainsString(slice []string, s string) bool { 20 | for _, item := range slice { 21 | if item == s { 22 | return true 23 | } 24 | } 25 | return false 26 | } 27 | 28 | func RemoveString(slice []string, s string) (result []string) { 29 | for _, item := range slice { 30 | if item == s { 31 | continue 32 | } 33 | result = append(result, item) 34 | } 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/util/tools.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | Copyright 2016 The Kubernetes Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package util 20 | 21 | import ( 22 | "sync" 23 | 24 | "k8s.io/utils/integer" 25 | ) 26 | 27 | // SlowStartBatch tries to call the provided function a total of 'count' times, 28 | // starting slow to check for errors, then speeding up if calls succeed. 29 | // 30 | // It groups the calls into batches, starting with a group of initialBatchSize. 31 | // Within each batch, it may call the function multiple times concurrently with its index. 32 | // 33 | // If a whole batch succeeds, the next batch may get exponentially larger. 34 | // If there are any failures in a batch, all remaining batches are skipped 35 | // after waiting for the current batch to complete. 36 | // 37 | // It returns the number of successful calls to the function. 38 | func SlowStartBatch(count int, initialBatchSize int, fn func(index int) error) (int, error) { 39 | remaining := count 40 | successes := 0 41 | index := 0 42 | for batchSize := integer.IntMin(remaining, initialBatchSize); batchSize > 0; batchSize = integer.IntMin(2*batchSize, remaining) { 43 | errCh := make(chan error, batchSize) 44 | var wg sync.WaitGroup 45 | wg.Add(batchSize) 46 | for i := 0; i < batchSize; i++ { 47 | go func(idx int) { 48 | defer wg.Done() 49 | if err := fn(idx); err != nil { 50 | errCh <- err 51 | } 52 | }(index) 53 | index++ 54 | } 55 | wg.Wait() 56 | curSuccesses := batchSize - len(errCh) 57 | successes += curSuccesses 58 | if len(errCh) > 0 { 59 | return successes, <-errCh 60 | } 61 | remaining -= batchSize 62 | } 63 | return successes, nil 64 | } 65 | 66 | // CheckDuplicate finds if there are duplicated items in a list. 67 | func CheckDuplicate(list []string) []string { 68 | tmpMap := make(map[string]struct{}) 69 | var dupList []string 70 | for _, name := range list { 71 | if _, ok := tmpMap[name]; ok { 72 | dupList = append(dupList, name) 73 | } else { 74 | tmpMap[name] = struct{}{} 75 | } 76 | } 77 | return dupList 78 | } 79 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/util/tools_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2019 The Kruise Authors. 4 | Copyright 2016 The Kubernetes Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package util 20 | 21 | import ( 22 | "fmt" 23 | "sync" 24 | "testing" 25 | ) 26 | 27 | func TestSlowStartBatch(t *testing.T) { 28 | fakeErr := fmt.Errorf("fake error") 29 | callCnt := 0 30 | callLimit := 0 31 | var lock sync.Mutex 32 | fn := func(idx int) error { 33 | lock.Lock() 34 | defer lock.Unlock() 35 | callCnt++ 36 | if callCnt > callLimit { 37 | return fakeErr 38 | } 39 | return nil 40 | } 41 | 42 | tests := []struct { 43 | name string 44 | count int 45 | callLimit int 46 | fn func(int) error 47 | expectedSuccesses int 48 | expectedErr error 49 | expectedCallCnt int 50 | }{ 51 | { 52 | name: "callLimit = 0 (all fail)", 53 | count: 10, 54 | callLimit: 0, 55 | fn: fn, 56 | expectedSuccesses: 0, 57 | expectedErr: fakeErr, 58 | expectedCallCnt: 1, // 1(first batch): function will be called at least once 59 | }, 60 | { 61 | name: "callLimit = count (all succeed)", 62 | count: 10, 63 | callLimit: 10, 64 | fn: fn, 65 | expectedSuccesses: 10, 66 | expectedErr: nil, 67 | expectedCallCnt: 10, // 1(first batch) + 2(2nd batch) + 4(3rd batch) + 3(4th batch) = 10 68 | }, 69 | { 70 | name: "callLimit < count (some succeed)", 71 | count: 10, 72 | callLimit: 5, 73 | fn: fn, 74 | expectedSuccesses: 5, 75 | expectedErr: fakeErr, 76 | expectedCallCnt: 7, // 1(first batch) + 2(2nd batch) + 4(3rd batch) = 7 77 | }, 78 | } 79 | 80 | for _, test := range tests { 81 | callCnt = 0 82 | callLimit = test.callLimit 83 | successes, err := SlowStartBatch(test.count, 1, test.fn) 84 | if successes != test.expectedSuccesses { 85 | t.Errorf("%s: unexpected processed batch size, expected %d, got %d", test.name, test.expectedSuccesses, successes) 86 | } 87 | if err != test.expectedErr { 88 | t.Errorf("%s: unexpected processed batch size, expected %v, got %v", test.name, test.expectedErr, err) 89 | } 90 | // verify that slowStartBatch stops trying more calls after a batch fails 91 | if callCnt != test.expectedCallCnt { 92 | t.Errorf("%s: slowStartBatch() still tries calls after a batch fails, expected %d calls, got %d", test.name, test.expectedCallCnt, callCnt) 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/nodepool/nodepool_webhook_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | // +kubebuilder:docs-gen:collapse=Apache License 14 | 15 | package nodepool 16 | 17 | import ( 18 | "context" 19 | "strings" 20 | "testing" 21 | 22 | corev1 "k8s.io/api/core/v1" 23 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | "k8s.io/apimachinery/pkg/runtime" 25 | "sigs.k8s.io/controller-runtime/pkg/client/fake" 26 | 27 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 28 | ) 29 | 30 | var defaultNodePool = &v1alpha1.NodePool{ 31 | ObjectMeta: metav1.ObjectMeta{ 32 | Name: "fooboo", 33 | Namespace: "default", 34 | }, 35 | Spec: v1alpha1.NodePoolSpec{ 36 | Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo"}}, 37 | Type: v1alpha1.Cloud, 38 | }, 39 | } 40 | 41 | func TestNodePoolDefaulter(t *testing.T) { 42 | webhook := &NodePoolHandler{} 43 | if err := webhook.Default(context.TODO(), defaultNodePool); err != nil { 44 | t.Fatal(err) 45 | } 46 | if defaultNodePool.Labels[v1alpha1.NodePoolTypeLabelKey] != strings.ToLower(string(defaultNodePool.Spec.Type)) { 47 | t.Fatalf("the default NodePool label doesn't match NodePool.Spec.Type. label:%s, type:%s", 48 | defaultNodePool.Labels[v1alpha1.NodePoolTypeLabelKey], string(defaultNodePool.Spec.Type)) 49 | } 50 | } 51 | 52 | func TestNodePoolValidator(t *testing.T) { 53 | 54 | // prepare fake client 55 | scheme := runtime.NewScheme() 56 | v1alpha1.AddToScheme(scheme) 57 | corev1.AddToScheme(scheme) 58 | cl := fake.NewClientBuilder().WithScheme(scheme).WithObjects(defaultNodePool).Build() 59 | webhook := &NodePoolHandler{ 60 | Client: cl, 61 | } 62 | 63 | // test default 64 | if err := webhook.Default(context.TODO(), defaultNodePool); err != nil { 65 | t.Fatal(err) 66 | } 67 | 68 | // test create 69 | if err := webhook.ValidateCreate(context.TODO(), defaultNodePool); err != nil { 70 | t.Fatal("should create success", err) 71 | } 72 | 73 | // test update 74 | updatedNp := defaultNodePool.DeepCopy() 75 | updatedNp.Spec.Type = v1alpha1.Edge 76 | if err := webhook.ValidateUpdate(context.TODO(), defaultNodePool, updatedNp); err == nil { 77 | t.Fatal("workload selector change should fail") 78 | } 79 | 80 | // test delete 81 | if err := webhook.ValidateDelete(context.TODO(), defaultNodePool); err != nil { 82 | t.Fatal(err) 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/nodepool/v1beta1/nodepool_webhook.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | // +kubebuilder:docs-gen:collapse=Apache License 14 | 15 | package v1beta1 16 | 17 | import ( 18 | ctrl "sigs.k8s.io/controller-runtime" 19 | 20 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1beta1" 21 | ) 22 | 23 | func (webhook *NodePoolHandler) SetupWebhookWithManager(mgr ctrl.Manager) error { 24 | return ctrl.NewWebhookManagedBy(mgr). 25 | For(&v1beta1.NodePool{}). 26 | Complete() 27 | } 28 | 29 | type NodePoolHandler struct{} 30 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/server.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package webhook 18 | 19 | import ( 20 | "github.com/pkg/errors" 21 | ctrl "sigs.k8s.io/controller-runtime" 22 | 23 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/nodepool" 24 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/nodepool/v1beta1" 25 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/uniteddeployment" 26 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/yurtappdaemon" 27 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/yurtappset" 28 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/webhook/yurtingress" 29 | ) 30 | 31 | func SetupWebhooks(mgr ctrl.Manager) error { 32 | // Our existing call to SetupWebhookWithManager registers our conversion webhooks with the manager, too. 33 | if err := (&nodepool.NodePoolHandler{Client: mgr.GetClient()}).SetupWebhookWithManager(mgr); err != nil { 34 | return errors.Wrapf(err, "unable to create webhook for NodePool") 35 | } 36 | 37 | if err := (&v1beta1.NodePoolHandler{}).SetupWebhookWithManager(mgr); err != nil { 38 | return errors.Wrapf(err, "unable to create webhook for v1beta1 NodePool") 39 | } 40 | 41 | if err := (&uniteddeployment.UnitedDeploymentHandler{Client: mgr.GetClient()}).SetupWebhookWithManager(mgr); err != nil { 42 | return errors.Wrapf(err, "unable to create webhook for UnitedDeployment") 43 | } 44 | 45 | if err := (&yurtappdaemon.YurtAppDaemonHandler{Client: mgr.GetClient()}).SetupWebhookWithManager(mgr); err != nil { 46 | return errors.Wrapf(err, "unable to create webhook for YurtAppDaemon") 47 | } 48 | 49 | if err := (&yurtappset.YurtAppSetHandler{Client: mgr.GetClient()}).SetupWebhookWithManager(mgr); err != nil { 50 | return errors.Wrapf(err, "unable to create webhook for YurtAppSet") 51 | } 52 | 53 | if err := (&yurtingress.YurtIngressHandler{Client: mgr.GetClient()}).SetupWebhookWithManager(mgr); err != nil { 54 | return errors.Wrapf(err, "unable to create webhook for YurtIngress") 55 | } 56 | 57 | return nil 58 | } 59 | 60 | // +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete 61 | // +kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=mutatingwebhookconfigurations,verbs=get;list;watch;create;update;patch;delete 62 | // +kubebuilder:rbac:groups=admissionregistration.k8s.io,resources=validatingwebhookconfigurations,verbs=get;list;watch;create;update;patch;delete 63 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/util/handler.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "sigs.k8s.io/controller-runtime/pkg/client" 21 | "sigs.k8s.io/controller-runtime/pkg/webhook/admission" 22 | ) 23 | 24 | type Options struct { 25 | Client client.Client 26 | } 27 | type Handler interface { 28 | admission.Handler 29 | SetOptions(options Options) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/util/util.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The OpenYurt Authors. 3 | Copyright 2020 The Kruise Authors. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | package util 19 | 20 | import ( 21 | "os" 22 | "strconv" 23 | 24 | "k8s.io/klog" 25 | ) 26 | 27 | func GetHost() string { 28 | return os.Getenv("WEBHOOK_HOST") 29 | } 30 | 31 | func GetNamespace() string { 32 | if ns := os.Getenv("POD_NAMESPACE"); len(ns) > 0 { 33 | return ns 34 | } 35 | return "kube-system" 36 | } 37 | 38 | func GetSecretName() string { 39 | if name := os.Getenv("SECRET_NAME"); len(name) > 0 { 40 | return name 41 | } 42 | return "yurt-app-webhook-certs" 43 | } 44 | 45 | func GetServiceName() string { 46 | if name := os.Getenv("SERVICE_NAME"); len(name) > 0 { 47 | return name 48 | } 49 | return "yurt-app-webhook-service" 50 | } 51 | 52 | func GetPort() int { 53 | port := 9876 54 | if p := os.Getenv("WEBHOOK_PORT"); len(p) > 0 { 55 | if p, err := strconv.ParseInt(p, 10, 32); err == nil { 56 | port = int(p) 57 | } else { 58 | klog.Fatalf("failed to convert WEBHOOK_PORT=%v in env: %v", p, err) 59 | } 60 | } 61 | return port 62 | } 63 | 64 | func GetCertDir() string { 65 | if p := os.Getenv("WEBHOOK_CERT_DIR"); len(p) > 0 { 66 | return p 67 | } 68 | return "/tmp/yurt-app-webhook-certs" 69 | } 70 | 71 | func GetMutatingWebhookConfigurationName() string { 72 | if p := os.Getenv("MUTATING_WEBHOOK_CONFIGURATION_NAME"); len(p) > 0 { 73 | return p 74 | } 75 | return "yurt-app-mutating-webhook-configuration" 76 | } 77 | 78 | func GetValidatingWebhookConfigurationName() string { 79 | if p := os.Getenv("VALIDATING_WEBHOOK_CONFIGURATION_NAME"); len(p) > 0 { 80 | return p 81 | } 82 | return "yurt-app-validating-webhook-configuration" 83 | } 84 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/yurtappdaemon/yurtappdaemon_webhook_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | // +kubebuilder:docs-gen:collapse=Apache License 14 | 15 | package yurtappdaemon 16 | 17 | import ( 18 | "context" 19 | "testing" 20 | 21 | appsv1 "k8s.io/api/apps/v1" 22 | corev1 "k8s.io/api/core/v1" 23 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | 25 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 26 | ) 27 | 28 | var defaultAppDaemon = &v1alpha1.YurtAppDaemon{ 29 | ObjectMeta: metav1.ObjectMeta{ 30 | Name: "fooboo", 31 | Namespace: "default", 32 | }, 33 | Spec: v1alpha1.YurtAppDaemonSpec{ 34 | Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo"}}, 35 | WorkloadTemplate: v1alpha1.WorkloadTemplate{ 36 | DeploymentTemplate: &v1alpha1.DeploymentTemplateSpec{ 37 | ObjectMeta: metav1.ObjectMeta{ 38 | Labels: map[string]string{"app": "demo"}, 39 | }, 40 | Spec: appsv1.DeploymentSpec{ 41 | Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo"}}, 42 | Template: corev1.PodTemplateSpec{ 43 | ObjectMeta: metav1.ObjectMeta{ 44 | Labels: map[string]string{"app": "demo"}, 45 | }, 46 | Spec: corev1.PodSpec{ 47 | Containers: []corev1.Container{ 48 | {Name: "demo", Image: "nginx"}, 49 | }, 50 | }, 51 | }, 52 | }, 53 | }, 54 | }, 55 | }, 56 | } 57 | 58 | func TestYurtAppSetDefaulter(t *testing.T) { 59 | webhook := &YurtAppDaemonHandler{} 60 | if err := webhook.Default(context.TODO(), defaultAppDaemon); err != nil { 61 | t.Fatal(err) 62 | } 63 | } 64 | 65 | func TestYurtAppSetValidator(t *testing.T) { 66 | 67 | webhook := &YurtAppDaemonHandler{} 68 | 69 | // set default value 70 | if err := webhook.Default(context.TODO(), defaultAppDaemon); err != nil { 71 | t.Fatal(err) 72 | } 73 | 74 | if err := webhook.ValidateCreate(context.TODO(), defaultAppDaemon); err != nil { 75 | t.Fatal("should create success", err) 76 | } 77 | 78 | updateAppSet := defaultAppDaemon.DeepCopy() 79 | updateAppSet.Spec.WorkloadTemplate.DeploymentTemplate.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo2"}} 80 | if err := webhook.ValidateUpdate(context.TODO(), defaultAppDaemon, updateAppSet); err == nil { 81 | t.Fatal("workload selector change should fail") 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/yurtappset/yurtappset_webhook_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | // +kubebuilder:docs-gen:collapse=Apache License 14 | 15 | package yurtappset 16 | 17 | import ( 18 | "context" 19 | "testing" 20 | 21 | appsv1 "k8s.io/api/apps/v1" 22 | corev1 "k8s.io/api/core/v1" 23 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | 25 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 26 | ) 27 | 28 | var defaultAppSet = &v1alpha1.YurtAppSet{ 29 | ObjectMeta: metav1.ObjectMeta{ 30 | Name: "fooboo", 31 | Namespace: "default", 32 | }, 33 | Spec: v1alpha1.YurtAppSetSpec{ 34 | Topology: v1alpha1.Topology{Pools: []v1alpha1.Pool{{Name: "beijing"}}}, 35 | Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo"}}, 36 | WorkloadTemplate: v1alpha1.WorkloadTemplate{ 37 | DeploymentTemplate: &v1alpha1.DeploymentTemplateSpec{ 38 | ObjectMeta: metav1.ObjectMeta{ 39 | Labels: map[string]string{"app": "demo"}, 40 | }, 41 | Spec: appsv1.DeploymentSpec{ 42 | Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo"}}, 43 | Template: corev1.PodTemplateSpec{ 44 | ObjectMeta: metav1.ObjectMeta{ 45 | Labels: map[string]string{"app": "demo"}, 46 | }, 47 | Spec: corev1.PodSpec{ 48 | Containers: []corev1.Container{ 49 | {Name: "demo", Image: "nginx"}, 50 | }, 51 | }, 52 | }, 53 | }, 54 | }, 55 | }, 56 | }, 57 | } 58 | 59 | func TestYurtAppSetDefaulter(t *testing.T) { 60 | 61 | webhook := &YurtAppSetHandler{} 62 | 63 | if err := webhook.Default(context.TODO(), defaultAppSet); err != nil { 64 | t.Fatal(err) 65 | } 66 | 67 | } 68 | 69 | func TestYurtAppSetValidator(t *testing.T) { 70 | 71 | webhook := &YurtAppSetHandler{} 72 | 73 | // set default value 74 | if err := webhook.Default(context.TODO(), defaultAppSet); err != nil { 75 | t.Fatal(err) 76 | } 77 | 78 | if err := webhook.ValidateCreate(context.TODO(), defaultAppSet); err != nil { 79 | t.Fatal("yurtappset should create success", err) 80 | } 81 | 82 | dupTopology := defaultAppSet.DeepCopy() 83 | dupTopology.Spec.Topology = v1alpha1.Topology{Pools: []v1alpha1.Pool{{Name: "beijing"}, {Name: "beijing"}}} 84 | if err := webhook.ValidateCreate(context.TODO(), dupTopology); err == nil { 85 | t.Fatal("topology dup should not fail") 86 | } 87 | 88 | updateAppSet := defaultAppSet.DeepCopy() 89 | updateAppSet.Spec.WorkloadTemplate.DeploymentTemplate.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{"app": "demo2"}} 90 | if err := webhook.ValidateUpdate(context.TODO(), defaultAppSet, updateAppSet); err == nil { 91 | t.Fatal("workload selector change should fail") 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /pkg/yurtappmanager/webhook/yurtingress/yurtingress_webhook_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt authors. 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | // +kubebuilder:docs-gen:collapse=Apache License 14 | 15 | package yurtingress 16 | 17 | import ( 18 | "context" 19 | "testing" 20 | 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | clientgoscheme "k8s.io/client-go/kubernetes/scheme" 24 | "sigs.k8s.io/controller-runtime/pkg/client" 25 | "sigs.k8s.io/controller-runtime/pkg/client/fake" 26 | 27 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 28 | ) 29 | 30 | var defaultYurtIngress = &v1alpha1.YurtIngress{ 31 | ObjectMeta: metav1.ObjectMeta{ 32 | Name: "fooboo", 33 | Namespace: "default", 34 | }, 35 | Spec: v1alpha1.YurtIngressSpec{ 36 | Replicas: 1, 37 | IngressControllerImage: "registry.k8s.io/ingress-nginx/controller:v0.49.0", 38 | IngressWebhookCertGenImage: "registry.k8s.io/ingress-nginx/kube-webhook-certgen:v0.49.0", 39 | Pools: []v1alpha1.IngressPool{{Name: "beijing"}}, 40 | }, 41 | } 42 | 43 | func TestYurtAppSetDefaulter(t *testing.T) { 44 | webhook := &YurtIngressHandler{} 45 | if err := webhook.Default(context.TODO(), defaultYurtIngress); err != nil { 46 | t.Fatal(err) 47 | } 48 | } 49 | 50 | func TestYurtAppSetValidator(t *testing.T) { 51 | 52 | scheme := runtime.NewScheme() 53 | _ = clientgoscheme.AddToScheme(scheme) 54 | _ = v1alpha1.AddToScheme(scheme) 55 | 56 | bjNp := &v1alpha1.NodePool{ 57 | ObjectMeta: metav1.ObjectMeta{ 58 | Name: "beijing", 59 | Namespace: "default", 60 | }, 61 | Spec: v1alpha1.NodePoolSpec{}, 62 | } 63 | objs := []client.Object{bjNp} 64 | 65 | client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(objs...).Build() 66 | 67 | webhook := &YurtIngressHandler{Client: client} 68 | 69 | // set default value 70 | if err := webhook.Default(context.TODO(), defaultYurtIngress); err != nil { 71 | t.Fatal(err) 72 | } 73 | 74 | if err := webhook.ValidateCreate(context.TODO(), defaultYurtIngress); err != nil { 75 | t.Fatal("should create success", err) 76 | } 77 | 78 | npNotExist := defaultYurtIngress.DeepCopy() 79 | npNotExist.Spec.Pools = []v1alpha1.IngressPool{{Name: "noneexist"}} 80 | if err := webhook.ValidateCreate(context.TODO(), npNotExist); err == nil { 81 | t.Fatal("should create fail", err) 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /tests/e2e/e2e.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package e2e 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | "path" 23 | "testing" 24 | 25 | "github.com/onsi/ginkgo" 26 | "github.com/onsi/ginkgo/config" 27 | "github.com/onsi/ginkgo/reporters" 28 | "github.com/onsi/gomega" 29 | "k8s.io/apimachinery/pkg/util/uuid" 30 | "k8s.io/klog" 31 | 32 | "github.com/openyurtio/yurt-app-manager/tests/e2e/util/ginkgowrapper" 33 | "github.com/openyurtio/yurt-app-manager/tests/e2e/yurtconfig" 34 | ) 35 | 36 | func RunE2ETests(t *testing.T) { 37 | klog.Infof("[edge] Start run e2e test") 38 | gomega.RegisterFailHandler(ginkgowrapper.Fail) 39 | var r []ginkgo.Reporter 40 | if yurtconfig.YurtE2eCfg.ReportDir != "" { 41 | if err := os.MkdirAll(yurtconfig.YurtE2eCfg.ReportDir, 0755); err != nil { 42 | klog.Errorf("Failed creating report directory: %v", err) 43 | } else { 44 | r = append(r, reporters.NewJUnitReporter(path.Join(yurtconfig.YurtE2eCfg.ReportDir, fmt.Sprintf("yurt-e2e-test-report_%02d.xml", config.GinkgoConfig.ParallelNode)))) 45 | } 46 | } 47 | klog.Infof("Starting e2e run %q on Ginkgo node %d", uuid.NewUUID(), config.GinkgoConfig.ParallelNode) 48 | ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "yurt-app-manager e2e suites", r) 49 | } 50 | -------------------------------------------------------------------------------- /tests/e2e/util/ginkgowrapper/wrapper.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic 18 | // with structured data instead of a constant string. 19 | package ginkgowrapper 20 | 21 | import ( 22 | "bufio" 23 | "bytes" 24 | "regexp" 25 | "runtime" 26 | "runtime/debug" 27 | "strings" 28 | 29 | "github.com/onsi/ginkgo" 30 | ) 31 | 32 | // FailurePanic is the value that will be panicked from Fail. 33 | type FailurePanic struct { 34 | Message string // The failure message passed to Fail 35 | Filename string // The filename that is the source of the failure 36 | Line int // The line number of the filename that is the source of the failure 37 | FullStackTrace string // A full stack trace starting at the source of the failure 38 | } 39 | 40 | // String makes FailurePanic look like the old Ginkgo panic when printed. 41 | func (FailurePanic) String() string { return ginkgo.GINKGO_PANIC } 42 | 43 | // Fail wraps ginkgo.Fail so that it panics with more useful 44 | // information about the failure. This function will panic with a 45 | // FailurePanic. 46 | func Fail(message string, callerSkip ...int) { 47 | skip := 1 48 | if len(callerSkip) > 0 { 49 | skip += callerSkip[0] 50 | } 51 | 52 | _, file, line, _ := runtime.Caller(skip) 53 | fp := FailurePanic{ 54 | Message: message, 55 | Filename: file, 56 | Line: line, 57 | FullStackTrace: pruneStack(skip), 58 | } 59 | 60 | defer func() { 61 | e := recover() 62 | if e != nil { 63 | panic(fp) 64 | } 65 | }() 66 | 67 | ginkgo.Fail(message, skip) 68 | } 69 | 70 | // ginkgo adds a lot of test running infrastructure to the stack, so 71 | // we filter those out 72 | var stackSkipPattern = regexp.MustCompile(`onsi/ginkgo`) 73 | 74 | func pruneStack(skip int) string { 75 | skip += 2 // one for pruneStack and one for debug.Stack 76 | stack := debug.Stack() 77 | scanner := bufio.NewScanner(bytes.NewBuffer(stack)) 78 | var prunedStack []string 79 | 80 | // skip the top of the stack 81 | for i := 0; i < 2*skip+1; i++ { 82 | scanner.Scan() 83 | } 84 | 85 | for scanner.Scan() { 86 | if stackSkipPattern.Match(scanner.Bytes()) { 87 | scanner.Scan() // these come in pairs 88 | } else { 89 | prunedStack = append(prunedStack, scanner.Text()) 90 | scanner.Scan() // these come in pairs 91 | prunedStack = append(prunedStack, scanner.Text()) 92 | } 93 | } 94 | 95 | return strings.Join(prunedStack, "\n") 96 | } 97 | -------------------------------------------------------------------------------- /tests/e2e/yurtconfig/yurtconfig.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The OpenYurt Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package yurtconfig 18 | 19 | import ( 20 | restclient "k8s.io/client-go/rest" 21 | "sigs.k8s.io/controller-runtime/pkg/client" 22 | ) 23 | 24 | type YurtE2eConfig struct { 25 | NodeType string 26 | RestConfig *restclient.Config 27 | 28 | KubeClient client.Client 29 | ReportDir string 30 | } 31 | 32 | var YurtE2eCfg YurtE2eConfig 33 | -------------------------------------------------------------------------------- /tests/fuzz/Dockerfile.builder: -------------------------------------------------------------------------------- 1 | FROM gcr.io/oss-fuzz-base/base-builder-go 2 | 3 | COPY ./ $GOPATH/src/github.com/openyurtio/yurt-app-manager/ 4 | COPY ./tests/fuzz/oss_fuzz_build.sh $SRC/build.sh 5 | 6 | WORKDIR $SRC -------------------------------------------------------------------------------- /tests/fuzz/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/openyurtio/yurt-app-manager/tests/fuzz 2 | 3 | // This module is used only to avoid polluting the main module 4 | // with fuzz dependencies. 5 | 6 | go 1.16 7 | -------------------------------------------------------------------------------- /tests/fuzz/oss_fuzz_build.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The OpenYurt Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | #!/usr/bin/env bash 16 | 17 | set -euxo pipefail 18 | 19 | GOPATH="${GOPATH:-/root/go}" 20 | GO_SRC="${GOPATH}/src" 21 | PROJECT_PATH="github.com/openyurtio/yurt-app-manager" 22 | 23 | cd "${GO_SRC}" 24 | 25 | # Move fuzzer to their respective directories. 26 | # This removes dependency noises from the modules' go.mod and go.sum files. 27 | cp "${PROJECT_PATH}/tests/fuzz/yurtappdaemon_fuzzer.go" "${PROJECT_PATH}/pkg/yurtappmanager/controller/yurtappdaemon/yurtappdaemon_fuzzer.go" 28 | cp "${PROJECT_PATH}/tests/fuzz/yurtappset_fuzzer.go" "${PROJECT_PATH}/pkg/yurtappmanager/controller/yurtappset/yurtappset_fuzzer.go" 29 | 30 | # compile fuzz tests for the runtime module 31 | pushd "${PROJECT_PATH}" 32 | 33 | go get -d github.com/AdaLogics/go-fuzz-headers 34 | compile_go_fuzzer "${PROJECT_PATH}/pkg/yurtappmanager/controller/yurtappdaemon/" FuzzAppDaemonReconcile fuzz_yurtappdaemon_controller 35 | compile_go_fuzzer "${PROJECT_PATH}/pkg/yurtappmanager/controller/yurtappset/" FuzzAppSetReconcile fuzz_yurtappset_controller 36 | 37 | popd 38 | -------------------------------------------------------------------------------- /tests/fuzz/oss_fuzz_run.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The OpenYurt Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | #!/usr/bin/env bash 16 | 17 | set -euxo pipefail 18 | 19 | # run each fuzzer once to ensure they are working properly 20 | find /out -type f -name "fuzz*" -exec echo {} -runs=1 \; | bash -e 21 | -------------------------------------------------------------------------------- /tests/fuzz/yurtappdaemon_fuzzer.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | /* 5 | Copyright 2022 The OpenYurt Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | package yurtappdaemon 21 | 22 | import ( 23 | "context" 24 | 25 | fuzz "github.com/AdaLogics/go-fuzz-headers" 26 | corev1 "k8s.io/api/core/v1" 27 | "k8s.io/apimachinery/pkg/runtime" 28 | "k8s.io/apimachinery/pkg/types" 29 | clientgoscheme "k8s.io/client-go/kubernetes/scheme" 30 | "k8s.io/client-go/tools/record" 31 | "sigs.k8s.io/controller-runtime/pkg/client/fake" 32 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 33 | 34 | appsv1alpha1 "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/apis/apps/v1alpha1" 35 | "github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappdaemon/workloadcontroller" 36 | ) 37 | 38 | var ( 39 | fuzzCtx = context.Background() 40 | fakeSchemeForFuzzing = runtime.NewScheme() 41 | ) 42 | 43 | func init() { 44 | _ = clientgoscheme.AddToScheme(fakeSchemeForFuzzing) 45 | _ = appsv1alpha1.AddToScheme(fakeSchemeForFuzzing) 46 | _ = corev1.AddToScheme(fakeSchemeForFuzzing) 47 | } 48 | 49 | func FuzzAppDaemonReconcile(data []byte) int { 50 | f := fuzz.NewConsumer(data) 51 | 52 | appDaemon := &appsv1alpha1.YurtAppDaemon{} 53 | if err := f.GenerateStruct(appDaemon); err != nil { 54 | return 0 55 | } 56 | 57 | clientFake := fake.NewClientBuilder().WithScheme(fakeSchemeForFuzzing).WithObjects( 58 | appDaemon, 59 | ).Build() 60 | 61 | r := &ReconcileYurtAppDaemon{ 62 | Client: clientFake, 63 | scheme: fakeSchemeForFuzzing, 64 | recorder: record.NewFakeRecorder(10000), 65 | controls: map[appsv1alpha1.TemplateType]workloadcontroller.WorkloadControllor{ 66 | appsv1alpha1.DeploymentTemplateType: &workloadcontroller.DeploymentControllor{Client: clientFake, Scheme: fakeSchemeForFuzzing}, 67 | }, 68 | } 69 | 70 | _, _ = r.Reconcile(fuzzCtx, reconcile.Request{NamespacedName: types.NamespacedName{Name: appDaemon.Name, Namespace: appDaemon.Namespace}}) 71 | return 1 72 | } 73 | -------------------------------------------------------------------------------- /tests/kind-conf.yaml: -------------------------------------------------------------------------------- 1 | kind: Cluster 2 | apiVersion: kind.x-k8s.io/v1alpha4 3 | nodes: 4 | - role: control-plane 5 | - role: worker 6 | - role: worker 7 | 8 | #kind create cluster --config kind-conf.yaml --image kindest/node:v1.20.7 9 | --------------------------------------------------------------------------------