Git Product home page Git Product logo

ks's Introduction

Gitpod ready-to-code Contributors GitHub release GitHub All Releases

ks

ks is a tool which makes it be easy to work with KubeSphere.

asciicast

Get started

Install it via hd:

curl -L https://github.com/linuxsuren/http-downloader/releases/latest/download/hd-linux-amd64.tar.gz | tar xzv
sudo mv hd /usr/bin/hd
hd install kubesphere-sigs/ks

Features

All features below work with KubeSphere instead of other concept.

  • Component Management
    • Enable (disable) components
    • Update a component manually or automatically
    • Output the logs of a KubeSphere component
    • Edit a KubeSphere component
    • Describe a KubeSphere component (wrapper of kubectl describe)
  • Pipeline management
    • Create a Pipeline with java, go template
    • Edit a Pipeline without give the fullname (namespace/name)
  • User Management
  • Working with k3s via setting environment kubernetes_type=k3s
  • KubeSphere installation

Component

➜  ~ kubectl ks com
Manage the components of KubeSphere

Usage:
  ks component [command]

Aliases:
  component, com

Available Commands:
  edit        Edit the target component
  enable      Enable or disable the specific KubeSphere component
  exec        Execute a command in a container.
  kill        Kill the pods of the components
  log         Output the log of KubeSphere component
  reset       Reset the component by name
  watch       Update images of ks-apiserver, ks-controller-manager, ks-console

Pipeline

➜  ~ kubectl ks pip
Usage:
  ks pipeline [flags]
  ks pipeline [command]

Aliases:
  pipeline, pip

Available Commands:
  create      Create a Pipeline in the KubeSphere cluster
  delete      Delete a specific Pipeline of KubeSphere DevOps
  edit        Edit the target pipeline
  view        Output the YAML format of a Pipeline

Flags:
  -h, --help   help for pipeline

Use "ks pipeline [command] --help" for more information about a command.

Installation

Install KubeSphere with kind or kk

Usage:
  ks install [command]

Available Commands:
  kind        Install KubeSphere with kind
  kk          Install KubeSphere with kubekey (aka kk)

ks's People

Contributors

chilianyi avatar dependabot[bot] avatar johnniang avatar ks-ci-bot avatar linuxsuren avatar seanly avatar selamanse avatar shihaoh avatar yudong2015 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

ks's Issues

Request to support component uninstallation feature

At present, official website has provided a document about how to uninstall each component.

But it's not very friendly for end users to execute so many command at the same time.

Therefore, I request to support component uninstallation in ks command. e.g.:

ks uninstall devops
ks uninstall logging
ks uninstall alerting
...

# Or uninstall all component but basic component
ks uninstall all

/kind feature

In k3d v5.0.0+ , not compatible

k3d version: v5.0.0
exec ks install k3d
Action:

FATA[0000] failed to transform ports: Failed to parse node filters: invalid format or empty subset in 'agent[0]'

This is how the k3d documentation describes it

 -p, --port [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]   Map ports from the node containers (via the serverlb) to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER])
                                                                        - Example: `k3d cluster create --agents 2 -p 8080:80@agent:0 -p 8081@agent:1`

Add support to install KubeSphere in kind

This feature might be a plugin of this repo.

cat <<EOF | kind create cluster --image kindest/node:v1.18.2 --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 30880
    hostPort: 30881
    protocol: TCP
  - containerPort: 30180
    hostPort: 30181
    protocol: TCP
EOF

docker pull kubesphere/ks-installer:v3.0.0
docker pull kubesphere/ks-apiserver:v3.0.0
docker pull kubesphere/ks-controller-manager:v3.0.0
docker pull kubesphere/ks-console:v3.0.0
docker pull redis:5.0.5-alpine
docker pull osixia/openldap:1.3.0
docker pull minio/minio:RELEASE.2019-08-07T01-59-21Z
docker pull mysql:8.0.11
kind load docker-image kubesphere/ks-installer:v3.0.0
kind load docker-image kubesphere/ks-apiserver:v3.0.0
kind load docker-image kubesphere/ks-controller-manager:v3.0.0
kind load docker-image kubesphere/ks-console:v3.0.0
kind load docker-image redis:5.0.5-alpine
kind load docker-image osixia/openldap:1.3.0
kind load docker-image minio/minio:RELEASE.2019-08-07T01-59-21Z
kind load docker-image mysql:8.0.11

kubectl cluster-info --context kind-kind
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/kubesphere-installer.yaml
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/cluster-configuration.yaml

# load the necessary images for devops
docker pull kubesphere/jenkins-uc:v3.0.0
docker pull jenkins/jenkins:2.176.2
kind load docker-image kubesphere/jenkins-uc:v3.0.0
kind load docker-image jenkins/jenkins:2.176.2

# load the image of Jenkins agent builder
docker pull jenkins/jnlp-slave:3.27-1
docker pull kubesphere/builder-base:v2.1.0
docker pull kubesphere/builder-nodejs:v2.1.0
docker pull kubesphere/builder-go:v2.1.0
docker pull kubesphere/builder-maven:v2.1.0
kind load docker-image kubesphere/builder-base:v2.1.0
kind load docker-image kubesphere/builder-nodejs:v2.1.0
kind load docker-image kubesphere/builder-go:v2.1.0
kind load docker-image kubesphere/builder-maven:v2.1.0
kind load docker-image jenkins/jnlp-slave:3.27-1

kubectl ks com enable devops

No root permission, no permission to install k3d

