嘿,所有,
也许这是一个非常愚蠢的问题,但是我在集群节点之间有一个带SSL的CoreOS集群。我已经在我的云配置中设置了Fleet和etcd。
Flecttl工作得很好。我不必提供任何证书,但是当我使用etcdctl时,我被迫提供了这样的证书路径:
etcdctl --ca-file /home/core/etcd/certificates/ca.pem --cert-file /home/core/etcd/certificates/coreos.pem --key-file /home/core/etcd/certificates/coreos-key.pem --endpoint "https://10.129.1.226:2379" get /test/key
有没有一种可以这样配置etcd2的方式,使得etcdctl不需要每次都需要证书路径,例如:
etcdctl get /test/key
我的云配置的一部分:
write_files:
# tell etcd2 and fleet where our certificates are going to live:
- path: /run/systemd/system/etcd2.service.d/30-certificates.conf
permissions: 0644
content: |
[Service]
# client environment variables
Environment=ETCD_CA_FILE=/home/core/etcd/certificates/ca.pem
Environment=ETCD_CERT_FILE=/home/core/etcd/certificates/coreos.pem
Environment=ETCD_KEY_FILE=/home/core/etcd/certificates/coreos-key.pem
# peer environment variables
Environment=ETCD_PEER_CA_FILE=/home/core/etcd/certificates/ca.pem
Environment=ETCD_PEER_CERT_FILE=/home/core/etcd/certificates/coreos.pem
Environment=ETCD_PEER_KEY_FILE=/home/core/etcd/certificates/coreos-key.pem
提前谢谢了。
最佳答案
根据etcdctl工具的README.md,可以为客户端设置环境变量。
您可以对其进行测试:
1:确认它不起作用
core@sylvana-coreos ~/docker $ etcdctl --endpoint "https://10.129.1.226:2379" ls /test
Error: client: etcd cluster is unavailable or misconfigured
error #0: x509: certificate signed by unknown authority
2:导出正确的环境变量
export ETCDCTL_CA_FILE=/your/path/to/ca.pem
export ETCDCTL_CERT_FILE=/your/path/to/cert.pem
export ETCDCTL_KEY_FILE=/your/path/to/key.pem
3:验证它是否正常
core@sylvana-coreos ~/docker $ etcdctl --endpoint "https://10.129.1.226:2379" ls /test
/test/key