[{"data":1,"prerenderedAt":503},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fmachines\u002Fclusters":3},{"id":4,"title":5,"body":6,"description":495,"extension":496,"meta":497,"navigation":498,"path":499,"seo":500,"stem":501,"__hash__":502},"docs\u002Fdocs\u002Fmachines\u002Fclusters.md","Form a cluster",{"type":7,"value":8,"toc":487},"minimark",[9,13,22,27,64,75,79,210,216,234,241,245,260,285,293,311,314,377,384,388,409,413,435,450,464,471,475,483],[10,11,5],"h1",{"id":12},"form-a-cluster",[14,15,16,17,21],"p",{},"Applications deploy onto a cluster, not a single machine. A cluster is three or more ",[18,19,20],"code",{},"sg"," machines joined into one native LXD cluster, so instances can be placed on any member and share one image store.",[23,24,26],"h2",{"id":25},"before-you-start","Before you start",[28,29,30,46,53],"ul",{},[31,32,33,34,36,37,41,42,45],"li",{},"Three or more machines created by ",[18,35,20],{}," ",[38,39,40],"strong",{},"in this directory",". They share the ledger at ",[18,43,44],{},".sg\u002Fstate.db","; a machine made from another directory doesn't count.",[31,47,48,49,52],{},"All of them on the same LXD channel (the default ",[18,50,51],{},"5.21\u002Fstable"," is fine).",[31,54,55,56,59,60,63],{},"Each machine's tailnet IPv4 address. ",[18,57,58],{},"tailscale status"," on your workstation lists them, or run ",[18,61,62],{},"tailscale ip -4"," on the host.",[65,66,68],"note",{"kind":67},"warning",[14,69,70,71,74],{},"Cluster membership grants ",[38,72,73],{},"shared root-level trust"," across every member. Root on one member can control instances on all of them. Only cluster machines you'd trust with each other's keys.",[23,76,78],{"id":77},"_1-write-clusteryaml","1. Write cluster.yaml",[80,81,86],"pre",{"className":82,"code":83,"language":84,"meta":85,"style":85},"language-yaml shiki shiki-themes github-dark-high-contrast","api_version: genesis\u002Fv1\ncluster:\n  name: lab\n  members:                          # members[0] bootstraps the cluster\n    - name: node-a                  # a machine registered in this ledger\n      core_address: \"100.64.0.11:8444\"\n    - name: node-b\n      core_address: \"100.64.0.12:8444\"\n    - name: node-c\n      core_address: \"100.64.0.13:8444\"\n","yaml","",[18,87,88,105,114,125,138,155,166,178,188,200],{"__ignoreMap":85},[89,90,93,97,101],"span",{"class":91,"line":92},"line",1,[89,94,96],{"class":95},"sKpQp","api_version",[89,98,100],{"class":99},"sMAXC",": ",[89,102,104],{"class":103},"sTRMh","genesis\u002Fv1\n",[89,106,108,111],{"class":91,"line":107},2,[89,109,110],{"class":95},"cluster",[89,112,113],{"class":99},":\n",[89,115,117,120,122],{"class":91,"line":116},3,[89,118,119],{"class":95},"  name",[89,121,100],{"class":99},[89,123,124],{"class":103},"lab\n",[89,126,128,131,134],{"class":91,"line":127},4,[89,129,130],{"class":95},"  members",[89,132,133],{"class":99},":                          ",[89,135,137],{"class":136},"sQrFR","# members[0] bootstraps the cluster\n",[89,139,141,144,147,149,152],{"class":91,"line":140},5,[89,142,143],{"class":99},"    - ",[89,145,146],{"class":95},"name",[89,148,100],{"class":99},[89,150,151],{"class":103},"node-a",[89,153,154],{"class":136},"                  # a machine registered in this ledger\n",[89,156,158,161,163],{"class":91,"line":157},6,[89,159,160],{"class":95},"      core_address",[89,162,100],{"class":99},[89,164,165],{"class":103},"\"100.64.0.11:8444\"\n",[89,167,169,171,173,175],{"class":91,"line":168},7,[89,170,143],{"class":99},[89,172,146],{"class":95},[89,174,100],{"class":99},[89,176,177],{"class":103},"node-b\n",[89,179,181,183,185],{"class":91,"line":180},8,[89,182,160],{"class":95},[89,184,100],{"class":99},[89,186,187],{"class":103},"\"100.64.0.12:8444\"\n",[89,189,191,193,195,197],{"class":91,"line":190},9,[89,192,143],{"class":99},[89,194,146],{"class":95},[89,196,100],{"class":99},[89,198,199],{"class":103},"node-c\n",[89,201,203,205,207],{"class":91,"line":202},10,[89,204,160],{"class":95},[89,206,100],{"class":99},[89,208,209],{"class":103},"\"100.64.0.13:8444\"\n",[14,211,212,215],{},[18,213,214],{},"core_address"," is the member's tailnet address and LXD API port. It must:",[28,217,218,225,228],{},[31,219,220,221,224],{},"carry an explicit port, never ",[18,222,223],{},"8443"," and never a wildcard;",[31,226,227],{},"be unique across members;",[31,229,230,231,233],{},"match the address the member actually has and the port its LXD is bound to. ",[18,232,20],{}," checks this against what it observes, never DNS.",[14,235,236,237,240],{},"Put ",[18,238,239],{},"cluster.yaml"," in the same directory as the machine specs.",[23,242,244],{"id":243},"_2-create-it","2. Create it",[14,246,247,248,251,252,255,256,259],{},"There's no ",[18,249,250],{},"init"," or ",[18,253,254],{},"plan"," for clusters: ",[18,257,258],{},"create"," shows its plan and asks once.",[80,261,265],{"className":262,"code":263,"language":264,"meta":85,"style":85},"language-bash shiki shiki-themes github-dark-high-contrast","sg cluster create --config cluster.yaml\n","bash",[18,266,267],{"__ignoreMap":85},[89,268,269,272,275,278,282],{"class":91,"line":92},[89,270,20],{"class":271},"s_sBn",[89,273,274],{"class":103}," cluster",[89,276,277],{"class":103}," create",[89,279,281],{"class":280},"sCcAr"," --config",[89,283,284],{"class":103}," cluster.yaml\n",[80,286,291],{"className":287,"code":289,"language":290,"meta":85},[288],"language-text","Form cluster lab over 3 member(s)? Membership grants shared root-level trust. [y\u002FN]:\n","text",[18,292,289],{"__ignoreMap":85},[14,294,295,296,298,299,302,303,306,307,310],{},"Before asking, ",[18,297,20],{}," checks every member: registered, with ",[18,300,301],{},"install.lxd",", ",[18,304,305],{},"firewall.guard"," and ",[18,308,309],{},"verify.isolation"," applied; matching LXD versions; compatible storage pools and bridges; and a working control path from each joiner to the bootstrap member. Any mismatch is a refusal that names the member.",[14,312,313],{},"The run applies four kinds of change:",[315,316,317,330],"table",{},[318,319,320],"thead",{},[321,322,323,327],"tr",{},[324,325,326],"th",{},"Change",[324,328,329],{},"Does",[331,332,333,347,357,367],"tbody",{},[321,334,335,341],{},[336,337,338],"td",{},[18,339,340],{},"cluster.bootstrap",[336,342,343,344],{},"Turns on clustering on ",[18,345,346],{},"members[0]",[321,348,349,354],{},[336,350,351],{},[18,352,353],{},"cluster.join.\u003Cmember>",[336,355,356],{},"Joins each other member with a one-time token that never touches disk, a plan or the ledger",[321,358,359,364],{},[336,360,361],{},[18,362,363],{},"cluster.guard.peers",[336,365,366],{},"Extends every member's firewall guard so members can reach each other",[321,368,369,374],{},[336,370,371],{},[18,372,373],{},"cluster.verify",[336,375,376],{},"Checks exact membership and the guard on each member, and boots a throwaway VM per member to re-prove isolation",[14,378,379,380,383],{},"When it finishes, the cluster is registered in the ledger, and ",[18,381,382],{},"application.yaml"," files can name it.",[23,385,387],{"id":386},"rules-that-protect-you","Rules that protect you",[28,389,390,399],{},[31,391,392,398],{},[38,393,394,395,397],{},"Editing ",[18,396,239],{}," never releases a member."," Teardown follows the recorded roster, not the file.",[31,400,401,408],{},[38,402,403,404,407],{},"A member refuses a direct ",[18,405,406],{},"sg machine destroy","."," You'd be pulling a node out from under a running cluster.",[23,410,412],{"id":411},"taking-a-cluster-apart","Taking a cluster apart",[80,414,416],{"className":262,"code":415,"language":264,"meta":85,"style":85},"sg cluster destroy --config cluster.yaml --with-machines\n",[18,417,418],{"__ignoreMap":85},[89,419,420,422,424,427,429,432],{"class":91,"line":92},[89,421,20],{"class":271},[89,423,274],{"class":103},[89,425,426],{"class":103}," destroy",[89,428,281],{"class":280},[89,430,431],{"class":103}," cluster.yaml",[89,433,434],{"class":280}," --with-machines\n",[14,436,437,438,441,442,445,446,449],{},"Today this is the ",[38,439,440],{},"only"," cluster teardown that completes. Plain ",[18,443,444],{},"sg cluster destroy"," always refuses with ",[18,447,448],{},"sg:cluster-teardown-unsupported",", because the pinned LXD version can't remove the final member natively.",[14,451,452,453,456,457,459,460,463],{},"With ",[18,454,455],{},"--with-machines",", every recorded member gets a full machine teardown, the same as ",[18,458,406],{},". You see every member's plan, then answer ",[38,461,462],{},"one"," question. That deletes every instance and pool on every member.",[65,465,466],{"kind":67},[14,467,468,470],{},[18,469,455],{}," destroys all the machines too, data included. Destroy your applications first if you want to watch that happen in smaller steps.",[23,472,474],{"id":473},"next","Next",[14,476,477,482],{},[478,479,481],"a",{"href":480},"\u002Fdocs\u002Fapplications\u002Ffirst-application","Launch your first application"," on your new cluster.",[484,485,486],"style",{},"html pre.shiki code .sKpQp, html code.shiki .sKpQp{--shiki-default:#72F088}html pre.shiki code .sMAXC, html code.shiki .sMAXC{--shiki-default:#F0F3F6}html pre.shiki code .sTRMh, html code.shiki .sTRMh{--shiki-default:#ADDCFF}html pre.shiki code .sQrFR, html code.shiki .sQrFR{--shiki-default:#BDC4CC}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .s_sBn, html code.shiki .s_sBn{--shiki-default:#FFB757}html pre.shiki code .sCcAr, html code.shiki .sCcAr{--shiki-default:#91CBFF}",{"title":85,"searchDepth":107,"depth":107,"links":488},[489,490,491,492,493,494],{"id":25,"depth":107,"text":26},{"id":77,"depth":107,"text":78},{"id":243,"depth":107,"text":244},{"id":386,"depth":107,"text":387},{"id":411,"depth":107,"text":412},{"id":473,"depth":107,"text":474},"Join three or more sg machines into one LXD cluster, understand the trust it creates, and take it apart again.","md",{},true,"\u002Fdocs\u002Fmachines\u002Fclusters",{"title":5,"description":495},"docs\u002Fmachines\u002Fclusters","2iFCTNt1ce6h7M6tDKfq3QjLre-LPig74XN_x5vhbEU",1796464240883]