{"id":199,"date":"2018-02-26T10:26:23","date_gmt":"2018-02-26T18:26:23","guid":{"rendered":"http:\/\/www.gauntletwizard.net\/wordpress\/?p=199"},"modified":"2018-02-26T10:26:23","modified_gmt":"2018-02-26T18:26:23","slug":"kubernetes-build-best-practices","status":"publish","type":"post","link":"https:\/\/www.gauntletwizard.net\/wordpress\/?p=199","title":{"rendered":"Kubernetes Build best practices"},"content":{"rendered":"<p>1) Squash your builds<br \/>\nThis is now part of default docker, but it was well worth it even before. Docker will create a new tarball for each `stage` &#8211; Each ADD, RUN, etc creates a new layer that, by default, you upload. This means if you add secret material and then delete it &#8211; you haven&#8217;t really deleted it. More commonly, it bloats your image sizes. A couple intermediate files can be a huge pain, and waste your time and bandwidth uploading.<\/p>\n<p>Don&#8217;t squash down to a single, monolithic image &#8211; Pick a good base point. Having a fully-featured image as a base layer is not a sin &#8211; So long as you reuse it, it doesn&#8217;t take up any more space or download time, so your lightweight squashed build can build on top of it.<\/p>\n<p>2) Use Multistage builds<br \/>\nYour build environment should be every bit as much a container as your output. Don&#8217;t build your artifacts in your local machine and then add them to your images &#8211; You&#8217;re likely polluting your output with local state more than you know. Deterministic builds require you to understand the state of the build machine and make sure it doesn&#8217;t leak, and containers are a wonderful tool for that. <\/p>\n<p>Alternatively:<br \/>\nJust use Bazel. Bazel&#8217;s <a href=\"http:\/\/rules_docker\">https:\/\/github.com\/bazelbuild\/rules_docker<\/a> is pretty simple to use, powerful, and generates docker-compatible images without actually running docker.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1) Squash your builds This is now part of default docker, but it was well worth it even before. Docker will create a new tarball for each `stage` &#8211; Each ADD, RUN, etc creates a new layer that, by default, you upload. This means if you add secret material and then delete it &#8211; you &hellip; <a href=\"https:\/\/www.gauntletwizard.net\/wordpress\/?p=199\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Kubernetes Build best practices<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/199"}],"collection":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199"}],"version-history":[{"count":2,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gauntletwizard.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}