update etcdctl outpout with json
parent
82eed1effb
commit
0dc7acd897
|
@ -97,89 +97,35 @@ metadata:
|
||||||
ConfigMap中的内容是存储到etcd中的,然后查询etcd:
|
ConfigMap中的内容是存储到etcd中的,然后查询etcd:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ETCDCTL_API=3 etcdctl get /registry/configmaps/default/nginx-config
|
ETCDCTL_API=3 etcdctl get /registry/configmaps/default/nginx-config -w json|python -m json.tool
|
||||||
/registry/configmaps/default/nginx-config
|
|
||||||
```
|
```
|
||||||
|
|
||||||
注意使用 v3 版本的 etcdctl API,下面是输出结果:
|
注意使用 v3 版本的 etcdctl API,下面是输出结果:
|
||||||
|
|
||||||
```bash
|
```json
|
||||||
k8s
|
{
|
||||||
|
"count": 1,
|
||||||
v1 ConfigMap<61>
|
"header": {
|
||||||
|
"cluster_id": 12091028579527406772,
|
||||||
T
|
"member_id": 16557816780141026208,
|
||||||
|
"raft_term": 36,
|
||||||
nginx-configdefault"*$18d70527-7686-11e7-bfbd-8af1e3a7c5bd28B
|
"revision": 29258723
|
||||||
<20>ʀ<EFBFBD><CA80><EFBFBD><EFBFBD>xz<78>
|
},
|
||||||
|
"kvs": [
|
||||||
|
{
|
||||||
nginx.conf<6E>
|
"create_revision": 14925806,
|
||||||
worker_processes 1;
|
"key": "L3JlZ2lzdHJ5L2NvbmZpZ21hcHMvZGVmYXVsdC9uZ2lueC1jb25maWc=",
|
||||||
|
"mod_revision": 14925806,
|
||||||
events { worker_connections 1024; }
|
"value": "azhzAAoPCgJ2MRIJQ29uZmlnTWFwEqQMClQKDG5naW54LWNvbmZpZxIAGgdkZWZhdWx0IgAqJDE4ZDcwNTI3LTc2ODYtMTFlNy1iZmJkLThhZjFlM2E3YzViZDIAOABCCwjdyoDMBRC5ss54egASywsKCm5naW54LmNvbmYSvAt3b3JrZXJfcHJvY2Vzc2VzIDE7CgpldmVudHMgeyB3b3JrZXJfY29ubmVjdGlvbnMgMTAyNDsgfQoKaHR0cCB7CiAgICBzZW5kZmlsZSBvbjsKCiAgICBzZXJ2ZXIgewogICAgICAgIGxpc3RlbiA4MDsKCiAgICAgICAgIyBhIHRlc3QgZW5kcG9pbnQgdGhhdCByZXR1cm5zIGh0dHAgMjAwcwogICAgICAgIGxvY2F0aW9uIC8gewogICAgICAgICAgICBwcm94eV9wYXNzIGh0dHA6Ly9odHRwc3RhdC51cy8yMDA7CiAgICAgICAgICAgIHByb3h5X3NldF9oZWFkZXIgIFgtUmVhbC1JUCAgJHJlbW90ZV9hZGRyOwogICAgICAgIH0KICAgIH0KCiAgICBzZXJ2ZXIgewoKICAgICAgICBsaXN0ZW4gODA7CiAgICAgICAgc2VydmVyX25hbWUgYXBpLmhlbGxvLndvcmxkOwoKICAgICAgICBsb2NhdGlvbiAvIHsKICAgICAgICAgICAgcHJveHlfcGFzcyBodHRwOi8vbDVkLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWw7CiAgICAgICAgICAgIHByb3h5X3NldF9oZWFkZXIgSG9zdCAkaG9zdDsKICAgICAgICAgICAgcHJveHlfc2V0X2hlYWRlciBDb25uZWN0aW9uICIiOwogICAgICAgICAgICBwcm94eV9odHRwX3ZlcnNpb24gMS4xOwoKICAgICAgICAgICAgbW9yZV9jbGVhcl9pbnB1dF9oZWFkZXJzICdsNWQtY3R4LSonICdsNWQtZHRhYicgJ2w1ZC1zYW1wbGUnOwogICAgICAgIH0KICAgIH0KCiAgICBzZXJ2ZXIgewoKICAgICAgICBsaXN0ZW4gODA7CiAgICAgICAgc2VydmVyX25hbWUgd3d3LmhlbGxvLndvcmxkOwoKICAgICAgICBsb2NhdGlvbiAvIHsKCgogICAgICAgICAgICAjIGFsbG93ICdlbXBsb3llZXMnIHRvIHBlcmZvcm0gZHRhYiBvdmVycmlkZXMKICAgICAgICAgICAgaWYgKCRjb29raWVfc3BlY2lhbF9lbXBsb3llZV9jb29raWUgIT0gImxldG1laW4iKSB7CiAgICAgICAgICAgICAgbW9yZV9jbGVhcl9pbnB1dF9oZWFkZXJzICdsNWQtY3R4LSonICdsNWQtZHRhYicgJ2w1ZC1zYW1wbGUnOwogICAgICAgICAgICB9CgogICAgICAgICAgICAjIGFkZCBhIGR0YWIgb3ZlcnJpZGUgdG8gZ2V0IHBlb3BsZSB0byBvdXIgYmV0YSwgd29ybGQtdjIKICAgICAgICAgICAgc2V0ICR4aGVhZGVyICIiOwoKICAgICAgICAgICAgaWYgKCRjb29raWVfc3BlY2lhbF9lbXBsb3llZV9jb29raWUgfiogImRvZ2Zvb2QiKSB7CiAgICAgICAgICAgICAgc2V0ICR4aGVhZGVyICIvaG9zdC93b3JsZCA9PiAvc3J2L3dvcmxkLXYyOyI7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHByb3h5X3NldF9oZWFkZXIgJ2w1ZC1kdGFiJyAkeGhlYWRlcjsKCgogICAgICAgICAgICBwcm94eV9wYXNzIGh0dHA6Ly9sNWQuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDsKICAgICAgICAgICAgcHJveHlfc2V0X2hlYWRlciBIb3N0ICRob3N0OwogICAgICAgICAgICBwcm94eV9zZXRfaGVhZGVyIENvbm5lY3Rpb24gIiI7CiAgICAgICAgICAgIHByb3h5X2h0dHBfdmVyc2lvbiAxLjE7CiAgICAgICAgfQogICAgfQp9GgAiAA==",
|
||||||
|
"version": 1
|
||||||
http {
|
|
||||||
sendfile on;
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
|
|
||||||
# a test endpoint that returns http 200s
|
|
||||||
location / {
|
|
||||||
proxy_pass http://httpstat.us/200;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
|
}
|
||||||
server {
|
|
||||||
|
|
||||||
listen 80;
|
|
||||||
server_name api.hello.world;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://l5d.default.svc.cluster.local;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header Connection "";
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
|
|
||||||
more_clear_input_headers 'l5d-ctx-*' 'l5d-dtab' 'l5d-sample';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
|
|
||||||
listen 80;
|
|
||||||
server_name www.hello.world;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
|
|
||||||
|
|
||||||
# allow 'employees' to perform dtab overrides
|
|
||||||
if ($cookie_special_employee_cookie != "letmein") {
|
|
||||||
more_clear_input_headers 'l5d-ctx-*' 'l5d-dtab' 'l5d-sample';
|
|
||||||
}
|
|
||||||
|
|
||||||
# add a dtab override to get people to our beta, world-v2
|
|
||||||
set $xheader "";
|
|
||||||
|
|
||||||
if ($cookie_special_employee_cookie ~* "dogfood") {
|
|
||||||
set $xheader "/host/world => /srv/world-v2;";
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy_set_header 'l5d-dtab' $xheader;
|
|
||||||
|
|
||||||
|
|
||||||
proxy_pass http://l5d.default.svc.cluster.local;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header Connection "";
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
输出中在 `nginx.conf` 配置文件的基础中增加了文件头内容,是kubernetes增加的。
|
其中的value就是 `nginx.conf` 配置文件的内容。
|
||||||
|
|
||||||
|
可以使用base64解码查看具体值,关于etcdctl的使用请参考[使用etcdctl访问kuberentes数据](../guide/using-etcdctl-to-access-kubernetes-data.md)。
|
||||||
|
|
||||||
## 代码
|
## 代码
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue