GithubHelp home page GithubHelp logo

apecloud / kbcli Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 11.0 40.97 MB

The CLI for KubeBlocks.

License: GNU Affero General Public License v3.0

Shell 4.57% Makefile 0.67% Go 92.92% Dockerfile 0.11% PowerShell 0.35% CUE 1.39%

kbcli's People

Contributors

1aal avatar ahjing99 avatar caiq1nyu avatar dengshaojiang avatar dependabot[bot] avatar fengluodb avatar free6om avatar heng4fun avatar huyongqii avatar iziang avatar jashbook avatar kizuna-lek avatar kubejocker avatar ldming avatar leon-inf avatar linghan-hub avatar lynnleelhl avatar michelle-0808 avatar nashtsai avatar nayutah avatar shanshanying avatar sophon-zt avatar talktocrystal avatar wangyelei avatar weicao avatar wusai80 avatar xuriwuyun avatar y-rookie avatar zhaodiankui avatar zjx20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kbcli's Issues

[Improvement] add auto-complete for edit config

kbcli cluster edit-config mycluster --component mysql --config-spec xxx

When there are multiple config specs, one must specify the config template name.
But the name is hard to remeber, and it's better to support auto-completion.

[Improvement] kubeblocks upgrade should check if the target version exits first

Is your improvement request related to a problem? Please describe.

kubeblocks upgrade should check if the target version exits first, otherwise, the kubeblocks will be stopped, but the new version can not be installed.

kbcli kb upgrade --version 0.7.1 
Current KubeBlocks version 0.7.0.
Upgrade KubeBlocks from 0.7.0 to 0.7.1
Please type 'Yes/yes' to confirm your operation: yes
Add and update repo kubeblocks                     OK
Stop KubeBlocks 0.7.0                              OK
Stop DataProtection                                OK
Upgrading KubeBlocks to 0.7.1                      FAIL
error: chart "kubeblocks" matching 0.7.1 not found in kubeblocks index. (try 'helm repo update'): no chart version found for kubeblocks-0.7.1

[Improvement] auto-complete for 'kbcli cluster delete-backup '

kbcli version 
KubeBlocks: 0.8.0-alpha.9
kbcli: 0.8.0-alpha.9

To reproduce:

  1. install kbcli and kubeblocks

install kbcli

curl -fsSL https://kubeblocks.io/installer/install_cli.sh | bash

and install kubeblocks

kbcli kubeblocks install

if there is no accessible k8s, just use our playground

 kbcli playground init

ref to: https://kubeblocks.io/docs/preview/user_docs/try-out-on-playground/try-kubeblocks-on-your-laptop
2. create a mysql cluster

 kbcli cluster create mycluster --cluster-definition apecloud-mysql --cluster
-version ac-mysql-8.0.30
  1. check cluster status, wait till it is running
 kbcli cluster list mycluster
image
  1. create a backup
kbcli cluster backup mycluster --method xtrabackup

Because there is no BackupRepo configured, this backup task should fail as expected.
image

  1. delete the backup by
image

If you type tab at this moment, there is no auto-completion for backup names.

For comprision, you can try

kbcli cluster list my<tab>

and cluster name mycluster will be completed.

[BUG] create-account failed to located primary pod

 kbcli cluster create-account -i apple89-mysql-0 --name test
