5.Etcd 解析
Etcd 解析
- 网络插件
flannel 、对于其它网络插件也需要用到etcd 存储网络的配置信息 Kubernetes 本身,包括各种对象的状态和元信息配置
注意:etcdctl
的时候需要设置 ETCDCTL_API
环境变量,该变量默认值为
原理
关于
使用Etcd 存储Flannel 网络信息
我们在安装FLANNEL_ETCD_PREFIX="/kube-centos/network"
参数,这是
查看
$ etcdctl --ca-file=/etc/kubernetes/ssl/ca.pem --cert-file=/etc/kubernetes/ssl/kubernetes.pem --key-file=/etc/kubernetes/ssl/kubernetes-key.pem ls /kube-centos/network -r
2018-01-19 18:38:22.768145 I | warning: ignoring ServerName for user-provided CA for backwards compatibility is deprecated
/kube-centos/network/config
/kube-centos/network/subnets
/kube-centos/network/subnets/172.30.31.0-24
/kube-centos/network/subnets/172.30.20.0-24
/kube-centos/network/subnets/172.30.23.0-24
```查看 flannel 的配置:```bash
$ etcdctl --ca-file=/etc/kubernetes/ssl/ca.pem --cert-file=/etc/kubernetes/ssl/kubernetes.pem --key-file=/etc/kubernetes/ssl/kubernetes-key.pem get /kube-centos/network/config
2018-01-19 18:38:22.768145 I | warning: ignoring ServerName for user-provided CA for backwards compatibility is deprecated
{"Network": "172.30.0.0/16", "SubnetLen": 24, "Backend": { "Type": "host-gw"} }
使用Etcd 存储Kubernetes 对象信息
/registry
路径下,如下:
ThirdPartyResourceData
apiextensions.k8s.io
apiregistration.k8s.io
certificatesigningrequests
clusterrolebindings
clusterroles
configmaps
controllerrevisions
controllers
daemonsets
deployments
events
horizontalpodautoscalers
ingress
limitranges
minions
monitoring.coreos.com
namespaces
persistentvolumeclaims
persistentvolumes
poddisruptionbudgets
pods
ranges
replicasets
resourcequotas
rolebindings
roles
secrets
serviceaccounts
services
statefulsets
storageclasses
thirdpartyresources
如果你还创建了
查看集群中所有的Pod 信息
例如我们直接从
ETCDCTL_API=3 etcdctl get /registry/pods --prefix -w json|python -m json.tool
此时将看到key
使用了base64
编码,关于
Etcd V2 与V3 版本API 的区别
etcdctl
的ETCDCTL_API=3
环境变量来指定
Etcd 数据备份
我们安装的时候指定的/var/lib/etcd
,一定要对该目录做好备份。