-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add krew support for bilibili tool Signed-off-by: chenliu1993 <[email protected]>
- Loading branch information
1 parent
9e94909
commit 1c21c28
Showing
19 changed files
with
1,395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,3 +358,8 @@ tencentScf/.env | |
|
||
# vs code | ||
.vscode | ||
|
||
# krew | ||
krew/bilipro | ||
krew/cmd/kubectl-bilipro | ||
krew/kustomization.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.DEFAULT_GOAL:=help | ||
SHELL := /usr/bin/env bash | ||
|
||
ROOT_DIR := $(shell git rev-parse --show-toplevel) | ||
GOOS ?= $(shell go env GOOS) | ||
GOARCH ?= $(shell go env GOARCH) | ||
|
||
|
||
GITCOMMIT ?= `git rev-parse HEAD` | ||
|
||
help: #### display help | ||
@awk 'BEGIN {FS = ":.*## "; printf "\nTargets:\n"} /^[a-zA-Z_-]+:.*?#### / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
@awk 'BEGIN {FS = ":.* ## "; printf "\n \033[1;32mBuild targets\033[36m\033[0m\n \033[0;37mTargets for building and/or installing CLI plugins on the system.\n Append \"ENVS=<os-arch>\" to the end of these targets to limit the binaries built.\n e.g.: make build-all-tanzu-cli-plugins ENVS=linux-amd64 \n List available at https://github.com/golang/go/blob/master/src/go/build/syslist.go\033[36m\033[0m\n\n"} /^[a-zA-Z_-]+:.*? ## / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
##### GLOBAL | ||
|
||
.PHONY: build | ||
build: #### build the plugin | ||
go vet ./... && \ | ||
go fmt ./... && \ | ||
cd ./cmd && \ | ||
GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags "-X github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/cmd.Version=${GITCOMMIT}" -o kubectl-bilipro kubectl-bilipro.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# BiliBili Pro Kubectl Plugin | ||
|
||
## Prerequisites | ||
|
||
- Kubernetes >= v1.23.0. | ||
- go >= v1.18 | ||
- kubectl installed on your local machine, configured to an existing healthy Kubernetes cluster. | ||
- [krew](https://krew.sigs.k8s.io/docs/user-guide/setup/install/) plugin installed | ||
|
||
## Install Plugin | ||
|
||
Command: `cd ./krew && make build` | ||
The binary will be generated in cmd/ install it alonside the kubectl binary. For example the kubectl is installed under `/usr/bin`, then put the bilibilipro plugin under `/usr/bin` too. | ||
|
||
## Plugin Commands | ||
|
||
### Deployment && Update | ||
|
||
Command: `kubectl bilipro init --config config.yaml` | ||
|
||
Creates Deployment with the needed environments. | ||
|
||
|
||
Optional Options: | ||
|
||
- `--image=zai7lou/bilibili_tool_pro:0.2.1` | ||
- `--namespace=bilipro` | ||
- `--image-pull-secret=` | ||
|
||
Required Options: | ||
|
||
- `--config=<config.yaml>` | ||
|
||
The content of <config.yaml> is a yaml array, please refer to the example config yaml under the krew directory. | ||
|
||
Suggestions: Deploy this workload in namespace other than default or kube-* namespace, because the delete logic should be improved | ||
|
||
### Deletion | ||
|
||
Command: `kubectl bilipro delete [options]` | ||
|
||
Deletes Deployment. | ||
v | ||
Optional Options: | ||
|
||
- `--namespace=<deploy-namespace>` | ||
- `--name=<deploy-name>` | ||
|
||
### Version | ||
|
||
Command: `kubectl bilipro version` | ||
|
||
Output the plugin version. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/pflag" | ||
|
||
"github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/cmd" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
) | ||
|
||
func main() { | ||
flags := pflag.NewFlagSet("kubectl-bilipro", pflag.ExitOnError) | ||
pflag.CommandLine = flags | ||
|
||
cmd := cmd.NewExecutor(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}) | ||
if err := cmd.Execute(); err != nil { | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- name: Ray_BiliBiliCookies__2 | ||
value: "cookie" | ||
# DailyTrigger - required | ||
- name: Ray_DailyTaskConfig__Cron | ||
value: "11 11 * * *" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module github.com/RayWangQvQ/BiliBiliToolPro/krew | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/spf13/cobra v1.4.0 | ||
github.com/spf13/pflag v1.0.5 | ||
k8s.io/api v0.25.4 | ||
k8s.io/cli-runtime v0.25.4 | ||
k8s.io/klog/v2 v2.70.1 | ||
sigs.k8s.io/kustomize/api v0.12.1 | ||
sigs.k8s.io/kustomize/kyaml v0.13.9 | ||
sigs.k8s.io/yaml v1.2.0 | ||
) | ||
|
||
require ( | ||
github.com/PuerkitoBio/purell v1.1.1 // indirect | ||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/emicklei/go-restful/v3 v3.8.0 // indirect | ||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect | ||
github.com/go-errors/errors v1.0.1 // indirect | ||
github.com/go-logr/logr v1.2.3 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.5 // indirect | ||
github.com/go-openapi/jsonreference v0.19.5 // indirect | ||
github.com/go-openapi/swag v0.19.14 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/btree v1.0.1 // indirect | ||
github.com/google/gnostic v0.5.7-v3refs // indirect | ||
github.com/google/gofuzz v1.1.0 // indirect | ||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect | ||
github.com/google/uuid v1.1.2 // indirect | ||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect | ||
github.com/imdario/mergo v0.3.6 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect | ||
github.com/mailru/easyjson v0.7.6 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/xlab/treeprint v1.1.0 // indirect | ||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect | ||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect | ||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect | ||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect | ||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/apimachinery v0.25.4 // indirect | ||
k8s.io/client-go v0.25.4 // indirect | ||
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect | ||
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect | ||
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect | ||
) | ||
|
||
replace github.com/RayWangQvQ/BiliBiliToolPro/krew => ../krew |
Oops, something went wrong.