context deadline exceeded when check etcd health

9/14/2019

I am check etcd(3.3.13) cluster status using this command:

[root@iZuf63refzweg1d9dh94t8Z work]# /opt/k8s/bin/etcdctl endpoint health --cluster
https://172.19.150.82:2379 is unhealthy: failed to connect: context deadline exceeded
https://172.19.104.231:2379 is unhealthy: failed to connect: context deadline exceeded
https://172.19.104.230:2379 is unhealthy: failed to connect: context deadline exceeded
Error: unhealthy cluster

check etcd member:

[root@iZuf63refzweg1d9dh94t8Z work]# /opt/k8s/bin/etcdctl member list
    56298c42af788da7, started, azshara-k8s02, https://172.19.104.230:2380, https://172.19.104.230:2379
    5ab2d0e431f00a20, started, azshara-k8s01, https://172.19.104.231:2380, https://172.19.104.231:2379
    84c70bf96ccff30f, started, azshara-k8s03, https://172.19.150.82:2380, https://172.19.150.82:2379

my cluster is deploy success?If not,how to solve the context deadline exceeded error? I tried this:

     export ETCDCTL_API=3
     [root@ops001 ~]# /opt/k8s/bin/etcdctl endpoint status --write-out=table
+----------------+------------------+---------+---------+-----------+-----------+------------+
|    ENDPOINT    |        ID        | VERSION | DB SIZE | IS LEADER | RAFT TERM | RAFT INDEX |
+----------------+------------------+---------+---------+-----------+-----------+------------+
| 127.0.0.1:2379 | 5ab2d0e431f00a20 |  3.3.13 |  2.0 MB |     false |        20 |   39303798 |
+----------------+------------------+---------+---------+-----------+-----------+------------+
[root@ops001 ~]# /opt/k8s/bin/etcdctl endpoint health
127.0.0.1:2379 is healthy: successfully committed proposal: took = 1.816293ms
[root@ops001 ~]# /opt/k8s/bin/etcdctl endpoint health --cluster
https://172.19.150.82:2379 is unhealthy: failed to connect: context deadline exceeded
https://172.19.104.231:2379 is unhealthy: failed to connect: context deadline exceeded
https://172.19.104.230:2379 is unhealthy: failed to connect: context deadline exceeded
Error: unhealthy cluster
-- Dolphin
kubernetes

1 Answer

9/15/2019

how to solve the context deadline exceeded error?

That error is misleading; it is usually caused by etcdctl not providing credentials and/or not using the same ETCDCTL_API= value as the cluster. If it's a modern etcd version, you'll want export ETCDCTL_API=3, followed by providing the same --cert-file= and --key-file= and likely --trusted-ca-file= as was used to start etcd itself.

-- mdaniel
Source: StackOverflow