自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

GoTTY - 終端工具變?yōu)?Web 應(yīng)用

運維 系統(tǒng)運維
GoTTY 是一個簡單的命令行工具,可將您的 CLI 工具變成 Web 應(yīng)用。

 GoTTY 是一個簡單的命令行工具,可將您的 CLI 工具變成 Web 應(yīng)用。

[[400135]]

快速入門

1、安裝 GoTTY 

  1. # Mac 版  
  2. brew install yudai/gotty/gotty 

如果你有 GO 的環(huán)境,也可以通過如下方式安裝: 

  1. go get github.com/yudai/gotty 

2、GoTTY 用法

  1. Usage: gotty [options] <command> [<arguments...>
  •  options 
  1. --address value, -a value     IP address to listen (default: "0.0.0.0") [$GOTTY_ADDRESS]  
  2. --port value, -p value        Port number to liten (default: "8080") [$GOTTY_PORT]  
  3. --permit-write, -w            Permit clients to write to the TTY (BE CAREFUL) [$GOTTY_PERMIT_WRITE]  
  4. --credential value, -c value  Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]  
  5. --random-url, -r              Add a random string to the URL [$GOTTY_RANDOM_URL]  
  6. --random-url-length value     Random URL length (default: 8) [$GOTTY_RANDOM_URL_LENGTH]  
  7. --tls, -t                     Enable TLS/SSL [$GOTTY_TLS]  
  8. --tls-crt value               TLS/SSL certificate file path (default: "~/.gotty.crt") [$GOTTY_TLS_CRT]  
  9. --tls-key value               TLS/SSL key file path (default: "~/.gotty.key") [$GOTTY_TLS_KEY]  
  10. --tls-ca-crt value            TLS/SSL CA certificate file for client certifications (default: "~/.gotty.ca.crt") [$GOTTY_TLS_CA_CRT]  
  11. --index value                 Custom index.html file [$GOTTY_INDEX]  
  12. --title-format value          Title format of browser window (default: "{{ .command }}@{{ .hostname }}") [$GOTTY_TITLE_FORMAT]  
  13. --reconnect                   Enable reconnection [$GOTTY_RECONNECT]  
  14. --reconnect-time value        Time to reconnect (default: 10) [$GOTTY_RECONNECT_TIME]  
  15. --max-connection value        Maximum connection to gotty (default: 0) [$GOTTY_MAX_CONNECTION]  
  16. --once                        Accept only one client and exit on disconnection [$GOTTY_ONCE]  
  17. --timeout value               Timeout seconds for waiting a client(0 to disable) (default: 0) [$GOTTY_TIMEOUT]  
  18. --permit-arguments            Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) [$GOTTY_PERMIT_ARGUMENTS]  
  19. --width value                 Static width of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_WIDTH]  
  20. --height value                Static height of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_HEIGHT]  
  21. --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] 
  22. --term value                  Terminal name to use on the browser, one of xterm or hterm. (default: "xterm") [$GOTTY_TERM] 
  23. --close-signal value          Signal sent to the command process when gotty close it (default: SIGHUP) (default: 1) [$GOTTY_CLOSE_SIGNAL] 
  24. --close-timeout value         Time in seconds to force kill process after client is disconnected (default: -1) (default: -1) [$GOTTY_CLOSE_TIMEOUT] 
  25. --config value                Config file path (default: "~/.gotty") [$GOTTY_CONFIG] 
  26. --version, -v                 print the version 

 3、實踐 

  1. # 示例  
  2. gotty -w python3 

訪問 http://127.0.0.1:8080 即可在線體驗 Python3 環(huán)境。

進階篇

容器化時代,遇到一些問題的時候,會進入容器內(nèi)部排查問題,依靠命令行確實可以解決,但是效率較低,如果將容器作為 Web 可訪問的應(yīng)用,那么處理問題就會便捷很多。

下面將介紹如何使用 GoTTY 連接 k8s 集群中的任意容器。

