查看etcd数据
kubespary部署的k8s, etcd, 确认ca信息1
2
3
4ETCD_TRUSTED_CA_FILE=/etc/ssl/etcd/ssl/ca.pem
ETCD_CERT_FILE=/etc/ssl/etcd/ssl/member-node1.pem
ETCD_KEY_FILE=/etc/ssl/etcd/ssl/member-node1-key.pem
ETCD_CLIENT_CERT_AUTH=true
查看成员
API21
2
3
4etcdctl --endpoints https://10.7.12.181:2379 --ca-file=/etc/ssl/etcd/ssl/ca.pem --cert-file=/etc/ssl/etcd/ssl/member-node1.pem --key-file=/etc/ssl/etcd/ssl/member-node1-key.pem member list
23d81eae56fef05e: name=etcd3 peerURLs=https://10.7.12.183:2380 clientURLs=https://10.7.12.183:2379 isLeader=true
8312e1bdd40b1b46: name=etcd2 peerURLs=https://10.7.12.182:2380 clientURLs=https://10.7.12.182:2379 isLeader=false
8c6895ac9eaa0eee: name=etcd1 peerURLs=https://10.7.12.181:2380 clientURLs=https://10.7.12.181:2379 isLeader=false
API3:1
2
3
4
5ETCDCTL_API=3 etcdctl --endpoints https://10.7.12.181:2379 --cacert=/etc/ssl/etcd/ssl/ca.pem --cert=/etc/ssl/etcd/ssl/member-node1.pem --key=/etc/ssl/etcd/ssl/member-node1-key.pem member list
23d81eae56fef05e, started, etcd3, https://10.7.12.183:2380, https://10.7.12.183:2379
8312e1bdd40b1b46, started, etcd2, https://10.7.12.182:2380, https://10.7.12.182:2379
8c6895ac9eaa0eee, started, etcd1, https://10.7.12.181:2380, https://10.7.12.181:2379
[root@node1 ssl]#
查看ns,pod 等信息
1 | ETCDCTL_API=3 etcdctl --endpoints https://10.7.12.181:2379 --cacert=/etc/ssl/etcd/ssl/ca.pem --cert=/etc/ssl/etcd/ssl/member-node1.pem --key=/etc/ssl/etcd/ssl/member-node1-key.pem get /registry/namespaces/cert-manager -w=json|jq . |
使用–prefix可以看到所有的子目录, 如查看集群ns信息
1 | ETCDCTL_API=3 etcdctl --endpoints https://10.7.12.181:2379 --cacert=/etc/ssl/etcd/ssl/ca.pem --cert=/etc/ssl/etcd/ssl/member-node1.pem --key=/etc/ssl/etcd/ssl/member-node1-key.pem get /registry/namespaces --prefix -w=json|python -m json.tool |
查看实际数据:
1 | echo L3JlZ2lzdHJ5L25hbWVzcGFjZXMvY2VydC1tYW5hZ2Vy|base64 -d |
查看k8s元数据
1 | #!/bin/bash |
操作数据
删除信息
1 | # 删除ns下指定的pod |
示例:
1 | [root@node1 ssl]# kubectl get pod |
这里我们看到删除指定pod成功
1 | # 删除指定的ns |