Error from server (NotFound): pods "apple89-mysql-0" not found`

cause there is no ConsensusSetStatus, ReplicationSetStatus in cluster status.

[Improvement] Check existence of BackupRepo before creating a Backup

Kubernetes: v1.27.3
KubeBlocks: 0.8.0-alpha.9
kbcli: 0.8.0-alpha.9

There is no backup repo by default.
When one creates a cluster, say mysql raft-group cluster, and creates a backup for that cluster.
He won't any error message until he checks the status of the newly created backup CR.

  1. make sure there is no backup-repo
kbcli backuprepo list
No backup repository found
  1. create a mysql cluster
kbcli cluster create mysql mycluster
  1. create a backup
kbcli cluster backup mycluster --method xtrabackup

and this backup failed due to error: no default BackupRepo found

we'd better check the existence of backuprepo ahead.

kbcli can't delete cluster

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Desktop (please complete the following information):

  • kubernetes 1.23.15
  • kbcli branch main

Additional context
Add any other context about the problem here.

[BUG] "kbcli backuprepo create" reports errors when non-string flags are defined

Describe the bug

% kbcli backuprepo create --provider ftp --ftp-host my-ftp-service.default.svc.cluster.local --ftp-user user --ftp-password pass1234 --default
invalid value "" for "--ftp-port": Invalid type. Expected: integer, given: string
invalid value "" for "--ftp-tls": Invalid type. Expected: boolean, given: string
error: invalid flags

[BUG] make kbcli-doc failed in CI

Screenshots
image
Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

[BUG] update kubeblocks to new componentDefinition API verison

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

[BUG] Multiple version addon leave residual resources after kb uninstall

 ~ kbcli kb uninstall --auto-approve
Uninstall KubeBlocks in namespace "kb-system"
Wait for addons to be disabled
  snapshot-controller                              OK
Uninstall helm release kubeblocks 0.8.0-alpha.11   OK
Remove helm repo kubeblocks                        OK
Remove built-in custom resources                   OK
Remove actionsets                                  OK
Remove addons                                      OK
Remove backuppolicytemplates                       OK
Remove clusterdefinitions                          OK
Remove clusterversions                             OK
Remove componentclassdefinitions                   OK
Remove componentdefinitions                        OK
Remove configconstraints                           OK
Remove configmaps                                  OK
Remove customresourcedefinitions                   OK
Remove storageproviders                            OK
Uninstall KubeBlocks done.
➜  ~ kbcli kb install
KubeBlocks will be installed to namespace "kb-system"
error: there are resources left by previous KubeBlocks version, try to run "kbcli kubeblocks uninstall" to clean up
  configmaps: ape-0.8.0-auditlog-config-template,ape-0.8.0-scripts,ape-0.8.0-config-template,ape-0.8.0-agamotto-configuration,ape-0.8.0-vttablet-config-template,ape-0.8.0-vtconsensus-config-template,ape-0.8.0-vtgate-config-template

image

[Features] cherry-pick of the kbcli changes missed in KubeBlocks

Due to ongoing development in KubeBlocks during the process of splitting kbcli and KubeBlocks, new additions were made to the kbcli content in KubeBlocks after the complete separation of kbcli from KB. This is mainly reflected in PR #5801, #5803, and #5794

image

[Features]Set up kbcli github workflows

What is the user interaction of your feature
kbcli github workflows

  • test workflows
  • release workflows with KubeBlocks
  • release workflows for winget、scoop、npm、yum...

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

If this is a new feature, please describe the motivation and goals.
A clear and concise description of why you want to happen, link the design doc if possible

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[BUG] kbcli failed to connect cluster

due to the api refactoring, accounts are not provisioned as expected and kbcli failed to connect cluster as 'admin' user.
to workaround, using secret '-root-credential' instead for the moment.

[BUG]kbcli addon upgrade failed

➜ ~ kbcli version
Kubernetes: v1.27.3-gke.100
KubeBlocks: 0.8.0-beta.11
kbcli: 0.8.0-beta.11

➜  ~ kbcli addon upgrade zookeeper
error: addon 'zookeeper' not found in the index 'kubeblocks'
➜  ~ kbcli addon upgrade apecloud-mysql
error: addon 'apecloud-mysql' not found in the index 'kubeblocks'
➜  ~ kbcli addon upgrade clickhouse
error: addon 'clickhouse' not found in the index 'kubeblocks'
➜  ~ kbcli addon upgrade greptimedb
error: addon 'greptimedb' not found in the index 'kubeblocks'


➜  ~ kbcli addon index list
error: command execution failure, output="正克隆到 '/Users/mjingz/.kbcli/addon/index/kubeblocks'...\nfatal: 无法访问 'https://github.com/apecloud/block-index.git/':HTTP/2 stream 1 was not closed cleanly before end of the underlying stream\n": exit status 128

[BUG] kbcli cluster create panic

Describe the bug

image

➜  ~ kbcli cluster create --cluster-definition oracle --set memory=2GB
panic: cannot parse '2GB': quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'

goroutine 1 [running]:
k8s.io/apimachinery/pkg/api/resource.MustParse({0x16d35364e, 0x3})
	/home/runner/go/pkg/mod/k8s.io/[email protected]/pkg/api/resource/quantity.go:139 +0x10c
github.com/apecloud/kbcli/pkg/cmd/cluster.buildClusterComp(0x140009282c0, 0x1?, 0x16d35363a?)
	/home/runner/work/kubeblocks/kubeblocks/pkg/cmd/cluster/create.go:1058 +0x73c
github.com/apecloud/kbcli/pkg/cmd/cluster.(*CreateOptions).buildComponents(0x1400137f800, {0x0, 0x0, 0x7?})
	/home/runner/work/kubeblocks/kubeblocks/pkg/cmd/cluster/create.go:599 +0x154
github.com/apecloud/kbcli/pkg/cmd/cluster.(*CreateOptions).Complete(0x1400137f800)
	/home/runner/work/kubeblocks/kubeblocks/pkg/cmd/cluster/create.go:496 +0x250
github.com/apecloud/kbcli/pkg/cmd/cluster.NewCreateCmd.func1(0x1400138ff00?, {0x140007a7080?, 0x0?, 0x4?})
	/home/runner/work/kubeblocks/kubeblocks/pkg/cmd/cluster/create.go:268 +0x6c
github.com/spf13/cobra.(*Command).execute(0x1400137fb00, {0x140007a7040, 0x4, 0x4})
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x640
github.com/spf13/cobra.(*Command).ExecuteC(0x14000f52c00)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
k8s.io/component-base/cli.run(0x14000f52c00)
	/home/runner/go/pkg/mod/k8s.io/[email protected]/cli/run.go:146 +0x264
k8s.io/component-base/cli.RunNoErrOutput(...)
	/home/runner/go/pkg/mod/k8s.io/[email protected]/cli/run.go:84
main.main()
	/home/runner/work/kubeblocks/kubeblocks/cmd/cli/main.go:31 +0x20

[BUG] release action failed due to missing script

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

[BUG] kbcli cluster connect use kbadmin

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

[BUG]kbcli cluster describe failed

➜ ~ kbcli version
Kubernetes: v1.28.3-aliyun.1
KubeBlocks: 0.6.5
kbcli: 0.8.0-alpha.5
WARNING: version difference between kbcli (0.8.0-alpha.5) and kubeblocks (0.6.5)

➜ ~ kbcli cluster describe apecloud-pg -n kubeblocks-cloud
Error from server (NotFound): the server could not find the requested resource

➜ ~ k get cluster apecloud-pg -n kubeblocks-cloud
NAME CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS AGE
apecloud-pg postgresql postgresql-14.8.0 Delete Running 141m

➜ ~ kbcli cluster list apecloud-pg -n kubeblocks-cloud
NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME
apecloud-pg kubeblocks-cloud postgresql postgresql-14.8.0 Delete Running Nov 17,2023 15:26 UTC+0800

[Improvement] add kubeblocks-addon as submodule of kbcli

KBCLI will build some charts as embeded-chart fo fast creation

.PHONY: build-kbcli-embed-chart
build-kbcli-embed-chart: helmtool fetch-addons create-kbcli-embed-charts-dir \
	build-single-kbcli-embed-chart.apecloud-mysql-cluster \
	build-single-kbcli-embed-chart.redis-cluster \
	build-single-kbcli-embed-chart.postgresql-cluster \
	build-single-kbcli-embed-chart.kafka-cluster \
	build-single-kbcli-embed-chart.mongodb-cluster \
	...

That's why KBCLI should fetch the laste version of kubeblocks-addons repo.
we may use GIT submodule to manage this repo.

[Improvement]kbcli cluster connect starrock return "unsupported engine type" if we do not support it

After I upgrade kb/kbcli from 0.7.2 to 0.8.0-beta.35 and try to kbcli cluster connect starrock, following error returned, we should return "unsupported engine type" as other engines if we do not support kbcli connect starrock

➜  ~ kbcli72 version
Kubernetes: v1.27.3-gke.100
KubeBlocks: 0.8.0-beta.35
kbcli: 0.7.2
WARNING: version difference between kbcli (0.7.2) and kubeblocks (0.8.0-beta.35)
➜  ~ kbcli72 cluster connect starrock-gdjmzp
Connect to instance starrock-gdjmzp-fe-0
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
command terminated with exit code 1

➜  ~ kbcli version
Kubernetes: v1.27.3-gke.100
KubeBlocks: 0.8.0-beta.35
kbcli: 0.8.0-beta.36
WARNING: version difference between kbcli (0.8.0-beta.36) and kubeblocks (0.8.0-beta.35)
➜  ~ kbcli cluster connect starrock-gdjmzp
Connect to instance starrock-gdjmzp-fe-0
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
command terminated with exit code 1

➜  ~ k get secret starrock-gdjmzp-conn-credential  -o yaml
apiVersion: v1
data:
  endpoint: c3RhcnJvY2stZ2RqbXpwLWZlLmRlZmF1bHQuc3ZjOjkwMzA=
  host: c3RhcnJvY2stZ2RqbXpwLWZlLmRlZmF1bHQuc3Zj
  password: ""
  port: OTAzMA==
  username: cm9vdA==
kind: Secret
metadata:
  creationTimestamp: "2024-01-04T02:54:37Z"
  finalizers:
  - cluster.kubeblocks.io/finalizer
  labels:
    app.kubernetes.io/instance: starrock-gdjmzp
    app.kubernetes.io/managed-by: kubeblocks
    app.kubernetes.io/name: starrocks
  name: starrock-gdjmzp-conn-credential
  namespace: default
  ownerReferences:
  - apiVersion: apps.kubeblocks.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Cluster
    name: starrock-gdjmzp
    uid: f1172145-0d21-4a80-a88b-4be6bd0a1710
  resourceVersion: "27527"
  uid: 014d3806-3f2b-44c0-9bc7-8b00aca8e180
type: Opaque

[BUG]kbcli login failed

➜ ~ kbcli version
Kubernetes: v1.27.3-gke.100
KubeBlocks: 0.7.1-beta.1
kbcli: 0.8.0-alpha.5

➜  ~ kbcli login
Successfully logged in as "[email protected]" for organization "" ("") "".
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
[github.com/apecloud/kbcli/pkg/cmd/auth.getFirstContext](http://github.com/apecloud/kbcli/pkg/cmd/auth.getFirstContext)({0x140003b2f00?, 0x4a6?}, {0x14001594330?, 0x104bdcd68?})
        /home/runner/work/kubeblocks/kubeblocks/pkg/cmd/auth/login.go:250 +0xd8
[github.com/apecloud/kbcli/pkg/cmd/auth.(*LoginOptions).loginWithDefault](http://github.com/apecloud/kbcli/pkg/cmd/auth.(*LoginOptions).loginWithDefault)(0x104bdcd68?, {0x104c17c90?, 0x106e6c860?})
        /home/runner/work/kubeblocks/kubeblocks/pkg/cmd/auth/login.go:195 +0x68
[github.com/apecloud/kbcli/pkg/cmd/auth.(*LoginOptions).run](http://github.com/apecloud/kbcli/pkg/cmd/auth.(*LoginOptions).run)(0x0?, {0x104c17c90?, 0x106e6c860?})
        /home/runner/work/kubeblocks/kubeblocks/pkg/cmd/auth/login.go:100 +0x6c
[github.com/apecloud/kbcli/pkg/cmd/auth.NewLogin.func1](http://github.com/apecloud/kbcli/pkg/cmd/auth.NewLogin.func1)(0x14000ec8300, {0x106e6c860?, 0x0?, 0x0?})
        /home/runner/work/kubeblocks/kubeblocks/pkg/cmd/auth/login.go:55 +0x90
[github.com/spf13/cobra.(*Command).execute](http://github.com/spf13/cobra.(*Command).execute)(0x14000ec8300, {0x106e6c860, 0x0, 0x0})
        /home/runner/go/pkg/mod/[github.com/spf13/[email protected]/command.go:944](http://github.com/spf13/[email protected]/command.go:944) +0x640
[github.com/spf13/cobra.(*Command).ExecuteC(0x14000ec8000)](http://github.com/spf13/cobra.(*Command).ExecuteC(0x14000ec8000))
        /home/runner/go/pkg/mod/[github.com/spf13/[email protected]/command.go:1068](http://github.com/spf13/[email protected]/command.go:1068) +0x320
[github.com/spf13/cobra.(*Command).Execute(...)](http://github.com/spf13/cobra.(*Command).Execute(...))
        /home/runner/go/pkg/mod/[github.com/spf13/[email protected]/command.go:992](http://github.com/spf13/[email protected]/command.go:992)
[k8s.io/component-base/cli.run(0x14000ec8000)](http://k8s.io/component-base/cli.run(0x14000ec8000))
        /home/runner/go/pkg/mod/[k8s.io/[email protected]/cli/run.go:146](http://k8s.io/[email protected]/cli/run.go:146) +0x264
[k8s.io/component-base/cli.RunNoErrOutput(...)](http://k8s.io/component-base/cli.RunNoErrOutput(...))
        /home/runner/go/pkg/mod/[k8s.io/[email protected]/cli/run.go:84](http://k8s.io/[email protected]/cli/run.go:84)
main.main()
        /home/runner/work/kubeblocks/kubeblocks/cmd/cli/main.go:31 +0x20

[Features] support set image registry

kbcli should support to set the image registry as a environment variable, this image registry can be used when install KB or enable addon.

Back port to release 0.7.

[Improvement] kubeblocks config command do not stop KubeBlocks

Is your improvement request related to a problem? Please describe.

kbcli kb config --set storageClass.name="test"
Current KubeBlocks version 0.7.0.
Add and update repo kubeblocks                     OK
Stop KubeBlocks 0.7.0                              OK
Stop DataProtection                                OK
Upgrading KubeBlocks                               FAIL

[Features]Support installing multiple versions for one kind of addon

What is the user interaction of your feature
A concise description of user interactions or user stories of your feature request

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

If this is a new feature, please describe the motivation and goals.
A clear and concise description of why you want to happen, link the design doc if possible

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[Improvement] kbcli support audit log filter

Is your improvement request related to a problem? Please describe.
kbcli cluster logs mycluster --file-type=audit --startTime='1970-01-01 00:00:00' --endTime='1970-01-02 00:00:00'
kbcli cluster logs mycluster --file-type=audit --startTime='1970-01-01 00:00:00' --endTime='1970-01-02 00:00:00' --filterkey='select'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.