|
1 | | -# Dockin Ops - Dockin Operation service |
| 1 | +# Dockin Ops-Dockin Operation service |
2 | 2 |
|
3 | 3 | [](https://www.apache.org/licenses/LICENSE-2.0.html) |
4 | 4 |
|
5 | | -English | [中文](README.zh-CN.md) |
| 5 | +English| [Chinese](README.zh-CN.md) |
6 | 6 |
|
7 | | -Dockin operation and maintenance management system is a safe operation and maintenance management service that optimizes exec execution performance and supports command authority management |
| 7 | +Dockin operation and maintenance management system is a safe operation and maintenance management service that optimizes exec execution performance, supports command authority management, and supports scene operation and maintenance orchestration. |
8 | 8 |
|
9 | | -**For more Dockin components, please visit [https://github.com/WeBankFinTech/Dockin](https://github.com/WeBankFinTech/Dockin)** |
| 9 | +**For more Docking components, please visit [https://github.com/WeBankFinTech/Dockin](https://github.com/WeBankFinTech/Dockin)** |
10 | 10 |
|
11 | 11 |  |
12 | 12 |
|
13 | | -## Demo Show |
14 | | - |
15 | | -### Exec |
16 | | - |
| 13 | +## Component introduction |
| 14 | +### Dockin-Opserver |
| 15 | +dockin-opserver is an apiserver interface agent developed based on kubernetes client-go, which supports the following basic functions: |
| 16 | +- Multi-cluster management, can manage multiple sets of apiserver clusters at the same time |
| 17 | +- User account information management. There is no account management when the Pod itself is accessed. Therefore, as long as you have kubeconfig, you can access all Pods. For cross-departmental situations, there are security risks |
| 18 | +- ssh proxy, after logging in to Pod through kubectl exec /bin/bash -it, users can operate any command, but due to the characteristics of kubernetes, there is strict control over memory, so some memory-consuming operations, such as vi Very large files can easily cause Pod to be OOM kill. Through ssh proxy, we can intercept all commands executed by users and perform security judgments (black and white lists). |
| 19 | +- Audit. Any command can be executed through kubectl exec. How can the user execute which command causes a security risk. Through the audit function, we will check all the commands executed by the user, whether it is exec or in the shell environment. Corresponding archives can be traced. |
| 20 | +- Provide http and websocket interfaces for executing ordinary exec and interactive exec requests |
| 21 | +- Protocol conversion, convert websocket and spdy protocol data to each other |
| 22 | +-Save the time of Add, Update, and Delete of pod to redis through the informer function of client-go |
| 23 | + |
| 24 | +### Dockin-Opsctl |
| 25 | +Similar to kubectl client, binary client, user and dockin-opserver establish http or websocket request, bind current standard input and standard input, enter raw mode in interactive mode |
| 26 | + |
| 27 | +### Dockin-Opagent |
| 28 | +The agent of dockin is deployed in each kubernetes node through daemonset, and it mainly has the following functions |
| 29 | +- Mount docker.sock to connect to dockerd |
| 30 | +- Integrate docker api for docker exec operation |
| 31 | +- Manage the correspondence between containerId and podName in the current node |
| 32 | +- Provide spdy interface to respond to exec requests initiated by dockin-opserver |
| 33 | +- Bind the input and output streams of docker api to the input and output streams of spdy |
| 34 | + |
| 35 | +### dockctl |
| 36 | +dockctl is a package of dockin-opsctl |
| 37 | +- dockctl provides batch operation of multiple Pods, in units of subsystems |
| 38 | +- Beautify output, dockin-opsctl returns standard output, mostly json data, dockctl will beautify the display of json data |
| 39 | + |
| 40 | +## List of open source functions |
| 41 | +- dockctl cmdb, limit Pod-related information based on the subsystem |
| 42 | +- exec proxy |
| 43 | +- ssh tool |
| 44 | + - Support intercepting ssh commands |
| 45 | + - Support command parameter interception |
| 46 | + - Support account management |
| 47 | +- Pod permission management |
| 48 | + |
| 49 | +## Roadmap |
| 50 | +- Shell content analysis optimization (based on escape characters, control characters) |
| 51 | +- File upload and download (kubectl cp without apiserver) |
| 52 | +- oom event capture |
| 53 | +- kubectl debug |
| 54 | + |
| 55 | +## Demo |
| 56 | +### SSH |
17 | 57 |  |
18 | | - |
19 | 58 | ### CMDB |
20 | | - |
21 | 59 |  |
22 | 60 |
|
23 | | -## Quick Guide |
24 | | - |
25 | | -### 1. Preparation |
26 | | -- k8s cluster |
27 | | -- Deploy Docking rm in advance, opserver needs to call rm interface to get information |
28 | | -- Prepare redis, you can quickly run redis with the following command: |
| 61 | +## third-party component |
| 62 | +- kubernetes cluster, offline installation can be achieved through dokin-installer, **dockin-installer: [https://github.com/WeBankFinTech/Dockin-installer](https://github.com/WeBankFinTech/Dockin-installer)* * |
| 63 | +- Deploy dokin-rm in advance, opserver needs to call the rm interface to obtain information, **dockin-rm [https://github.com/WeBankFinTech/Dockin-rm](https://github.com/WeBankFinTech/Dockin-rm) ** |
| 64 | +- Prepare redis. Redis stores a black and white list of some shell commands. The pod change information pushed by the apiserver through the informer can be quickly run through the following commands: |
29 | 65 | ``` |
30 | 66 | docker run -p 6379:6379 -d redis:latest redis-server |
31 | | -``` |
32 | | -- Plan to deploy opserver server, record the ip |
33 | | - |
34 | | -### 2. Compile |
35 | | - |
36 | | -#### 2.1 Dockin-opserver |
37 | | -- Modify the configuration file application.yaml, the main thing to note is the address of rm |
38 | | - |
39 | | -``` |
40 | | -rm-address: http://127.0.0.1:10002/rmController # RM access address |
41 | | -batch-timeout: 5000 |
42 | | -http-port: 8084 # listening port of opserver |
43 | | -cmd-filter-type: blacklist |
44 | | -while-list-update-time: 60000 |
45 | | -limits: |
46 | | - exec-forbidden: |
47 | | - -vi |
48 | | - file-max-size: 1000 |
49 | | - upload-file-max-size: 500 |
50 | | - download-file-max-size: 4000 |
51 | | - vi-file-max-size: 10 |
52 | | - k8s-qos: 40 |
53 | | - k8s-burst: 60 |
54 | | -opagent-port: 8085 # listening port of opagent |
55 | | -redis: |
56 | | - expiration: 120000 |
57 | | -accounts: # User information of opserver, currently configured in the configuration file |
58 | | - -account: |
59 | | - user-name: app |
60 | | - passwd: passwd |
61 | | -``` |
62 | | - |
63 | | -- Compile: execute the following command |
64 | | - |
65 | | -``` |
66 | | -make |
67 | | -``` |
68 | | - |
69 | | -#### 2.2 Dockin-opsctl |
70 | | -- Modify opserver access address |
71 | | -``` |
72 | | -# File to be modified: internal/common/url.go, change the constant RemoteHost to the ip and port corresponding to opserver |
73 | | -const RemoteHost = "127.0.0.1:8084" |
74 | | -``` |
75 | | -- Compile: execute the make command |
76 | | -``` |
77 | | -make |
78 | | -``` |
79 | | - |
80 | | - |
81 | | -#### 2.3 Dockin-opagent |
82 | | -- Modify the configuration file application.yaml, the access address of rm should be noted |
83 | | -``` |
84 | | -app: |
85 | | - rm: |
86 | | - api: http://127.0.0.1:10002/rmController # RM access address |
87 | | - container: |
88 | | - ticker: 30 |
89 | | - http: |
90 | | - port: 8085 |
91 | | - debug: |
92 | | - port: 10102 |
93 | | - ims: |
94 | | - logroot: /data/logs/ |
95 | | - docker: |
96 | | - sock: unix:///var/run/docker.sock |
97 | | - qos: |
98 | | - path: /data/cgroup |
99 | | - logs: |
100 | | - cmd-white-list: |
101 | | - -grep |
102 | | - -zgrep |
103 | | - -cat |
104 | | - -head |
105 | | - -tail |
106 | | - -awk |
107 | | - -uniq |
108 | | - -sort |
109 | | - -ls |
110 | | - cmd-timeout: 5000 |
111 | | - max-file-size: 3000 |
112 | | - max-line: 1000 |
113 | | - root: /data/logs/ |
114 | | -
|
115 | | -``` |
116 | | -- Compile and package opagent to docker image |
117 | | -``` |
118 | | -make docker-build |
119 | | -``` |
120 | | - |
121 | | - |
122 | | -### 3. Installation And Running |
123 | | - |
124 | | -#### 3.1 dockin-opagent |
125 | | -1. Opagent runs in the k8s cluster as a daemonSet. You can directly refer to the daemonSet sample in the internal/docs directory of the project, modify the corresponding mirror information and apply it directly to the k8s cluster. |
126 | | - |
127 | | -#### 3.2 dockin-opagent |
128 | | -1. Export the configuration file of the k8s cluster that needs to be managed, place it in the configs/cluster directory, and add a dockin section on the basis of the original configuration file. The example is shown below. Please see the corresponding notes for those who need attention: |
129 | | - |
130 | | -``` |
131 | | -apiVersion: v1 |
132 | | -clusters: |
133 | | --cluster: # The access address and name of the cluster can be declared multiple |
134 | | - insecure-skip-tls-verify: true |
135 | | - server: https://127.0.0.1:6443 |
136 | | - name: kubernetes |
137 | | -contexts: # Context information, mainly used to correspond to the above cluster information, set up some configurations |
138 | | --context: |
139 | | - cluster: kubernetes # cluster name, corresponding to the cluster name in the cluster section |
140 | | - namespace: test # Use the namespace of the configuration operation |
141 | | - user: kubernetes-readonly-user # The user used to access the cluster |
142 | | - name: readonly-user |
143 | | -current-context: readonly-user # Context used by default |
144 | | -kind: Config |
145 | | -preferences: {} |
146 | | -users: |
147 | | --name: kubernetes-readonly-user # User information, corresponding to the user in the context section |
148 | | - user: |
149 | | - password: your_password # User password |
150 | | - username: readonly-user # username |
151 | | -dockin: # Additional custom configuration, the user declares the rules applicable to the cluster and the corresponding cluster id, and declares the default whitelist |
152 | | - cluster-id: test |
153 | | - rule: test |
154 | | - whitelist: |
155 | | - -127.0.0.1 |
156 | | -``` |
157 | | -2. Upload the *start.sh*, *configs* directories and compiled executable files in the project to the server, and execute the following commands: |
158 | | -``` |
159 | | -sh start.sh |
160 | | -``` |
161 | | - |
162 | | - |
163 | | -#### 3.3 dockin-opsctl |
164 | | -- Copy the executable file to the server to use it, use the following command to view the help: |
165 | | -``` |
166 | | -dockin-opsctl -h |
167 | | -``` |
168 | | -Currently, dockin-opsctl already supports the dockin-opserver address compiled by the configuration file. The path of other configuration files is: `$HOME/.opserver.yaml`. At the same time, it also supports the use of `-c` or `--config` parameters to prepare configuration files. |
169 | | -The configuration file uses a yaml file, and currently there is only one configuration: |
170 | | -``` |
171 | | -Opserver: 127.0.0.1:8084 |
172 | | -``` |
| 67 | +``` |
0 commit comments