When I use not root permission and install k3d, tips no permission. but when the user has ![image](https://user-images.githubusercontent.com/20575981/132883990-564cbb88-73e2-4ec0-81ff-a0991b8cfbc8.png)do permission, sudo ks install k3d is ok.
no permission install

sudo user install

So I suggest describing the installation method clearly.

Request to add event list for Pipeline, PipelineRun in Pipeline dashboard

Currently, If we encounter a problem with PipelineRun, we have no idea to know what happened. But our reconcilers may store some events about the result of Pipeline or PipelineRun.

As a result, I request to add event list for Pipeline, PipelineRun in Pipeline dashboard to let users know what happened just now whether it is successful.

/kind feature

Couldn't install kubectl-ks correctly via README.md

In README.md, I was trying to execute command hd install -t 8 linuxsuren/ks/kubectl-ks to install k8s and ks, but failed eventually. Full error log as follow:

start to fetch the config
From https://github.com/LinuxSuRen/hd-home
 * branch            master     -> FETCH_HEAD
HEAD is now at 48ee4a8 Add cgit in the package list (#27)
start to download from https://github.com/linuxsuren/ks/releases/latest/download/kubectl-ks-windows-amd64.tar.gz
Error: cannot download from https://github.com/linuxsuren/ks/releases/latest/download/kubectl-ks-windows-amd64.tar.gz, response error: failed to download from 'https://github.com/linuxsuren/ks/releases/latest/download/kubectl-ks-windows-amd64.tar.gz': status code: 404, content length error: <nil>

I found that github releases' detail didn't list any assets which name started with "kubectl-ks".

Request to release a new version 0.0.54

Since v0.0.53 was released, several bugs have been fixed.

I'm looking forward to the next release to test KubeSphere with pre-release version.

/cc @kubesphere-sigs/sig-devops

Add support create docker registry repo in secret format

Below is an example of docker registry as secret in KubeSphere project:

apiVersion: v1
data:
  .dockerconfigjson: eyJhdXRocyI6eyJodHRwczovL2RvY2tlci5pbyI6eyJ1c2VybmFtZSI6InN1cmVucGkiLCJwYXNzd29yZCI6IjEyMzQ1NiIsImVtYWlsIjoiIiwiYXV0aCI6ImMzVnlaVzV3YVRveE1qTTBOVFk9In19fQ==
kind: Secret
metadata:
  annotations:
    kubesphere.io/creator: admin
  creationTimestamp: "2021-03-09T01:07:50Z"
  name: "22"
  namespace: b2i
  resourceVersion: "240359"
  selfLink: /api/v1/namespaces/b2i/secrets/22
  uid: a6f09f64-c3b2-46e0-b898-91b70bc409ad
type: kubernetes.io/dockerconfigjson

Why need this?

It can benefit automated tests.

Cannot use ks in the KubeSphere kubectl console

You will get the errors like below:

/ # ks pip
stat /root/.kube/config: no such file or directory
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1387442]

goroutine 1 [running]:
github.com/linuxsuren/ks/kubectl-plugin/pipeline.getAllNamespace(0x0, 0x0, 0x203000, 0xc0000b3958, 0x759cf3cb6dc993e)
        /home/runner/work/ks/ks/kubectl-plugin/pipeline/root.go:64 +0x82
github.com/linuxsuren/ks/kubectl-plugin/pipeline.getNamespace(0x0, 0x0, 0x250e990, 0x0, 0x0, 0x0, 0x153de60, 0xffffffffffffffff, 0xc0
000b3a20)
        /home/runner/work/ks/ks/kubectl-plugin/pipeline/root.go:44 +0xd5
github.com/linuxsuren/ks/kubectl-plugin/pipeline.getPipelines(0x0, 0x0, 0x250e990, 0x0, 0x0, 0xc0000b3b90, 0xc0000b3bb8, 0xc0000b3bb8
, 0x5bad44, 0xc0000e3700, ...)
        /home/runner/work/ks/ks/kubectl-plugin/pipeline/edit.go:95 +0x3f2
github.com/linuxsuren/ks/kubectl-plugin/pipeline.NewPipelineCmd.func1(0xc0001458c0, 0x250e990, 0x0, 0x0, 0x0, 0x0)
        /home/runner/work/ks/ks/kubectl-plugin/pipeline/root.go:21 +0x6c
github.com/spf13/cobra.(*Command).execute(0xc0001458c0, 0x250e990, 0x0, 0x0, 0xc0001458c0, 0x250e990)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000dd080, 0x7, 0x174ce88, 0x1)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
github.com/linuxsuren/go-cli-alias/pkg/cmd.Execute(0xc0000dd080, 0x175144d, 0x7, 0xc000375400, 0x13, 0x13, 0x0)
        /home/runner/go/pkg/mod/github.com/linuxsuren/[email protected]/pkg/cmd/root.go:130 +0x644
main.main()
        /home/runner/work/ks/ks/main.go:53 +0x32b

Failed to exec into a component

Please see also the following error output:

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.

Request to support installation of KubeSphere v3.1.1

[root@node1 ~]# ks install kk --components devops --version v3.1.1

Flags:
      --components stringArray   The components which you want to enable after the installation
      --container string         Indicate the container runtime type. Supported: docker, containerd (default "docker")
      --fetch                    Indicate if fetch the latest config of tools (default true)
  -h, --help                     help for kk
  -v, --version string           The version of KubeSphere. Support value could be v3.1.0, nightly, nightly-20210309. nightly equals to nightly-latest (default "v3.1.0")
      --zone string              Set environment variables, for example export KKZONE=cn (default "cn")

not support version: v3.1.1

Request to support import a member cluster

Possible usage: ks opt cluster import

This command might do the following things:

  • check the current cluster if is the host role
  • let users choose from context (~/.kube/config)
  • import

Incorrect GC behaviour for PipelineRuns

What's the problem?

Recently, I encountered that my pending or running PipelineRuns disappeared suddenly, even in Jenkins. So I guess it may be GCed by cronjob-gc. I will show the evidence up below.

Steps to reproduce

  1. Create a simple Pipeline with Jenkinsfile as below:
