Coreos

從 discovery.etcd.io 中刪除陳舊的 CoreOS 節點

  • April 8, 2015

我從 CoreOS 集群中刪除了一個節點,並在其位置上創建了一個新節點。不幸的是,它獲取了與舊機器相同的 IP。

這阻止了 etcd 發現集群的其餘部分,日誌中顯示如下消息:“失敗:加入請求失敗:對等地址已存在”

如何從 discovery.etcd.io 中刪除舊節點?

如果您知道機器 ID,請簡短回答

發送 HTTP DELETE 請求到https://discovery.etcd.io/<cluster-id>/<machine-id>

例如

curl https://discovery.etcd.io/abcdef0123456789abcdef0123456789/7cf9a5cf5e3b4baea82e28618bffeaf5 -XDELETE

更長的答案-如何找到要刪除的機器ID

首先,從您的發現 URL 中獲取 JSON 對象,例如

https://discovery.etcd.io/abcdef0123456789abcdef0123456789

它看起來有點像這樣:

{
 "action": "get",
 "node": {
   "key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789",
   "dir": true,
   "nodes": [
     {
       "key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/6148dbb812a44dbe8773bebf329634e7",
       "value": "http:\/\/10.132.47.218:7001",
       "expiration": "2015-04-15T17:58:12.753046544Z",
       "ttl": 598570,
       "modifiedIndex": 453369429,
       "createdIndex": 453369429
     },
     {
       "key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/646fbdaee73544e6ac289894e935f0c7",
       "value": "http:\/\/10.132.47.218:7001",
       "expiration": "2015-04-15T18:30:03.08506867Z",
       "ttl": 600480,
       "modifiedIndex": 453418705,
       "createdIndex": 453418705
     },
     {
       "key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/05e0decf1d9240819382db7a7f8ff2e7",
       "value": "http:\/\/10.132.58.166:7001",
       "expiration": "2015-04-14T23:47:31.402148037Z",
       "ttl": 533129,
       "modifiedIndex": 451690943,
       "createdIndex": 451690943
     },
     {
       "key": "\/_etcd\/registry\/abcdef0123456789abcdef0123456789\/af2783b2327e4f3a9b6e7ea169814a06",
       "value": "http:\/\/10.132.58.167:7001",
       "expiration": "2015-04-14T23:47:38.676204353Z",
       "ttl": 533136,
       "modifiedIndex": 451691169,
       "createdIndex": 451691169
     }
   ],
   "modifiedIndex": 426955695,
   "createdIndex": 426955695
 }
}

假設我們重用的 IP 是10.132.47.218- 我們要辨識與該 IP 對應的機器 ID。從key可以看出這是6148dbb812a44dbe8773bebf329634e7

現在我們可以簡單地使用 DELETE 動詞來刪除它

curl https://discovery.etcd.io/abcdef0123456789abcdef0123456789/7cf9a5cf5e3b4baea82e28618bffeaf5 -XDELETE

引用自:https://serverfault.com/questions/681377