|
<!DOCTYPE html> |
|
<html class="no-js" lang="en"> |
|
|
|
<head> |
|
<style> |
|
@charset "UTF-8";article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}html{font-size:100%;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0;font-size:13px;line-height:1.231}body,button,input,select,textarea{font-family:sans-serif;color:#222020}::-moz-selection{background:#fe57a1;color:#fff;text-shadow:none}::selection{background:#fe57a1;color:#fff;text-shadow:none}a{color:#00e}a:visited{color:#551a8b}a:hover{color:#06e}a:focus{outline:thin dotted}a:hover,a:active{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:1em 40px}dfn{font-style:italic}hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}ins{background:#ff9;color:#000;text-decoration:none}mark{background:#ff0;color:#000;font-style:italic;font-weight:700}pre,code,kbd,samp{font-family:monospace,monospace;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:before,q:after{content:"";content:none}small{font-size:85%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}ul{margin:1em 0;padding:0 0 0 50px}ol{margin:1em 0;padding:0 0 0 60px}dd{margin:0 0 0 40px}nav ul,nav ol{list-style:none;list-style-image:none;margin:0;padding:0}img{border:0;-ms-interpolation-mode:bicubic;vertical-align:middle}svg:not(:root){overflow:hidden}figure{margin:0}form{margin:0}fieldset{border:0;margin:0;padding:0}label{cursor:pointer}legend{border:0;*margin-left:-7px;padding:0}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal;*overflow:visible}table button,table input{*overflow:auto}button,input[type=button],input[type=reset],input[type=submit]{cursor:pointer;-webkit-appearance:button}input[type=checkbox],input[type=radio]{box-sizing:border-box}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:vertical}input:invalid,textarea:invalid{background-color:#f0dddd}table{border-collapse:collapse;border-spacing:0}td{vertical-align:top}body{font-family:minion pro,palatino,hoefler text,times new roman,serif}header,footer,p,h2,h3,th,td,li,dd,dt,blockquote{font-size:1.4em}li li{font-size:1em}li p{font-size:1em}pre{font-size:1rem;font-family:monaco,monospace,sans-serif;line-height:1.4em}code{font-family:monaco,monospace,sans-serif}dt{font-weight:700}ul,ol{list-style-position:outside;margin:0 0 0 3em;padding:0}a,a:active,a.link,a:visited,a:hover{text-decoration:none;color:#8c0808}p,li,dd,dt,blockquote{max-width:35em;line-height:1.5em}dl dd p{font-size:1em}li{margin:5px 0}dt{margin-top:10px}sup{padding:0 0 0 4px;font-weight:700}#container{margin:0 auto 100px;position:relative;width:90%;max-width:820px;overflow:hidden;padding:0 2em}header{overflow:hidden;font-size:1em}header a:hover{text-decoration:underline}#logo{color:#222}#logo h1,#logo h2,#logo h3,#logo h4,#logo h5{font-family:monaco,monospace,sans-serif;font-weight:400;margin:0;padding:0}#logo h1{font-size:4em;margin-top:.2em}#logo h2{font-size:1.8em}#logo h3{margin:.3em 0 1em}#logo h3#mobile_nav{display:none}#logo h4{font-size:2em;text-align:right}#logo h4 a{color:#222}#logo h5{text-align:right;font-size:1.1em}#logo h5 a{color:#222}#article_nav{color:#222;margin:5px 0 30px;padding-right:10px}#article_nav h5{font-family:monaco,monospace,sans-serif;font-weight:400;font-size:1.1em;margin:0;padding:0;text-align:right}#article_nav h5 a{color:#222}footer{margin:100px 0 40px;color:#aaa;font-size:1.1em;line-height:1.5em}footer a:active,footer a:link,footer a:visited,footer a:hover{color:#aaa}footer a:hover{text-decoration:underline}.mobile_only{display:none}.home #logo{text-align:center}.home h2{font-family:signika negative,serif;font-size:2em;font-weight:400;color:#222;margin:0 0 10px;padding:0;clear:left}.home li{margin:8px 0}.home #bio{font-size:1.4em;margin-bottom:10px}.home #bio p{width:auto;margin:5px 0;font-size:1em}.home a.read-more{display:block;text-align:right;padding:5px 0;font-size:10pt}#about-photo{float:right;margin:0 0 10px 10px;border:2px solid #ccc;padding:2px}.articles{padding:0;font-size:1.4em;margin-bottom:20px}.articles h1#title{font-family:signika negative,serif;font-size:3em;font-weight:400;color:#222;margin:0;padding:0}.articles p{font-size:1em}.articles p code{font-size:.85em}.articles .article_summary{border-bottom:1px dotted #ddd;overflow:hidden;padding:.5em 0}.articles .article_summary p{font-size:1em}.articles .article_summary p code{font-size:.85em}.articles .article_summary .meta{float:right;width:30%;text-align:right;color:#666;font-size:.85em}.articles .article_summary .meta a{color:#974747}.articles .article_summary .main a{display:block}.articles .article_summary .main p{font-size:1em;margin:.1em 0 0}.article{}.article h1#article_title{font-family:signika negative,serif;color:#8c0808;font-weight:400;font-size:3.7em;margin:.3em 0 .2em;text-align:left;line-height:1.1}.article h1#title{font-family:signika negative,serif;font-size:4em;font-weight:400;color:#222;margin:0;padding:0}.article p{margin:10px 0}.article p code{border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;background-color:#eee;padding:2px 3px;font-size:.85em}.article li code{border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;background-color:#eee;padding:2px 3px;font-size:1rem}.article li{}.article li div.highlight code{background-color:#272822;padding:0}.article img.title-image{margin:20px 0 0;width:100%}.article h1{font-family:signika negative,serif;color:#8c0808;font-weight:400;font-size:2em;margin-top:1em}.article h1 code{font-size:.85em}.article h2{font-family:signika negative,serif;color:#8c0808;font-weight:400;font-size:1.8em;margin:20px 0 10px}.article h2 code{font-size:.85em}.article h3{font-family:signika negative,serif;color:#8c0808;font-weight:400;font-size:1.6em;margin:10px 0}.article h3 code{font-size:.85em}.article h4{font-family:signika negative,serif;color:#8c0808;font-weight:400;font-size:1.4em;margin:10px 0}.article h4 code{font-size:.85em}.article .byline{font-family:signika negative,serif;color:#8c0808;font-weight:400;color:#974747;font-size:1.4em;text-align:left;margin:0 0 30px}.article blockquote{background-color:#eee;border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;padding:.8em 1em;font-style:italic;margin:1em 0 0}.article blockquote p{font-size:1em;margin:0;padding:.4em 0}.article div.slidedeck{width:90%;max-width:45em}.article div.warning{background-color:#eee;border:1px solid #ddd;color:#555;padding:1em;margin-top:20px;font-size:1.4em;line-height:1.5em;width:38em}.article div.warning p{margin:0}.article img.align-right{float:right;padding:2px;margin:0 0 2em 1em;background-color:#fff;border:1px solid #aaa}.article img.noborder{border:none}.article img.screenshot{background-color:#fff;border:1px dashed #aaa;padding:8px 12px}.article img.photo{width:100%;padding:0;margin:0 0 1em;border:2px solid #aaa}.article figure img{width:70%}.article figure figcaption h4{text-align:left;color:#aaa;font-family:minion pro,palatino,hoefler text,times new roman,serif;font-style:italic}.article .highlight{border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;width:95%;max-width:790px;padding:10px 10px 10px 20px}.article .highlight pre{margin:0}.article .keys{border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;background-color:#ddd;color:#000;padding:3px 7px;font-family:monaco,monospace,sans-serif;border:1px solid #ccc;font-size:.9em}.article nav#TableOfContents ul{list-style:none;padding-left:0}.article nav#TableOfContents ul ul{list-style:disc inside;padding-left:20px}.article nav#TableOfContents ul ul ul{list-style:circle inside}.article nav#TableOfContents ul ul ul li{font-size:.9em}.article nav#TableOfContents ul ul ul li code{font-size:.9em}.article div.footnotes{margin:80px 0 40px;font-size:.8em}.article div.footnotes ol{margin:40px 0 0 15px}.article div.footnotes ol li{max-width:none}.article div.footnotes ol li p{max-width:none;margin:0 0 4px}.article div.footnotes ul{margin:0 0 0 14px}.article div.footnotes div.highlight{margin:0 0 6px}.article div.footnotes code{font-size:.8em}.article #article_meta{font-size:.8em;margin-top:80px}.article #article_meta span.hr{color:#aaa}.article #article_meta p{max-width:none}.ir{display:block;border:0;text-indent:-999em;overflow:hidden;background-color:transparent;background-repeat:no-repeat;text-align:left;direction:ltr}.ir br{display:none}.hidden{display:none!important;visibility:hidden}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.clearfix:before,.clearfix:after{content:"";display:table}.clearfix:after{clear:both}.clearfix{zoom:1}@media screen and (min-width:10px) and (max-width:480px){#container{padding:0 10px;margin-bottom:20px}.desktop_only{display:none}.mobile_only{display:block}.home #logo{margin-bottom:20px}.home h2{font-size:1.4em}.home #about-photo{display:none}#logo h1{font-size:2.6em}#logo h3#screen_nav{display:none}#logo h3#mobile_nav{margin-top:0;display:block}#logo h4{text-align:center}#logo h5{text-align:center;padding-bottom:15px}.articles h1#title{font-size:2em}.articles .article_summary .meta{width:100%;text-align:left;padding-bottom:5px}.articles .article_summary .meta .tags{display:none}#article_nav{padding:0}#article_nav h5{text-align:center}.article{}.article h1#article_title{font-size:2.5em;padding-left:0}.article h1#title{font-size:2.8em;padding-left:0}.article nav#TableOfContents ul{padding:0;margin:0}.article nav#TableOfContents ul ul{padding:0;margin:0}.article nav#TableOfContents ul ul ul{padding-left:20px}.article .article_date{font-size:.8em}.article #nav{float:none}.article .caption{margin:0}.article ul{padding-left:0;margin-left:15px}.article #article_content p,.article #article_content dl,.article #article_content table{margin-left:0;padding-left:0}.article img.align-right{display:none}.article .highlight{width:auto}}@media only screen and (min-width:480px){}@media only screen and (min-width:768px){}@media print{*{background:0 0!important;color:#000!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href)")"}abbr[title]:after{content:" (" attr(title)")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}.highlight .hll{background-color:#49483e}.highlight{background:#272822;color:#f8f8f2}.highlight .c{color:#75715e}.highlight .err{color:#960050;background-color:#1e0010}.highlight .k{color:#66d9ef}.highlight .l{color:#ae81ff}.highlight .n{color:#f8f8f2}.highlight .o{color:#f92672}.highlight .p{color:#f8f8f2}.highlight .cm{color:#75715e}.highlight .cp{color:#75715e}.highlight .c1{color:#75715e}.highlight .cs{color:#75715e}.highlight .ge{font-style:italic}.highlight .gs{font-weight:700}.highlight .kc{color:#66d9ef}.highlight .kd{color:#66d9ef}.highlight .kn{color:#f92672}.highlight .kp{color:#66d9ef}.highlight .kr{color:#66d9ef}.highlight .kt{color:#66d9ef}.highlight .ld{color:#e6db74}.highlight .m{color:#ae81ff}.highlight .s{color:#e6db74}.highlight .na{color:#a6e22e}.highlight .nb{color:#f8f8f2}.highlight .nc{color:#a6e22e}.highlight .no{color:#66d9ef}.highlight .nd{color:#a6e22e}.highlight .ni{color:#f8f8f2}.highlight .ne{color:#a6e22e}.highlight .nf{color:#a6e22e}.highlight .nl{color:#f8f8f2}.highlight .nn{color:#f8f8f2}.highlight .nx{color:#a6e22e}.highlight .py{color:#f8f8f2}.highlight .nt{color:#f92672}.highlight .nv{color:#f8f8f2}.highlight .ow{color:#f92672}.highlight .w{color:#f8f8f2}.highlight .mf{color:#ae81ff}.highlight .mh{color:#ae81ff}.highlight .mi{color:#ae81ff}.highlight .mo{color:#ae81ff}.highlight .sb{color:#e6db74}.highlight .sc{color:#e6db74}.highlight .sd{color:#e6db74}.highlight .s2{color:#e6db74}.highlight .se{color:#ae81ff}.highlight .sh{color:#e6db74}.highlight .si{color:#e6db74}.highlight .sx{color:#e6db74}.highlight .sr{color:#e6db74}.highlight .s1{color:#e6db74}.highlight .ss{color:#e6db74}.highlight .bp{color:#f8f8f2}.highlight .vc{color:#f8f8f2}.highlight .vg{color:#f8f8f2}.highlight .vi{color:#f8f8f2}.highlight .il{color:#ae81ff} |
|
|
|
|
|
@font-face { |
|
font-family: 'Signika Negative'; |
|
font-style: normal; |
|
font-weight: 600; |
|
src: url(https://fonts.gstatic.com/s/signikanegative/v21/E21x_cfngu7HiRpPX3ZpNE4kY5zKSPmJXkF0VDD2RAp5TI3rvdw.ttf) format('truetype'); |
|
} |
|
</style> |
|
<meta charset="utf-8"> |
|
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> |
|
<meta content="width=device-width,initial-scale=1" name="viewport"> |
|
<title> |
|
Reorganising a Consul key-value store — David Winterbottom |
|
</title> |
|
<meta content="David Winterbottom" name="author"> |
|
<meta content="This is really just a reference on how to combine JQ's select filters." name="description"> |
|
<meta content="AymqwRC7u88Y4JPvfIF2F37QKylC04248hLCdJAsh8xgOfe/dVJPV3XS3wLFca1ZMVOtnBfVjaCMTVudWM//5g4AAAB7eyJvcmlnaW4iOiJodHRwczovL3d3dy5nb29nbGV0YWdtYW5hZ2VyLmNvbTo0NDMiLCJmZWF0dXJlIjoiUHJpdmFjeVNhbmRib3hBZHNBUElzIiwiZXhwaXJ5IjoxNjk1MTY3OTk5LCJpc1RoaXJkUGFydHkiOnRydWV9" http-equiv="origin-trial"> |
|
</head> |
|
<body> |
|
<article class="hentry" id="container"> |
|
<header> |
|
<div id="article_nav"> |
|
<h5> |
|
<a> |
|
home |
|
</a> |
|
| |
|
<a> |
|
writing |
|
</a> |
|
| |
|
<a> |
|
TIL |
|
</a> |
|
| |
|
<span class="desktop_only"> |
|
<a> |
|
now |
|
</a> |
|
| |
|
</span> |
|
<a> |
|
about |
|
</a> |
|
</h5> |
|
</div> |
|
</header> |
|
<div id="main" role="main"> |
|
<div class="article" id="content"> |
|
<h1 class="entry-title" id="article_title"> |
|
Reorganising a Consul key-value store |
|
</h1> |
|
<div class="byline desktop_only"> |
|
by |
|
<a class="author vcard"> |
|
David Winterbottom |
|
</a> |
|
on |
|
<time class="published" datetime> |
|
Monday, 27 March 2017 |
|
</time> |
|
</div> |
|
<div class="byline mobile_only"> |
|
by |
|
<a class="author vcard"> |
|
David Winterbottom |
|
</a> |
|
<br> |
|
<span class="article_date"> |
|
on |
|
<time class="published" datetime> |
|
Monday, 27 March 2017 |
|
</time> |
|
</span> |
|
</div> |
|
<div class="entry-content" id="article_content"> |
|
<p> |
|
If your Consul key-value store is structured as: |
|
</p> |
|
<div class="highlight"> |
|
<pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;" tabindex="0"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>/ |
|
</span></span><span style="display:flex;"><span> A/ |
|
</span></span><span style="display:flex;"><span> X <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span> |
|
</span></span><span style="display:flex;"><span> Z <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span> |
|
</span></span><span style="display:flex;"><span> Y <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span> |
|
</span></span><span style="display:flex;"><span> C |
|
</span></span><span style="display:flex;"><span> D |
|
</span></span></code></pre> |
|
</div> |
|
<p> |
|
but you now realise you should have namespaced everything within |
|
<code> |
|
WEBSERVER/ |
|
</code> |
|
(or something like that): |
|
</p> |
|
<div class="highlight"> |
|
<pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;" tabindex="0"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>/ |
|
</span></span><span style="display:flex;"><span> WEBSERVER/ |
|
</span></span><span style="display:flex;"><span> A/ |
|
</span></span><span style="display:flex;"><span> X <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span> |
|
</span></span><span style="display:flex;"><span> Z <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span> |
|
</span></span><span style="display:flex;"><span> Y <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span> |
|
</span></span><span style="display:flex;"><span> C |
|
</span></span><span style="display:flex;"><span> D |
|
</span></span></code></pre> |
|
</div> |
|
<p> |
|
then this Bash script will help you migrate: |
|
</p> |
|
<div class="highlight"> |
|
<pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;" tabindex="0"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/bash |
|
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> |
|
</span></span><span style="display:flex;"><span>set -e <span style="color:#75715e"># Exit on error</span> |
|
</span></span><span style="display:flex;"><span> |
|
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Emit "key value" lines for all keys in Consul's KV store</span> |
|
</span></span><span style="display:flex;"><span>keys_and_values<span style="color:#f92672">()</span> <span style="color:#f92672">{</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># Recursively fetch all values from Consul but exclude:</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># (a) those that end in / (as these are folders)</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># (b) those that start with WEBSERVER/ (as that's where we are migrating</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># to).</span> |
|
</span></span><span style="display:flex;"><span> curl -s <span style="color:#e6db74">"localhost/v1/kv/?recurse"</span> | jq -r <span style="color:#e6db74">' |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> .[] | |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> select( |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> (.Key | endswith("/") | not) and |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> (.Key | startswith("WEBSERVER") | not) |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> ) | |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> [.Key, " ", .Value] | |
|
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> add'</span> | <span style="color:#66d9ef">while</span> read key b64value |
|
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">do</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># Consul's REST API returns values base64-encoded so we decode here.</span> |
|
</span></span><span style="display:flex;"><span> echo $key <span style="color:#e6db74">`</span>echo <span style="color:#e6db74">"</span>$b64value<span style="color:#e6db74">"</span> | base64 -d<span style="color:#e6db74">`</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">done</span> |
|
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> |
|
</span></span><span style="display:flex;"><span> |
|
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Set a new value in Consul's KV store</span> |
|
</span></span><span style="display:flex;"><span>set_key<span style="color:#f92672">()</span> <span style="color:#f92672">{</span> |
|
</span></span><span style="display:flex;"><span> key<span style="color:#f92672">=</span>$1 |
|
</span></span><span style="display:flex;"><span> value<span style="color:#f92672">=</span>$2 |
|
</span></span><span style="display:flex;"><span> curl -s -X PUT -d <span style="color:#e6db74">"</span>$value<span style="color:#e6db74">"</span> <span style="color:#e6db74">"localhost/v1/kv/</span>$key<span style="color:#e6db74">"</span> > /dev/null |
|
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> |
|
</span></span><span style="display:flex;"><span> |
|
</span></span><span style="display:flex;"><span>migrate_to_webserver_namespace<span style="color:#f92672">()</span> <span style="color:#f92672">{</span> |
|
</span></span><span style="display:flex;"><span> keys_and_values | <span style="color:#66d9ef">while</span> read key value |
|
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">do</span> |
|
</span></span><span style="display:flex;"><span> set_key <span style="color:#e6db74">"WEBSERVER/</span>$key<span style="color:#e6db74">"</span> <span style="color:#e6db74">"</span>$value<span style="color:#e6db74">"</span> |
|
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">done</span> |
|
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span> |
|
</span></span><span style="display:flex;"><span> |
|
</span></span><span style="display:flex;"><span>migrate_to_webserver_namespace |
|
</span></span></code></pre> |
|
</div> |
|
<p> |
|
This script uses |
|
<a> |
|
Consul’s REST API |
|
</a> |
|
and filters |
|
the results using |
|
<a> |
|
<code> |
|
jq |
|
</code> |
|
</a> |
|
<sup id="fnref:1"> |
|
<a class="footnote-ref" role="doc-noteref"> |
|
1 |
|
</a> |
|
</sup> |
|
. It’s easily |
|
adapted to migrate key-value pairs between different namespaces. |
|
</p> |
|
<div class="footnotes" role="doc-endnotes"> |
|
<hr> |
|
<ol> |
|
<li id="fn:1"> |
|
<p> |
|
I can never remember jq’s |
|
<code> |
|
select |
|
</code> |
|
syntax so this post is intended largely |
|
as a personal reference on how to do this. |
|
<a class="footnote-backref" role="doc-backlink"> |
|
↩︎ |
|
</a> |
|
</p> |
|
</li> |
|
</ol> |
|
</div> |
|
</div> |
|
<div id="article_meta"> |
|
<span class="hr"> |
|
—————— |
|
</span> |
|
<p> |
|
Something wrong? |
|
<a> |
|
Suggest an improvement |
|
</a> |
|
or |
|
<a> |
|
add a comment |
|
</a> |
|
(see |
|
<a> |
|
article history |
|
</a> |
|
) |
|
<br> |
|
Tagged with: |
|
<a> |
|
consul |
|
</a> |
|
, |
|
<a> |
|
bash |
|
</a> |
|
, |
|
<a> |
|
jq |
|
</a> |
|
<br> |
|
Filed in: |
|
<a> |
|
tips |
|
</a> |
|
</p> |
|
<p> |
|
Previous: |
|
<a> |
|
Lies you're told on a software project |
|
</a> |
|
<br> |
|
Next: |
|
<a> |
|
Podcast.__init__ on Oscar |
|
</a> |
|
</p> |
|
<p> |
|
Copyright © 2005-2023 |
|
<a> |
|
David Winterbottom |
|
</a> |
|
<br> |
|
Content licensed under |
|
<a> |
|
CC BY-NC-SA 4.0 |
|
</a> |
|
. |
|
</p> |
|
</div> |
|
</div> |
|
</div> |
|
</article> |
|
</body> |
|
</html> |
|
|