[{"data":1,"prerenderedAt":387},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fgetting-started\u002Fcore-concepts":3},{"id":4,"title":5,"body":6,"description":379,"extension":380,"meta":381,"navigation":382,"path":383,"seo":384,"stem":385,"__hash__":386},"docs\u002Fdocs\u002Fgetting-started\u002Fcore-concepts.md","Core concepts",{"type":7,"value":8,"toc":369},"minimark",[9,13,22,27,34,102,114,118,130,140,144,158,212,218,228,232,247,266,270,283,289,295,302,306,313,319,323],[10,11,5],"h1",{"id":12},"core-concepts",[14,15,16,17,21],"p",{},"Six ideas explain almost everything ",[18,19,20],"code",{},"sg"," does, and everything it refuses to do.",[23,24,26],"h2",{"id":25},"specs","Specs",[14,28,29,30,33],{},"A spec is a YAML file that says what should exist. There are three kinds, all ",[18,31,32],{},"api_version: genesis\u002Fv1",":",[35,36,37,53],"table",{},[38,39,40],"thead",{},[41,42,43,47,50],"tr",{},[44,45,46],"th",{},"Spec",[44,48,49],{},"Describes",[44,51,52],{},"Commands",[54,55,56,72,87],"tbody",{},[41,57,58,64,67],{},[59,60,61],"td",{},[18,62,63],{},"machine.yaml",[59,65,66],{},"One hardened LXD host",[59,68,69],{},[18,70,71],{},"sg machine …",[41,73,74,79,82],{},[59,75,76],{},[18,77,78],{},"cluster.yaml",[59,80,81],{},"An LXD cluster over three or more machines",[59,83,84],{},[18,85,86],{},"sg cluster …",[41,88,89,94,97],{},[59,90,91],{},[18,92,93],{},"application.yaml",[59,95,96],{},"Instances, volumes, services and a load balancer on a cluster",[59,98,99],{},[18,100,101],{},"sg application …",[14,103,104,105,110,111,113],{},"Specs are strict. Unknown or wrongly typed fields are refused, names must be lowercase DNS-safe labels, and every field you leave out has a ",[106,107,109],"a",{"href":108},"\u002Fdocs\u002Freference\u002Fmachine-spec","documented default",". Secrets never go in a spec. A spec names the environment variable that holds the secret, and ",[18,112,20],{}," reads it at run time.",[23,115,117],{"id":116},"the-project-directory","The project directory",[14,119,120,121,125,126,129],{},"Keep every spec for one estate in ",[122,123,124],"strong",{},"one directory",". The ledger lives next to them at ",[18,127,128],{},".sg\u002Fstate.db",". The cluster reads its members' machine records from that ledger, and the machine destroy guard reads the cluster's. A spec in another directory gets another ledger, and the two can't see each other.",[131,132,138],"pre",{"className":133,"code":135,"language":136,"meta":137},[134],"language-text","~\u002Festates\u002Flab\u002F\n├── node-a.yaml\n├── node-b.yaml\n├── node-c.yaml\n├── cluster.yaml\n├── application.yaml\n└── .sg\u002Fstate.db        # the ledger: never edit it by hand\n","text","",[18,139,135],{"__ignoreMap":137},[23,141,143],{"id":142},"plans","Plans",[14,145,146,147,150,151,150,154,157],{},"A plan is the ordered list of changes needed to make reality match the spec. Each change has an ID (",[18,148,149],{},"harden.ssh",", ",[18,152,153],{},"cluster.join.node-b",[18,155,156],{},"volumes.pgdata","), a reason, and a risk grade:",[35,159,160,170],{},[38,161,162],{},[41,163,164,167],{},[44,165,166],{},"Risk",[44,168,169],{},"Means",[54,171,172,182,192,202],{},[41,173,174,179],{},[59,175,176],{},[18,177,178],{},"none",[59,180,181],{},"Verification only. Runs no host mutation.",[41,183,184,189],{},[59,185,186],{},[18,187,188],{},"low",[59,190,191],{},"The least disruptive kind of change.",[41,193,194,199],{},[59,195,196],{},[18,197,198],{},"medium",[59,200,201],{},"Changes how the host or an instance behaves, or creates data storage.",[41,203,204,209],{},[59,205,206],{},[18,207,208],{},"high",[59,210,211],{},"Can cut access, interrupt service or recreate an instance. Read these rows twice.",[14,213,214,215,217],{},"An application group takes the grade of its most severe replica change, so an image change that recreates instances grades the whole group ",[18,216,208],{},".",[14,219,220,223,224,227],{},[18,221,222],{},"plan"," commands are read-only. They connect, observe and print. Apply commands always build their ",[122,225,226],{},"own fresh plan",", so an old plan you looked at an hour ago is never trusted.",[23,229,231],{"id":230},"runs-and-confirmation","Runs and confirmation",[14,233,234,235,238,239,242,243,246],{},"An apply is a ",[122,236,237],{},"run",". It prints the plan and asks ",[18,240,241],{},"… [y\u002FN]:",". Only an answer starting with ",[18,244,245],{},"y"," continues.",[248,249,250,257,263],"ul",{},[251,252,253,256],"li",{},[18,254,255],{},"--yes"," skips that question. It never skips a safety or ownership check.",[251,258,259,260,262],{},"A run stops at the first failed change and records it. Fix the host and run again; ",[18,261,20],{}," picks up from what's actually there.",[251,264,265],{},"Ctrl-C cancels cleanly. No new change starts, cleanup runs, and the run is recorded as aborted.",[23,267,269],{"id":268},"the-ledger-and-ownership","The ledger and ownership",[14,271,272,273,275,276,279,280,282],{},"Everything ",[18,274,20],{}," changes goes into the ledger: which change, on which host, with which inputs, and what it created. That record is the ",[122,277,278],{},"only"," proof of ownership ",[18,281,20],{}," accepts.",[14,284,285,286,288],{},"So rollback and destroy act only on what the ledger proves ",[18,287,20],{}," made. A container you created by hand on the same host, a volume another tool made, a package that was already installed: all retained and reported, never touched.",[131,290,293],{"className":291,"code":292,"language":136,"meta":137},[134],"retained: instance scratch-box is not owned by sg\n",[18,294,292],{"__ignoreMap":137},[14,296,297,298,301],{},"Don't edit or delete ",[18,299,300],{},"state.db",". Back it up with your specs instead.",[23,303,305],{"id":304},"generations","Generations",[14,307,308,309,312],{},"For applications, every deploy that finishes ",[122,310,311],{},"and"," passes health and exposure checks becomes a generation: 1, 2, 3, and so on. Failed or aborted deploys stay in run history but never become generations.",[14,314,315,318],{},[18,316,317],{},"sg application rollback"," redeploys the exact recorded spec of generation N-1 as a new generation N+1. History only grows.",[23,320,322],{"id":321},"exit-codes","Exit codes",[35,324,325,334],{},[38,326,327],{},[41,328,329,332],{},[44,330,331],{},"Code",[44,333,169],{},[54,335,336,349,359],{},[41,337,338,343],{},[59,339,340],{},[18,341,342],{},"0",[59,344,345,346],{},"Success, help, a read-only report (even one that shows drift), or you answered ",[18,347,348],{},"N",[41,350,351,356],{},[59,352,353],{},[18,354,355],{},"1",[59,357,358],{},"Runtime failure, safety refusal or configuration error",[41,360,361,366],{},[59,362,363],{},[18,364,365],{},"2",[59,367,368],{},"Usage error: bad flag, unknown group or verb",{"title":137,"searchDepth":370,"depth":370,"links":371},2,[372,373,374,375,376,377,378],{"id":25,"depth":370,"text":26},{"id":116,"depth":370,"text":117},{"id":142,"depth":370,"text":143},{"id":230,"depth":370,"text":231},{"id":268,"depth":370,"text":269},{"id":304,"depth":370,"text":305},{"id":321,"depth":370,"text":322},"Specs, plans, runs, the ledger, ownership and generations. The six ideas that explain everything sg does and refuses to do.","md",{},true,"\u002Fdocs\u002Fgetting-started\u002Fcore-concepts",{"title":5,"description":379},"docs\u002Fgetting-started\u002Fcore-concepts","d2E8Bz2SvLoCxhPl6d3r8BgKTzSHhoe11bQYTfgNK2M",1796464240881]