Home

Awesome

中文 README.md

Web Kubectl - Run kubectl command in web browser

Downloads Go Report Card License Dockerized Version

webkubectl

Goal

Web Kubectl helps you manage kubernetes credentials and run kubectl command in web browser, so that you don't have to install kubectl on your local PC or some other servers, furthermore Web Kubectl can be used for a team.

Advantage

_______________________________________________________________________
|   Local Network     |          DMZ           |      VPC/Datacenter  |
|                     |                        |                      |
|                     |    _______________     |   ----------------   |
|   ---------------   |    |             |  /~~~~~>| Kubernetes A |   |
|   | Your Laptop |~~~~~~~>| Web Kubectl | /   |   ----------------   |
|   ---------------   |    |             | \   |                      |
|                     |    ---------------  \  |   ----------------   |
|                     |                      \~~~~>| Kubernetes B |   |
|                     |                        |   ----------------   |
-----------------------------------------------------------------------

Architecture

Web Kubectl use webkubectl/gotty to run a JavaScript based terminal on web browsers.<br> When opens a new session, a temporary Linux namespace will be created for the session, this make sure all sessions are isolated, each session has its own namespace and storage, meanwhile .kube/config file is generated for current session.<br> When session terminated, the provisioned namespace and storage are deleted.

Installation

$ docker run --name="webkubectl" -p 8080:8080 -d --privileged kubeoperator/webkubectl

Advanced environment variables

ENVTypeDefault ValueDescription
SESSION_STORAGE_SIZEstring10MStorage size limit for single connection
KUBECTL_INSECURE_SKIP_TLS_VERIFYbooltrueWhether to skip tls verify
GOTTY_OPTIONSstring--port 8080 --permit-write --permit-argumentsGotty options, see more
WELCOME_BANNERstringWelcome to Web Kubectl, try kubectl --help.Welcome banner after web terminal opened

Usage

Use index page

Open below url in web browser.

http://<webkubectl-address>:<port>

In the opened page you can manage your own kubeconfig files or bearer tokens which are stored in local storage, then choose a session and click connect to use kubectl command in web terminal.

index

terminal

Use API

Get token by Kubernetes API server address and bearer token

$ curl http://<webkubectl-address>:<port>/api/kube-token -X POST -d '{"name":"gks-hk-dev","apiServer":"https://k8s-cluster:6443","token":"token-content"}'
#response
$ {"success":true,"token":"mkolj4hgbutfgy1thgp1","message":""}

Request Json <br>

keyTypeDescription
namestringsession name
apiServerstringAPI server address
tokenstringKubernetes bearer token

Response Json <br>

keyTypeDescription
successboolthe request is proceeded successfully or not
tokenstringtoken used to open terminal
messagestringerror message if success is false

Get token by kubeconfig file

$ curl http://<webkubectl-address>:<port>/api/kube-config -X POST -d '{"name":"k8s-cluster-bj1","kubeConfig":"<kubeconfig file content base64 encoded>"}'
#response
$ {"success":true,"token":"mkolj4hgbutfgy1thgp1","message":""}

Request Json <br>

keyTypeDescription
namestringsession name
kubeConfigstringkubeconfig file content base64 encoded

Response Json <br>

keyTypeDescription
successboolthe request is proceeded successfully or not
tokenstringtoken used to open terminal
messagestringerror message if success is false

Open web terminal with token fetched from API

http://<webkubectl-address>:<port>/terminal/?token=<token fetched from api>

Security

Extensions

Dependencies

License

Copyright (c) 2014-2024 FIT2CLOUD 飞致云<br>

https://www.fit2cloud.com<br>

Web Kubectl is licensed under the Apache License, Version 2.0.


Alternatives

Advertisement

KubeOperator

KubeOperator is an open source project, a web based application enable you to deploy and manage production ready Kubernetes clusters on VMware, Openstack, virtual machines and physical machines in LAN network without internet connectivity.<br> https://kubeoperator.io<br> https://github.com/kubeoperator/kubeoperator