Giter Club home page Giter Club logo

k8s-webshell's Introduction

k8s-webshell

k8s-webshell 能做什么

用户可以再web页面上直接登录k8s内部容器, 执行shell命令.

示例如下:

k8s-webshell

build

  • compile k8s-webshell (要求本地有make):

    ### 如果需要指定linux版本,加参数 `make linux`
    # make 
  • build 镜像():

    # make docker 

部署方式有2种:

  • kubernetes 部署(k8s 集群内 incluster 模式)到集群当中

  • docker-compose 部署(k8s集群外部署)

kubernetes 部署 k8s-webshell

进入到doc/deploy/k8s 下面依次执行: (注意 根据自己的pod部署的命名空间修改里面的namespace字段)

# kubectl apply -f k8s-webshell-sa.yaml
# kubectl apply -f k8s-webshell-clusterrole.yaml
# kubectl apply -f k8s-webshell-secret.yaml 
# kubectl apply -f k8s-webshell-clusterrolebinding.yaml
# kubectl apply -f k8s-webshell-deployment.yaml
# kubectl apply -f k8s-webshell-svc.yaml

修改doc/demo/client/index.html 中的以下内容的ip修改为容器的为域名(ssl证书为xx.com):

ws = new WebSocket("wss://xx.com:30001/api/ws?" + "token=" + wsToken);

然后打开index.html 就可以测试了

docker-compose 部署

在项目根目录下执行:

docker-compose -f docker-compose.yaml up -d k8s-webshell 

接口使用

调用/auth(POST方法)先获取token,参数如下:

{
	"secretKey":"xxxxx", 
	"paasUser":"zhuruiqing",
	"podNs":"richie",
	"podName":"my-nginx-xxx6-jtr5k",
	"containerName":"my-nginx"
	
}

参数说明:

secretKey  api认证secretKey
paasUser   paas平台用户
podNs      pod命名空间
podName    pod名称
containerName 容器名称

web页面调用k8s-webshell websocket接口

调用接口/api/ws其中token为 请求auth后获得的token: ws = new WebSocket("wss://xx.com:30001/api/ws?" + "token=" + wsToken);

k8s-webshell's People

Contributors

lmdkfs avatar

Stargazers

 avatar  avatar thinkeng avatar Li Jiayu avatar enhao.liu avatar changqing_shen avatar  avatar  avatar Keven Fesperman avatar Andrey Kuznetsov avatar baiqidong avatar Sun Wei avatar Brian Seong avatar I'm a villager of chaoyue.yang avatar wangyufan avatar tianchi avatar Poverty avatar Jian Bo avatar

Watchers

James Cloos avatar  avatar

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.