pipeline {
    agent any 
    stages {
        stage('Greet') { 
            steps {
              sh 'echo "Hello, Jenkins!" && ping bing.com'
            }
        }
    }
}
  1. Click Run button to run the Pipeline
  2. Then Run the GC job immediately
kubectl -n kubesphere-devops-system create job gc-test-job --from=cronjob/devops
  1. See the PipelineRun you just run

/kind bug

Failed to install KubeSphere via ks install kk on a fresh machine

The command is:

ks install kk --kubernetesVersion v1.21.5

The error output is:

time="10:40:52 CST" level=error msg="Failed to connect to 192.168.0.3: Failed to validate ssh connection parameters: Failed to read keyfile \"/root/.ssh/id_rsa\": open /root/.ssh/id_rsa: no such file or directory" node=192.168.0.3
time="10:40:52 CST" level=warning msg="Task failed ..."
time="10:40:52 CST" level=warning msg="error: interrupted by error"
Error: Failed to init OS: interrupted by error
Failed to init OS: interrupted by error

It still cannot work after I generated the ssh key with the following command:

ssh-keygen

the error output is:

time="10:57:28 CST" level=error msg="Failed to connect to 192.168.0.3: could not establish connection to 192.168.0.3:22: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain" node=192.168.0.3
time="10:57:28 CST" level=warning msg="Task failed ..."
time="10:57:28 CST" level=warning msg="error: interrupted by error"
Error: Failed to init OS: interrupted by error
Failed to init OS: interrupted by error

then, I put the content of /root/.ssh/id_rsa.pub into the end of /root/.ssh/authorized_keys. It works well.

Suggestion

I'd like to suggest doing all those work by the command ks install kk. So users don't need to do it over and over again.

Add gray release support

You can get the release strategy list via: ks get --all-namespaces strategy. Below is an example:

apiVersion: servicemesh.kubesphere.io/v1alpha2
kind: Strategy
metadata:
  annotations:
    app.kubernetes.io/icon: /assets/bookinfo.svg
    kubesphere.io/creator: admin
    servicemesh.kubesphere.io/newWorkloadName: details-v2
    servicemesh.kubesphere.io/oldWorkloadName: details-v1
    servicemesh.kubesphere.io/workloadReplicas: "1"
    servicemesh.kubesphere.io/workloadType: deployments
  creationTimestamp: "2021-03-15T05:43:22Z"
  generation: 1
  labels:
    app: details
    app.kubernetes.io/name: bookinfo
    app.kubernetes.io/version: v1
  name: blue-test-1
  namespace: ks
  ownerReferences:
  - apiVersion: app.k8s.io/v1beta1
    blockOwnerDeletion: true
    controller: false
    kind: Application
    name: bookinfo
    uid: 8eb1bbec-d44f-4d5f-8507-500e92775234
  resourceVersion: "152221"
  selfLink: /apis/servicemesh.kubesphere.io/v1alpha2/namespaces/ks/strategies/blue-test-1
  uid: 2ca3bc16-1e91-4cc5-b200-e9630bd2fac0
spec:
  governor: v1
  hosts: details
  principal: v1
  protocol: http
  selector:
    matchLabels:
      app: details
      app.kubernetes.io/name: bookinfo
      app.kubernetes.io/version: v1
  strategyPolicy: WaitForWorkloadReady
  template:
    spec:
      hosts:
      - details
      http:
      - route:
        - destination:
            host: details
            subset: v1
          weight: 100
        - destination:
            host: details
            subset: "1"
          weight: 0
  type: Bluegreen

Deploy bitbucket for the test purpose

The possible docker images:

  • atlassian/bitbucket-server:7.10.0
  • atlassian/bitbucket-server:7.6.4
  • atlassian/bitbucket-server:7.2.4

Get started

Run it via:

