go-dockerclient是一个GO语言写的docker客户端,支持Docker remote API,这个项目在https://github.com/fsouza/go-dockerclient中。
go-dockerclient使用两种方式同dockerdaemon通讯,第一种方式是通过/var/run/docker.sock,第二种方式是通过TLS。使用第一种方式时,需要有读写/var/run/docker.sock的权限,使用第二种方式时需要有认证文件。
在Kubenetes1.2中要求Docker Remote API版本至少是1.18。
go-dockerclient中使用到的Docker remote API和kubernetes1.2中使用到的Docker remote API:
Docker Remote API 1.22 | 使用方式 | Go-dockerclient | Kubernetes1.2 |
Get container stats based on resource usage | GET /containers/(id)/stats | ||
Update a container | POST /containers/(id)/update | ||
Rename a container | POST /containers/(id)/rename | ||
Retrieving information about files and folders in a container | HEAD /containers/(id)/archive | ||
List containers | GET /containers/json | √ | √ |
Inspect a container | GET /containers/(id)/json | √ | √ |
Inspect changes on a container’s filesystem | GET /containers/(id)/changes | √ | √ |
Create a container | POST /containers/create | √ | √ |
Start a container | POST /containers/(id)/start | √ | √ |
Stop a container | POST /containers/(id)/stop | √ | √ |
Restart a container | POST /containers/(id)/restart | √ | |
Pause a container | POST /containers/(id)/pause | √ | |
Unpause a container | POST /containers/(id)/unpause | √ | |
List processes running inside a container | GET /containers/(id)/top | √ | |
Kill a container | POST /containers/(id)/kill | √ | √ |
Remove a container | DELETE /containers/(id) | √ | √ |
Get an archive of a filesystem resource in a container | GET /containers/(id)/archive | √ | |
Extract an archive of files or folders to a directory in a container | PUT /containers/(id)/archive | √ | |
Copy files or folders from a container | POST /containers/(id)/copy,以后会被删除掉,使用archive代替 | √ | |
Wait a container | POST /containers/(id)/wait | √ | |
Create a new image from a container’s changes | POST /commit | √ | |
Attach to a container | POST /containers/(id)/attach | √ | √ |
Get container logs | GET /containers/(id)/logs | √ | √ |
Resize a container TTY | POST /containers/(id)/resize | √ | |
Export a container | GET /containers/(id)/export | √ | |
List Images | GET /images/json | √ | √ |
Inspect an image | GET /images/(name)/json | √ | √ |
Get the history of an image | GET /images/(name)/history | √ | |
Push an image on the registry | POST /images/(name)/push | √ | |
Build image from a Dockerfile | POST /build | √ | |
Create an image | POST /images/create | √ | √ |
Load a tarball with a set of images and tags into docker | POST /images/load | √ | |
Get a tarball containing all images in a repository | GET /images/(name)/get | √ | |
Tag an image into a repository | POST /images/(name)/tag | √ | |
Remove an image | DELETE /images/(name) | √ | √ |
Search images | GET /images/search | √ | |
Monitor Docker’s events | GET /events | ||
Show the docker version information | GET /version | √ | √ |
Display system-wide information | GET /info | √ | √ |
Ping the docker server | GET /_ping | ||
List volumes | GET /volumes | √ | |
Create a volume | POST /volumes/create | √ | |
Inspect a volume | GET /volumes/(name) | √ | |
Remove a volume | DELETE /volumes/(name) | √ | |
List networks | GET /networks | √ | |
Inspect network | GET /networks/<network-id> | √ | |
Create a network | POST /networks/create | √ | |
Remove a network | DELETE /networks/(id) | √ | |
Connect a container to a network | POST /networks/(id)/connect | √ | |
Disconnect a container from a network | POST /networks/(id)/disconnect | √ | |
Check auth configuration | POST /auth | √ | |
Exec Create | POST /containers/(id)/exec | √ | √ |
Exec Start | POST /exec/(id)/start | √ | √ |
Exec Resize | POST /exec/(id)/resize | √ | |
Exec Inspect | GET /exec/(id)/json | √ | √ |
下面是DockerDaemon版本同Docker Remote API版本对应关系:
Docker Daemon版本 | Docker Remote API版本 |
1.10.x | 1.22 |
1.9.x | 1.21 |
1.8.x | 1.2 |
1.7.x | 1.19 |
1.6.x | 1.18 |
1.5.x | 1.17 |
1.4.x | 1.16 |
1.3.x | 1.15 |
1.2.x | 1.14 |
kubernetes1.2源代码中引用的etcd版本是2.2.5,这个版本的etcd集群中支持的最低版本是2.1.0。kubernetes1.2源代码中引用etcd的目的是使用etcd的client,所以对etcd server端版本的选择影响不大。
项目位置:https://github.com/coreos/etcd
kubernetes1.2源代码中引用的cAdvisor版本是0.22.0,cAdvisor是用来采集容器资源使用和性能数据,在NODE节点上默认使用4194端口。
项目位置:https://github.com/google/cadvisor
kubernetes1.2源代码中引用的是Prometheus客户端源代码,用来定义kubernetes自身的监控项,比如etcd缓存命中数、etcd缓存入口访问数、从etcd查询数据总延迟、向etcd创建数据总延迟,等等,利用Prometheus客户端源代码还可以用来让使用者自定义POD中监控项,目前kubernetes1.2中只能以prometheus API的形式来自定义监控项,并且一个POD中最多只能自定义5个监控项,prometheus API是一个web services接口。
自定义POD中监控项写入文件/etc/custom-metrics/definition.json,然后在创建容器的时候挂载到容器中。
项目位置:https://github.com/prometheus/client_golang
kubernetes1.2源代码中引用的是heapster客户端源代码,Heapster通过NODE节点上默认10255端口采集监控项信息,当kubernetes使用到HorizontalController的时候,会建立heapster客户端,由客户端来向heapster服务端发请求,收集历史监控数据。
项目位置:https://github.com/kubernetes/heapster