1、構(gòu)建 GoTTY Docker 鏡像

已構(gòu)建好的鏡像:registry.cn-beijing.aliyuncs.com/tlab/k8s-gotty:latest

  •  gotty:可運行的 gotty 程序,查看 [Releases]列表,選擇合適的
  •  kubernetes.repo:用于下載 kubectl 
  1. [kubernetes]  
  2. name=Kubernetes  
  3. baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/  
  4. enabled=1  
  5. gpgcheck=1  
  6. repo_gpgcheck=1  
  7. gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg 
  •  Dockerfile:用于構(gòu)建鏡像 
  1. FROM centos:latest  
  2. RUN yum install -y epel-release kde-l10n-Chinese glibc-common wget  
  3. RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8  
  4. ENV LC_ALL zh_CN.utf8  
  5. ADD gotty /root/  
  6. ADD kubernetes.repo /etc/yum.repos.d/  
  7. RUN yum -y install kubectl  
  8. WORKDIR /root  
  9. EXPOSE 8080  
  10. CMD ["./gotty", "-w", "--permit-arguments", "kubectl", "exec", "-it", "-n"] 

2、在 k8s 集群中運行 GoTTY 

  1. kind: Deployment  
  2. apiVersion: apps/v1  
  3. metadata:  
  4.   name: gotty  
  5.   namespace: default  
  6. spec:  
  7.   replicas: 1  
  8.   selector:  
  9.     matchLabels:  
  10.       k8s-app: gotty  
  11.   template:  
  12.     metadata:  
  13.       labels:  
  14.         k8s-app: gotty  
  15.     spec:  
  16.       serviceAccountName: <此處填具有合適權(quán)限的k8s用戶名>  
  17.       containers:  
  18.         - name: gotty  
  19.           image: registry.cn-beijing.aliyuncs.com/tlab/k8s-gotty  
  20.           ports:  
  21.             - containerPort: 8080  
  22.               protocol: TCP 

3、暴露 GoTTY 服務(wù) 

  1. kind: Service  
  2. apiVersion: v1  
  3. metadata:  
  4.   labels:  
  5.     k8s-app: gotty  
  6.   name: gotty-service  
  7.   namespace: default  
  8. spec:  
  9.   ports:  
  10.     - port: 80  
  11.       targetPort: 8080  
  12.       nodePort: 38080  
  13.   selector:  
  14.     k8s-app: gotty  
  15.   type: NodePort 

4、訪問容器

在終端里,進入容器的命令是:

  1. kubectl exec -it -n <Namespace> <PodName> 

那么,利用 GoTTY 訪問則是 http://<ip>:38080/?arg=<Namespace>&arg=<PodName> 

 

責(zé)任編輯:龐桂玉 來源: 運維派
相關(guān)推薦

2011-12-29 11:13:58

移動Web應(yīng)用程序標(biāo)準(zhǔn)

2010-05-06 10:08:21

2009-08-27 11:40:43

ibmdw云計算

2011-03-25 11:06:46

2014-05-22 10:03:29

2011-08-29 15:00:54

APC數(shù)據(jù)中心

2021-05-10 09:00:00

Web工具安全

2014-07-11 09:24:56

終端調(diào)試AngularJS

2014-06-18 10:47:05

dstat監(jiān)控工具

2011-03-25 11:18:51

2021-03-02 08:49:53

tmuxLinux命令

2010-05-28 14:23:00

ibmdwWeb

2013-11-22 11:03:45

GoogleWeb開發(fā)工具

2011-07-18 12:56:10

Web開發(fā)

2020-05-19 12:24:01

Web應(yīng)用安全測試工具開源

2024-01-05 12:03:37

終端工具?tmux

2009-12-21 09:54:54

Web應(yīng)用程序安全測試

2021-08-05 13:20:46

Python工具工具

2021-04-01 10:22:42

工具Linux文件

2021-11-16 14:55:50

命令行Linux開源
點贊
收藏

51CTO技術(shù)棧公眾號