docker volume create --name bitbucketVolume
docker run -d -v bitbucketVolume:/var/atlassian/application-data/bitbucket \
    -p 30000:7990 -p 30001:7999 \
    atlassian/bitbucket-server:7.10.0

Add a command to setup KubeSphere

case 1

Sometimes we need multiple environments for development and testing purposes. It's hard to memorize the address of those KubeSphere clusters. Even worse, part of those environments might be temporary. Give that, it would be good to have a simple way to set up a remote kubeclt connection locally, open the console of the KubeSphere cluster.

You can consider the following usage:

ks config add --cluster dev --host 192.168.0.3

The above command will get the token of the default serviceAccount, then add it to ~/.kube/config as dev. Secondly, create a configMap to store the address of the cluster. It could be like:

kind: ConfigMap
apiVersion: v1
data:
  externalAddress: http://192.168.0.3:30880

If you want to open it in your browser, just need to type: ks open dev.

Add support to create a project in KubeSphere workspace

Below is an example of a project:

apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kubesphere.io/creator: admin
  finalizers:
  - finalizers.kubesphere.io/namespaces
  labels:
    kubesphere.io/namespace: b2i
    kubesphere.io/workspace: test
  name: b2i
  ownerReferences:
  - apiVersion: tenant.kubesphere.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Workspace
    name: test
    uid: 45ed0813-fb91-41d7-af5c-1aa1526d99d4
spec:
  finalizers:
  - kubernetes
status:
  phase: Active

Why need this?

It can benefit automated tests.

ks app update command report error: "failed to push changes, error is: failed to push branch, error is: failed to commit changes, error is author field is required"

I use ks app update command, as follows:

ks app update --app-name test11111 --app-namespace testqgg2s --name old-image-addr --newName new-image-addr:newtag --git-password 'O>hx@q012I' --git-username=app-mwcn --git-target-branch dev

encountered an error:

failed to push changes, error is: failed to push branch, error is: failed to commit changes, error is author field is required

I checked the source code and probably found the code location where the problem is:
image

image

Add support to set federal cluster

KubeSphere support the federal cluster. It can set a Kubernetes cluster to be a member or host role. So, the first feature that I want to have is making a cluster to be a member or host.

Second, support to add a cluster to be a member of the host cluster. It can be a direct connection or agent mode.

See also the official document here.

Add support to pre-load images in KubeSphere cluster

Some images will be loaded during the runtime instead of the installation phase of KubeSphere. It's very reasonable. But for the users, might need to wait for a while before all the necessary images are ready. Case 2, users might want to use KubeSphere in a private environment which means there's no internet.

So what I want to propose is that provide a command to pre-load all necessary images as the need to the target environment.

For the machine which can access the internet, the usage could be ks images load --components devops

For no internet case, the usage could be ks images save --components devops, then load them by offline mode.

How to get the whole images list

You can get the list from file images-list.txt

One question is that it does not tell us the relation between images and components. I guess re-org the file from .txt to .yaml will be better.

Add support to create credential in DevOps project

Username & Password

apiVersion: v1
data:
  password: YXNkZg==
  username: YXNkZg==
kind: Secret
metadata:
  annotations:
    credential.devops.kubesphere.io/autosync: "true"
    credential.devops.kubesphere.io/datahash: 848fbcbc7d
    credential.devops.kubesphere.io/syncstatus: successful
    credential.devops.kubesphere.io/synctime: 2021-03-08 16:45:31.889544672 +0800
      CST m=+6505.581589688
    kubesphere.io/creator: admin
  creationTimestamp: "2021-03-08T08:45:31Z"
  finalizers:
  - finalizers.kubesphere.io/credential
  labels:
    app: abc
  name: abc
  namespace: test2tkk7
  resourceVersion: "31863"
  selfLink: /api/v1/namespaces/test2tkk7/secrets/abc
  uid: a05fd2b8-2661-4df5-811d-ac4252817205
type: credential.devops.kubesphere.io/basic-auth

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.