k8s - WEB终端(gotty)

简介: 搭建K8S私有云之后,我们需要在私有云上提供一种能力,让研发可以直接登录容器,参看容器或者应用程序当前的状态。研发人员不可直接登录宿主主机,登录宿主主机属于危险操作。 WEB终端的话,推荐使用gotty: github 地址: https://github.

搭建K8S私有云之后,我们需要在私有云上提供一种能力,让研发可以直接登录 容器,参看容器或者应用程序当前的状态。研发人员不可直接登录宿主主机,登录宿主主机属于危险操作。

WEB终端的话,推荐使用gotty: github 地址: https://github.com/yudai/gotty

一、环境说明:

centos7

K8S: 1.8

gotty:1.0.1

二、gotty参数说明 :

--address value, -a value IP address to listen (default: "0.0.0.0") [$GOTTY_ADDRESS]

--port value, -p value Port number to liten (default: "8080") [$GOTTY_PORT]

--permit-write, -w Permit clients to write to the TTY (BE CAREFUL) [$GOTTY_PERMIT_WRITE]

--credential value, -c value Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]

--random-url, -r Add a random string to the URL [$GOTTY_RANDOM_URL]

--random-url-length value Random URL length (default: 8) [$GOTTY_RANDOM_URL_LENGTH]

--tls, -t Enable TLS/SSL [$GOTTY_TLS]

--tls-crt value TLS/SSL certificate file path (default: "~/.gotty.crt") [$GOTTY_TLS_CRT]

--tls-key value TLS/SSL key file path (default: "~/.gotty.key") [$GOTTY_TLS_KEY]

--tls-ca-crt value TLS/SSL CA certificate file for client certifications (default: "~/.gotty.ca.crt") [$GOTTY_TLS_CA_CRT]

--index value Custom index.html file [$GOTTY_INDEX]

--title-format value Title format of browser window (default: "{{ .command }}@{{ .hostname }}") [$GOTTY_TITLE_FORMAT]

--reconnect Enable reconnection [$GOTTY_RECONNECT]

--reconnect-time value Time to reconnect (default: 10) [$GOTTY_RECONNECT_TIME]

--max-connection value Maximum connection to gotty (default: 0) [$GOTTY_MAX_CONNECTION]

--once Accept only one client and exit on disconnection [$GOTTY_ONCE]

--timeout value Timeout seconds for waiting a client(0 to disable) (default: 0) [$GOTTY_TIMEOUT]

--permit-arguments Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) [$GOTTY_PERMIT_ARGUMENTS]

--width value Static width of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_WIDTH]

--height value Static height of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_HEIGHT]

--ws-origin value A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default [$GOTTY_WS_ORIGIN]

--term value Terminal name to use on the browser, one of xterm or hterm. (default: "xterm") [$GOTTY_TERM]

--close-signal value Signal sent to the command process when gotty close it (default: SIGHUP) (default: 1) [$GOTTY_CLOSE_SIGNAL]

--close-timeout value Time in seconds to force kill process after client is disconnected (default: -1) (default: -1) [$GOTTY_CLOSE_TIMEOUT]

--config value Config file path (default: "~/.gotty") [$GOTTY_CONFIG]

--version, -v print the version

三、启动gotty :

./gotty -w --permit-arguments docker exec -ti

或者 ./gotty -w -p 8081 --permit-arguments kubectl exec -ti &

浏览器直接传入容器的ID和进入容器需要执行的命令(/bin/bash)

http://172.172.241.180:8080/?arg=6f&arg=%2fbin%2fbash

e803eec6ace4b3f64abd384a007a15460a62e382

其他:使用浏览器频繁进入容器之后,容器内部会产生大量/bin/bash进程,这个需要注意一下,一般是不推荐直接进入容器的。

本文转自CSDN-k8s - WEB终端(gotty)

相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
云原生实践公开课
课程大纲 开篇:如何学习并实践云原生技术 基础篇: 5 步上手 Kubernetes 进阶篇:生产环境下的 K8s 实践 相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
相关文章
|
2月前
|
Kubernetes 应用服务中间件 nginx
K8S Pod Sidecar 应用场景之一 - 加入 NGINX Sidecar 做反代和 web 服务器
K8S Pod Sidecar 应用场景之一 - 加入 NGINX Sidecar 做反代和 web 服务器
|
2月前
|
Kubernetes 监控 Shell
K8S 实用工具之二 - 终端 UI K9S
K8S 实用工具之二 - 终端 UI K9S
|
7月前
|
弹性计算 Kubernetes 索引
使用Kubectl部署web服务到K8s集群
本场景带您体验如何使用k8s的原生命令kubectl部署一个web应用(魔方应用)的镜像到k8s集群中,并通过Ingress将部署的服务暴露出来由外部访问。
5692 2
|
8月前
|
弹性计算 Kubernetes 容器
使用Kubectl部署web服务到K8s集群
本次基于阿里云实验室提供的实验环境,使用预创建好的创建云服务器ECS和ACK集群资源,实现通过Kubectl部署web服务到K8s集群。
|
10月前
|
Linux Go C语言
嵌入式linux之go语言开发(十一)让web服务器跑在终端上,通过网页配置终端参数
嵌入式linux之go语言开发(十一)让web服务器跑在终端上,通过网页配置终端参数
|
弹性计算 Kubernetes Cloud Native
容器实验班开课!30 分钟学会使用 Kubectl 部署 web 服务到 K8s 集群
容器实验班开课!30 分钟学会使用 Kubectl 部署 web 服务到 K8s 集群
容器实验班开课!30 分钟学会使用 Kubectl 部署 web 服务到 K8s 集群
|
Kubernetes 容器 Perl
使用Kubectl部署web服务到K8s集群-4
使用Kubectl部署web服务到K8s集群-4
134 0
|
弹性计算 Kubernetes 容器
使用Kubectl部署web服务到K8s集群-3
使用Kubectl部署web服务到K8s集群-3
198 0
使用Kubectl部署web服务到K8s集群-3
|
弹性计算 Kubernetes 容器
使用Kubectl部署web服务到K8s集群-2
使用Kubectl部署web服务到K8s集群-2
181 0
使用Kubectl部署web服务到K8s集群-2
|
20天前
|
监控 JavaScript 前端开发
《理解 WebSocket:Java Web 开发的实时通信技术》
【4月更文挑战第4天】WebSocket是Java Web实时通信的关键技术,提供双向持久连接,实现低延迟、高效率的实时交互。适用于聊天应用、在线游戏、数据监控和即时通知。开发涉及服务器端实现、客户端连接及数据协议定义,注意安全、错误处理、性能和兼容性。随着实时应用需求增加,WebSocket在Java Web开发中的地位将更加重要。

推荐镜像

更多