<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rich Marshall on Medium]]></title>
        <description><![CDATA[Stories by Rich Marshall on Medium]]></description>
        <link>https://medium.com/@richard.marshall_58248?source=rss-c4ffd37d5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g9FtfKD-drAiMnTZZrMWfg.jpeg</url>
            <title>Stories by Rich Marshall on Medium</title>
            <link>https://medium.com/@richard.marshall_58248?source=rss-c4ffd37d5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 01:35:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@richard.marshall_58248/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[To Monolith or to Microservice]]></title>
            <link>https://medium.com/ww-engineering/to-monolith-or-to-microservice-f8c3f967e63c?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8c3f967e63c</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[team-topologies]]></category>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Sat, 29 Feb 2020 12:33:02 GMT</pubDate>
            <atom:updated>2020-03-13T11:52:56.662Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Team interactions and microservice architectures." src="https://cdn-images-1.medium.com/max/1024/1*Wdxy0xBiNUlpNdOA2tlcSg.png" /></figure><h4>TL,DR;</h4><p>Start with a monolith. Learn to recognise the patterns that indicate when you grow (reduce?) that into Microservices. Depending on your circumstances, that might still be straight away. It might also be never.</p><p>I was <a href="https://medium.com/@aleon1220/i-dont-know-anything-about-istio-but-to-me-it-sounds-like-another-layer-of-complexity-from-an-2c8f90ec3b72?source=post_page-----194b8475bdaa----------------------">recently contacted by someone</a> who’d been reading my my post about why we use the Istio Service Mesh in our Kubernetes platform. They’d made a really pertinent observation: Adding the complexity of Istio to the already complex Kubernetes feels like I really high cost for making it easier to run and co-exist versions of Microservices (co-existence being our use case for Istio). Why not just build a monolith instead and avoid all the complexity?, he asked. “That’s a really good question” I thought and one I have attempted to answer in the past but I think I should have another go.</p><p>At the same time, at <a href="http://www.wealthwizards.com/">Wealth Wizards</a>, we’ve been adopting the principles taught in the brilliant <a href="https://teamtopologies.com/">Team Topologies book</a> by Matthew Skelton and Manuel Pais. I’ve been promising to write something about our experiences to date with what actions we’ve taken from the learning. As I sat down to write the first, it stuck me that these are really the same post. The underlying subject is exactly the same, one helps deal with the consequences of the other.</p><h4>Always start with the WHY.</h4><p>Why are we using Microservices? Why didn’t that solve our problem?</p><p>@Wealth Wizards we’re building a SaaS platform which will allow us to provide regulated, automated financial advice to everyone, regardless of their circumstances. Financial wellness — which has a huge impact on mental health, should be available to everyone, from those with debt worries all the way through to those without a care in the world. Right now in this country it is typically the preserve of the wealthy — those who can afford to spend hundreds or thousands of pounds to know where they should best invest their money or how to use their pensions. There’s a lot to financial advice, many factors to take into account and literally millions of possible outcomes for given areas of advice — e.g mortgage, investment or retirement.</p><p>When we began our journey we had a handful of developers and we started out working on automating “at retirement” advice — what’s recognised as one of the most complicated and risk-laden areas. We started with a monolith. We had one problem to solve and two people working on solving it. With a monolith it’s (relatively) easy to know where the code is, how functions interact with each other and how and where to deploy the code.</p><p>With two developers it’s easy to co-ordinate work that’s taking place on that code base, what changes are occurring, why, and the expected outcome of those changes. There’s still a lot for two developers to consider — retirement advice is notoriously difficult to understand and get right. This is exactly why we started there — to prove that automating complex advice is possible.</p><p>As the product grew, along with ambitions and funding (or customers — depending on your business model) we needed to hire more developers “build faster!”. This meant more people having to co-ordinate around a code base. At four devs, we managed. Then it became necessary to start working on a new area of advice — a new product for us. We hired more people and made what turns out to be a good decision: we forked our code base. One team on Pensions, one on Retirement. Why was this good? Forking is often considered a Bad Thing(tm).<br> <br>By forking the code, we were able to reuse some of the first team’s learning but we were also able to give the new team independence from the existing product. We’d unwittingly reduced the cognitive load of each team — they each had one problem to worry about instead of two and there were fewer people to co-ordinate when working on each code base.</p><p>We continued in this mode for a while — building two separate products on two code bases. They functioned in a similar way — they were essentially twins but they slowly grew apart. Over time, our release frequency slowed. The products grew, along with the capabilities but each change became more complicated and with greater risk.</p><p>We had a funding round and wanted to grow more. We hired more devs, we decided to move to JS (node and react, full stack), microservices and kubernetes. It was the latest thing and microservices solve slow releases, right?</p><p>We started to decompose our monoliths. New functions were built as microservices and the teams started releasing more often. Kubernetes took care of the traditional deployment and scaling problems like load balancing, service discovery, etc. this carried on for a year or more. New product lines were started — investment advice, DB (“final salary” pensions) Transfer advice . Each time, a new, independent team.</p><p>Midway thought last year we ground to a halt. Releases were taking weeks, sometimes months, to appear and contained 10–15 microservices at a time. The platform we’d built had little ability to hand over from one type of advice to another — something an adviser would do seamlessly. I’m good at pointing out our worst faults but it truth, it wasn’t all bad. Some teams were still able to release frequently, but they were generally not working on “difficult advice” problems.</p><p>What had gone wrong? The truth was, it was hard to know. Conways law was itching at the back of my mind — “organisations design systems which mirror their own communication structure” and I had this memory that the real value of microservices lay in being able to model different functions in your business or process as independent functions (and ultimately teams owning those functions), not just in building small code bases which are “easy to reason with”. I also had a fear that we were no longer building a coherent platform as we liked to describe it, but different products using common technology.</p><p>At the same time as this, some of our teams started to recognise and complain about the number of things they were having to work on and importantly, to think about — we started to understand the term “cognitive load”. When you’re moving from one problem to another you often have to stop a moment and reset your brain, “load-up” the new problem and start again. This context switching is a real performance killer — anyone that’s worked closely with Operating Systems will know that CPU switches can be a performance killer — it’s a valuable performance metric for system administrators to follow, especially in older single-core CPUs. The teams started to recognise the affect that working on such a complicated set of problems was having on their cognitive load and that ultimately it was damaging their ability to code, refactor and solve problems quickly and efficiently.</p><p>I started to look back at some sales slide decks(!) and diagrams I’d been building of our systems to demonstrate to 3rd parties how we mapped our ‘Fin’ to our ‘Tech’. Slowly ideas started to form — could we map our micro services directly over these advice areas? We were close in many places but to date we’d taken an engineers approach to breaking down the system and the truth was, we weren’t domain experts.</p><p>A few of us had been aware of Matthew Skelton from talks he’d run in the past and so I happen to follow him on twitter. We’d been reading books like <a href="https://www.amazon.co.uk/dp/1491949880">Designing Delivery</a> and <a href="https://www.amazon.co.uk/Accelerate-Software-Performing-Technology-Organizations/dp/1942788339/">Accelerate</a> among others and getting great ideas about what seemed right but didn’t really know how to put it into practice. By some chance of fate it turned out that Matthew and Manual Pais had clearly also been thinking in depth about these problems (not specifically for our benefit, unfortunately) and were about to launch a <a href="https://teamtopologies.com/book">book</a> helping solve these problems.</p><p>We had to wait a few weeks — their timing was good, but not impeccable — so started to scan what they had available online. It made sense immediately — perhaps because our heads were already in the right context. When the book arrived I devoured the audio book. I quickly evangelised the book to the teams and encouraged them to get copies and learn.</p><p>Now we could form a model on how to solve not only our immediate cognitive load problems but also our potential scaling problems in future. The methods described in the book have been a huge help — recognising the different team patterns — enablement, complicated sub-system, platform services, value streams. We quickly identified the problems we were seeing and the most appropriate solutions to help us reduce cognitive load and deliver faster.</p><p>So far so good but we’re nowhere near done. Having these new patterns we’ve been able to take a step back from our platform and look at the functions and the microservices with a mind to how we _want_ them to work. What structure will give us not only the most cohesive yet decoupled platform alongside the highest performing empowered teams.</p><p>We’re really still at the beginning of our journey but Team Topologies and a Microservices approach — with the knowledge of _where_ we need to build boundaries, has given us the tools we were looking for and have helped us to build a plan and have confidence that we know where we’re going and how to get there.</p><p>I know there’s more to come in this thread. The whole process has stated me thinking about how we build truly empowered and engaged teams. This is no small challenge and has lead me down the path of “<a href="https://en.m.wikipedia.org/wiki/Teal_organisation">Teal Organisations</a>” — as proposed by <a href="https://en.m.wikipedia.org/wiki/Reinventing_Organizations">Frederic Laloux</a>. Definitely a topic for another post, in the future, when I know where we’re going. In the mean time. I’ll stop here but feel free to comment or ask questions if this sound familiar to you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8c3f967e63c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/to-monolith-or-to-microservice-f8c3f967e63c">To Monolith or to Microservice</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Istio IP Whitelists]]></title>
            <link>https://medium.com/ww-engineering/istio-ip-whitelists-1633acbd4205?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1633acbd4205</guid>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[service-mesh]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Wed, 12 Sep 2018 14:49:41 GMT</pubDate>
            <atom:updated>2019-03-13T08:03:11.275Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*68Q8bF-6Ge_ACNFvaqFQCA.png" /></figure><p>The Kubernetes Nginx ingress controller makes it really easy to enforce IP restrictions on a per ingress resource level. This means that for each of our services, we can provide fine-grained IP access controls. Something which is really important for us on a number of components.</p><p>As part of our process of adopting the Istio service mesh we’ve been looking to replicate this function in Istio. In the long run we’d like to migrate all ingress functions to Istio, but the IP whitelist is realy the first thing we’d like to move becuase it’s implemeneted as part of the ingress resource definitions and therefore we treat it as part of our application layer rather than infrastructure.</p><p>Unfortunatley documentation on this is very light and so having spent a good day or so trying to figure it out, having cracked it, I thought I’d share!</p><p>Unlike Kubernetes where the IP whitelist is managed as an annotation on the ingress resource and applied by the controller, Istio manages this type of behaviour as part of it’s policies and is distinct from the virtual service or gateways we have defined previously.</p><p>There are 3 parts to an Istio IP whitelist policy; a handler, an instance and finally a rule. The handler is implemented through an <a href="https://istio.io/docs/reference/config/policy-and-telemetry/adapters/">adapter</a>. The instance is implemented through a <a href="https://istio.io/docs/reference/config/policy-and-telemetry/templates/">template</a> and the rule is a <a href="https://istio.io/docs/reference/config/policy-and-telemetry/istio.policy.v1beta1/">rule</a>. I don’t know why there is this complication. It doesn’t make understanding it any easier. To add to the complication, one element which is described as most suitable for implementing an IP whitelist, a <a href="https://istio.io/docs/reference/config/policy-and-telemetry/adapters/list/">list</a> is actually referred to as a listchecker and you must use this term for it in the policies. Finally, it appears the IP_ADDRESS type is broken.</p><p>So, on with the policy. This is what you need:</p><p><strong>Handler</strong>; how should these be handled? i.e. whitelisted.</p><p>This is the list of IPs you wish to whitelist. You can easily turn this into a blacklist by switching “blacklist” to true. <br>the listchecker spec offers an IP_ADDRESSES type but it appears to be broken currently.</p><p>UPDATE:: Please see the comments below. Craig Skelton has reported that the docs are broken (which define IP_ADDRESS) but the add does support IP_ADDRESSES. I’ve not had a chance to validate this.</p><pre>--- <br>apiVersion: &quot;config.istio.io/v1alpha2&quot;<br>kind: listchecker<br>metadata:<br>  name: whitelist<br>spec:<br>  overrides: [ &quot;8.8.8.8&quot;, &quot;8.8.4.4&quot; ]  <br>  blacklist: false<br>---</pre><p><strong>Instance; </strong>on what instance of the data should the handler be applied?</p><p>Here we decide what part of the object we want to apply the handler too. In this case we’re going to use the http request header “x-real-ip” which is injected by the nginx ingress controller. We could use x-forwarded-for instead, but this header often has multiple IPs in it which makes the mathing more diffifult. The is also the option of source.ip but this value is typically managed by the routing in Kubernetes (If you’ve not come across it yet, kubernetes, by default, relies on a SNAT rule on each host. This makes any request entering a container appear to come from the Kubernetes host it’s running on.) this means unless you’ve setup your Kube clusters in what is currently a failry non-typical way, then the source.ip value is of little use.</p><pre>---<br>apiVersion: config.istio.io/v1alpha2<br>kind: listentry<br>metadata:<br>  name: x-real<br>spec:<br>  value: request.headers[&quot;x-real-ip&quot;]<br>---</pre><p><strong>Rule; </strong>When do we apply this rule and what do we plan on doing</p><p>In this instance we apply the rule to any traffic which matches ingressgateway in the Istio label field. We then specify the action and reference the handler and instances in DNS format. i.e. least significant element on the left.</p><pre>---<br>apiVersion: &quot;config.istio.io/v1alpha2&quot;<br>kind: rule<br>metadata:<br>  name: ip-rule<br>spec:<br>  match: source.labels[&quot;istio&quot;] == &quot;ingressgateway&quot;<br>  actions:<br>  - handler: whitelist.listchecker<br>    instances: <br>    - x-real.listentry<br>---</pre><p>Now apply these 3 policies to the namespace where the services reside and you should find whitelisting is applied. It actually takes a few seconds to apply, and is intermittent initially.</p><p>Havng finaly figured out how to do this, we’ve decided we’re not going to use it yet. The main reason being that the response back to the client is not great. Instead of a 403 the client recives a 404 with a message saying they don’t match the istio whitelist. Not really what we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*m263tc07AqApShMI3qcS9g.jpeg" /></figure><p>There is an alternative way of applying white lists which is described <a href="https://groups.google.com/forum/#!msg/istio-users/TjenvxWXJI4/FQTeh6v9AAAJ;context-place=forum/istio-users">here</a> but it’s also not very elegant but it does at least provide a better response to the client in so far as it’s a 403.</p><pre>apiVersion: &quot;config.istio.io/v1alpha2&quot;<br>kind: denier<br>metadata:<br>  name: denyreviewsv3handler<br>spec:<br>  status:<br>    code: 7<br>    message: Not allowed<br>---<br>apiVersion: &quot;config.istio.io/v1alpha2&quot;<br>kind: checknothing<br>metadata:<br>  name: denyreviewsv3request<br>spec:<br>---<br>apiVersion: &quot;config.istio.io/v1alpha2&quot;<br>kind: rule<br>metadata:<br>  name: denyreviewsv3<br>spec:<br>  match: source.ip != ip(&quot;192.168.0.1&quot;)<br>  actions:<br>  - handler: denyreviewsv3handler.denier<br>    instances: [ denyreviewsv3request.checknothing ]</pre><p>We’ll keep an eye out for imporvements in this area but it certainly feels rather immature at present.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1633acbd4205" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/istio-ip-whitelists-1633acbd4205">Istio IP Whitelists</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Istio, Part III, why use it?]]></title>
            <link>https://medium.com/ww-engineering/istio-iii-why-use-it-2ba2500cceda?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ba2500cceda</guid>
            <category><![CDATA[build-pipeline]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[service-mesh]]></category>
            <category><![CDATA[istio]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Wed, 12 Sep 2018 13:40:29 GMT</pubDate>
            <atom:updated>2019-07-15T09:52:07.020Z</atom:updated>
            <content:encoded><![CDATA[<p>In my<a href="https://medium.com/ww-engineering/istio-part-ii-e219a2e771bb"> last post</a> I covered how we are installing Istio into our Kubernetes platform. Here I want to cover the problem we’re trying to solve and how Istio helps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*s8HtjtekFB50bfzmU8HO0g.jpeg" /></figure><p>To date Kubernetes has really helped us build an advanced, relatively low-maintenance, autoscaling platform which is ideally suited to supporting a microservice architecture like we have. It’s also ideal for providing a self-serve, developer friendly workspace.</p><p>We’ve made use of Kubernetes namespaces to host our different build stages, e.g. development test, staging, production as well as our multiple tenant configurations giving us three namespaces per tenant. This has worked well to date but we’re increasingly finding that we’re being constrained to a single path to live for any given change. If we have one large change which gets blocked for whatever reason, and that can be the subject of a whole set of ways to work (better) discussions, then we end up clogging-up the whole pathway to live.</p><p>What we’re looking for is the ability to make a change or add a feature and then have a customer accept that change, before we commit it to master. In a monolithic system this is pretty straight forward, just spin up a monolith branch and test it. It’s much more complicated with microservices as theres a whole plethora of components which need to be started and co-ordinated. Before we go any further, yes we are trying to address this problem though TDD, more effective ACs, etc. but in the mean time, if we can solve a problem quickly with thech, we should try it.</p><p>One solution for us would be to clone a namespace, which is relatively straight-forward and deploy the change into the cloned space. While there are some complexities to this soluton, the real issue is simply the cost and scale of the environment we end up with. One of our tenant namespaces has ~ 60 microservices. The cost of cloning that, just so that we accept a change to a single element is large, not just from the management but also from the underlying compute. We may have 10 changes in flight at a time. That’s a lot of microservices deployed!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*AbZMjp40oBSm3XtMGNBohg.png" /></figure><p>Our proposed alternative is to make use of Istio to provide an intelligent routing overlay instead. We will maintain one namespace for development and then build and deploy a feature branch of a component into the namespace, alongside the master version. We’ll then use istio to ensure any request which wants to reach the new feature reaches the feature component(s), while routing all other requests thorugh the “master” components.</p><p>The idea is to make use of Istio VirtualServices and DestinationRules and have Istio switch the path of the request to reach a branch instance, based on a header in the request.</p><p>The Istio definitions are:</p><p><strong>Gateway</strong>; loosely equivalent to a virtual host definition in Apache (you all remember apache, right? ) and covers some of what we do with a Kubernetes ingress resource. It tells Istio to accept requests for a given host:port combination into the mesh. This example uses a wildcard host to keep the PoC quick. We would normally generate TLS certs and setup DNS and specify the correct hostname here to limit what this gateway is going to accept.</p><pre><br>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: Gateway<br>metadata:<br>  name: gateway-its<br>  namespace: istio-test<br>spec:<br>  selector:<br>    istio: ingressgateway<br>  servers:<br>  - port:<br>      number: 80<br>      name: http<br>      protocol: HTTP<br>    hosts:<br>    - &quot;*&quot; # Serve all hostnames from here until we have DNS and TLS certs configured<br>---</pre><p><strong>VirtualService</strong>; the magic happens here! The virtual service is also has a lot of crossover with the ingress resource in kube and similar to the “location” directive in Apache. It’s here that we apply the routing logic.</p><p>If a request contains a header, requesting a particular feature branch, then send that request to a pod with a matching “subset”, otherwise send it to the default, master pod.</p><pre>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: income-tax-service<br>  namespace: istio-test<br>spec:<br>  hosts:<br>  - income-tax-service.istio-test.svc.cluster.local<br>  gateways:<br>   - mesh<br>  http:<br>  - match:<br>    - headers: <br>        x-branch-id: <br>          exact: FEAT-1234<br>    route:<br>    - destination:<br>        host: income-tax-service<br>        subset: FEAT-1234<br>  - route:<br>    - destination:<br>        host: income-tax-service<br>        subset: master<br>---</pre><p><strong>DestinationRule</strong>; used to map the subsets to actual pods by using the version label with the pod. <a href="https://istio.io/docs/setup/kubernetes/spec-requirements/">Istio requires</a> your deployments to provide the “app” and “version” labels. We’d have preferred to use the term “variant” instead of version but such is life :) <br>Something that I found slightly odd to get used to in Istio is that all variants of a pod are reached via the same Kubernetes service. This would mean that if you have 2 variants of an application deployed as 2 pods then if you access the Kube service directly (and anything which doesn’t have the Istio proxy in it will do this) then your request will be round-robined between the different variants becuase kube is unaware of the additional layer of logic. It makes total sense given how Istio works, it just takes a bit of adjusting to and it means that you need to carefully stage your migration to using Istio on an existing system.</p><pre>---<br>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: income-tax-service<br>  namespace: istio-test<br>spec:<br>  host: income-tax-service<br>  subsets:<br>  - name: master<br>    labels:<br>      version: master<br>  - name: FEAT-1234<br>    labels:<br>      version: FEAT-1234<br>---</pre><p>To ground this to standard Kubernetes, the income-tax-service deployments and service are defined like so:</p><pre>---<br>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: income-tax-service--master<br>  annotations:<br>  labels:<br>    app: income-tax-service<br>  namespace: istio-test<br>spec:<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: income-tax-service<br>        version: master<br>    spec:<br>      containers:<br>        name: income-tax-service<br>        image: income-tax-service:latest<br>        imagePullPolicy: IfNotPresent<br>        ports:<br>        - containerPort: 80<br>---<br>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: income-tax-service--feat-1234<br>  annotations:<br>  labels:<br>    app: income-tax-service<br>  namespace: istio-test<br>spec:<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: income-tax-service<br>        version: feat-1234<br>    spec:<br>      containers:<br>        name: income-tax-service<br>        image: income-tax-service:FEAT-1234<br>        imagePullPolicy: IfNotPresent<br>        ports:<br>        - containerPort: 80</pre><pre>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  namespace: istio-test<br>  name: income-tax-service<br>  labels:<br>    app: income-tax-service<br>spec:<br>  ports:<br>  - name: http<br>    port: 80<br>    targetPort: 80<br>  selector:<br>    app: income-tax-service<br>---</pre><p>So, once we’ve done all this what have we gained? I think of it like this; we once had a single path to production. Anything than broke on that path blocked it and prevented anything else from passing. By making use of Istio we now have a multilane highway. If one lane gets blocked, it’s easy to keep moving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*1Ham7pTJp8Av2pmAGiDy5g.jpeg" /></figure><p>In my<a href="https://medium.com/ww-engineering/istio-ip-whitelists-1633acbd4205"> next post</a>, I’ll cover how to apply IP white lists in Istio.</p><p>I’ve now moved to a new role and I’m a lot less involved in our work on Istio. My colleagues, Dave, Pierre and Ionut have taken on most of this now. Dave’s done some follow up posts and recently spoke at KubeConf in Barcelona. <a href="https://medium.com/ww-engineering/unblocking-our-release-train-with-istio-traffic-management-42206f7f8376?source=collection_home---4------0-----------------------">Unblocking our release train with Istio traffic management</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ba2500cceda" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/istio-iii-why-use-it-2ba2500cceda">Istio, Part III, why use it?</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Istio, Part II]]></title>
            <link>https://medium.com/ww-engineering/istio-part-ii-e219a2e771bb?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e219a2e771bb</guid>
            <category><![CDATA[service-mesh]]></category>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Wed, 12 Sep 2018 09:04:53 GMT</pubDate>
            <atom:updated>2019-01-28T10:14:20.423Z</atom:updated>
            <content:encoded><![CDATA[<p>You could read that as part 2, but in truth it feels more like part 11!</p><p>Back in June I <a href="https://medium.com/@richard.marshall_58248/starting-with-istio-610421f5a815">wrote a post</a> describing why we’d finally started to look at bringning Istio into our kubernetes platform. The long-and-short of it is that it didn’t happen. Other things took over and learning how to integrate Istio into a running platform took some serious headspace.</p><p>So here I am, 4 months later and I’m pleased to say that we’re now much closer to it happening and for a different reason.</p><p>In June, we tried Istio using the version 0.7 release, only to see it replaced soon after by 0.8. We’re now at 1.0.2 and things have come on rapidly but istio seems to be creeping closer to maturity which is great news. It does mean though that a lot of what I learned about Istio in June had to be forgotten and it was better to start from a clean sheet. That applies to both installing it and running it.</p><p>Installing Istio 1.0 is pretty straight forward. The maintainers have adopted Helm templates, and while we’re not using Helm + Tiller internally, we can use helm to generate “traditional” k8s yaml files and install from there which works well for us. The istio site documents this process and it’s pretty painless.</p><p>We’ve opted to install and use Istio across a number of namespaces, which the installer partially supports. This is what we’ve done, why and how.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*6wulujCw5iUHR6b3uullaA.png" /></figure><p>We run applications in a number of isolated (via network-policies) namespaces and want to keep web traffic away from the Istio control channel. To address this, we’ve deployed both a kubernetes nginx ingress controller and an Istio ingress gateway into a stand-alone namespace with the remainder of the Istio components in the default “istio-system” namespace. The helm templates support not defining an ingress gateway easy (and therefore the build of the istio-system namespace as we want it) but they don’t offer the ability to only define an ingress gateway and link it to the istio control plane.</p><p>To make this work for us, based on the <a href="https://istio.io/docs/setup/kubernetes/helm-install/#option-1-install-with-helm-via-helm-template">how-to from istio</a> we’ve done the following:</p><pre>## Generate a &quot;complete&quot; definition, including the ingress gateway</pre><pre>helm template install/kubernetes/helm/istio --name istio --namespace istio-system \<br># We don&#39;t want to use egress gateways, yet. <br>  --set gateways.istio-egressgateway.enabled=false \<br># We want an ingress gateway, but not exposed publically.<br>  --set gateways.istio-ingressgateway.type=ClusterIP \<br># We need to deinfe cluster IP boundaries so pods can egress<br>  --set global.proxy.includeIPRanges=&quot;10.0.0.0/8&quot; \  <br>  &gt; istio-full.yaml</pre><pre>## Generate a &quot;control&quot; definition, without the ingress gateway</pre><pre>helm template install/kubernetes/helm/istio --name istio --namespace istio-system \<br>  --set gateways.istio-egressgateway.enabled=false \<br>  --set gateways.istio-ingressgateway.enabled=false \<br>  &gt; istio-system.yaml</pre><pre>## Diff the two files to end up with only the ingress gateway definitions, then update the definitions so the gateway can find the control plane, etc.</pre><pre>diff --normal istio-full.yaml istio-system.yaml | grep &quot;&lt;&quot; | \<br>sed -e &quot;s/&lt; //&quot; \<br> -e &quot;s/namespace: istio-system/namespace: ingress/&quot; \<br> -e &quot;s/istio-pilot:8080/istio-pilot.istio-system.svc.cluster.local:8080/&quot; \<br> -e &quot;s/zipkin:9411/zipkin.istio-system.svc.cluster.local:9411/&quot;\<br> -e &quot;s/istio-statsd-prom-bridge:9125/istio-statsd-prom-bridge.istio-system.svc.cluster.local:9125/&quot;\<br> -e &quot;/nodePort/d&quot;\<br> &gt; istio-ingress.yaml</pre><pre># Now apply the files, as per the how-to docs:<br>kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml<br>kubectl apply -f istio-system.yaml -n istio-system<br>kubectl apply -f istio-ingress.yaml -n ingress</pre><p>You should now, or at least soon, have your ingress gatwate way deployed into a seperate “DMZ” namespace with the remainder of Istio system deployed into the istio-system naemspace.</p><p>In addition to this, we deploy a standard nginx ingress controller into the ingress namespace to accept the incoming public connections, then use an ingress resource to forward al requests into the istio ingress gateway, where the service mesh takes over traffic.</p><p>Deploying the ingress controller and default backend are both straight forward. The more interesting parts are the service and ingress definitions:</p><pre>---<br>kind: Service<br>apiVersion: v1<br>metadata:<br>  name: nginx-ingress<br>  namespace: ingress<br>  annotations:<br>    service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb&quot;<br>spec:<br>  externalTrafficPolicy: Local<br>  selector:<br>    name: nginx-ingress<br>  ports:<br>  - name: https<br>    port: 443<br>    protocol: TCP<br>    targetPort: 443<br>  - name: http<br>    port: 80<br>    protocol: TCP<br>    targetPort: 80<br>  type: LoadBalancer</pre><pre>---</pre><pre>apiVersion: extensions/v1beta1<br>kind: Ingress<br>metadata:<br>  annotations:<br>  name: istio<br>  namespace: ingress<br>spec:<br>  rules:<br>  - http:<br>      paths:<br>      - backend:<br>          serviceName: istio-ingressgateway<br>          servicePort: 80<br>        path: /<br>---</pre><p>Why do we use an nginx controller instead of serving straight from the istio ingress gateway?</p><p>Right now Istio ingress is still pretty young and it doesn’t have the features we want. In fact we find that most kube ingress controller don’t offer the features we currently need.</p><p>At present we use the ngin ingress controllers to add/remove/dynamicaly updates headers, use the kube ingress rules to add IP whitelist restrictions, etc. While there is support for some of these things in Istio it’s more comlpicated and not as mature, so right now we’re going to adopt a two-tier approach.</p><p>The final step to building the mesh is to enable sidecar injection in a namespace. This means that each time a pod is deployed, kubernetes will transparently inject the istio proxy sidecar and bring the pod “on-mesh” Without this, istio can’t really help. Fortunatly this step is easy:</p><pre>kubectl label namespace [application-namespace] istio-injection=enabled</pre><p>There may be pods where you <strong>don’t</strong> want the sidecar injected, for example the nginx ingress controller, becuase you want it to sit outside the mesh. Fortunately, this is simple, and just requires an annotation on the pod/deployment. e.g.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  annotations:<br>    sidecar.istio.io/inject: &quot;false&quot;</pre><p>Now we have a working istio service mesh deployed, we want to start making use of it. <a href="https://medium.com/ww-engineering/istio-iii-why-use-it-2ba2500cceda">In my next pos</a>t, I’ll cover what problem we’re trying to solve and how we’re going about it. I also cover whitelisting <a href="https://medium.com/ww-engineering/istio-ip-whitelists-1633acbd4205">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e219a2e771bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/istio-part-ii-e219a2e771bb">Istio, Part II</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kube-Native or Kube-Lite?]]></title>
            <link>https://medium.com/ww-engineering/kube-native-or-kube-lite-1934f248171a?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1934f248171a</guid>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Tue, 28 Aug 2018 08:17:30 GMT</pubDate>
            <atom:updated>2018-08-28T10:05:28.201Z</atom:updated>
            <content:encoded><![CDATA[<p>Kube’s been around for a while now and the eco-system continues to evolve at an accelerating rate. I’m increasingly seeing the term kube-native but what does this really mean? This is my take on it:</p><p>Kube-lite: I’m starting to think that what we’ve been doing to date is really “kube-lite”. I see this as being taking an traditional infrastrucutre and deploying it on top of kubernetes to take advantage of it’s scaling and scheduling benefits. This is akin to the mass migration to virtualisation (primarily VMWare) that many of us saw ~10 years ago. Infact, I really see the current trend of large institutions adopting kube as being the logical next-step of that virtualisation migration we saw.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UQZBZdbGA3MViuVV36k9_A.png" /></figure><p>To date, we’ve taken our PHP monolith and deployed it inside a container and built-out a number of microservices around this, decomposing the functionality one opportunity at a time. Now we have 50–60 microservices that actually make-up the majority of our stack. However what makes it kube-lite is the fact that we’re still treating kube as just being a smart virtualisation layer. We’re very loosely coupled to kube and we could quite easily (I mean a few weeks platform engineering, at most) to move the whole stack to any other means of running code, e.g. even as bare metal.</p><p>So if kube-lite is just running apps in containers on kube, what’s kube-native?</p><p>The rapidly maturing kube eco-system has led to some significant frameworks arriving. I think the most important I’ve seen so far is <a href="https://istio.io/">Istio</a> (though of course there are other ways of implementing what it does — a service mesh, such as <a href="https://linkerd.io/">linkerd</a>). Istio has taken existing tools e.g. as <a href="https://www.envoyproxy.io/">envoy</a> and wrapped them in a way that integrates very neatly with kube. Kube, in combination with tools like Istio allow you to go full kube-native.</p><p>What I mean by this is taking lots of common elements from your microservices and pushing them down into the platform. With kube-native, your applications no longer need to deal with this like trust, routing (in the form of the embedded express, for example) encryption, etc. Instead all these functions are pushed down into the platform, allowing developers to concentrate on writing the functions they need to deliver products instead of having to deal with lots of boiler-plate functionality. If this sounds like serverless to you, then we’re in agreement.</p><p>We’ve not really been using serverless, e.g. AWS Lambda, here at Wealth Wizards yet. It’s something developers are increasingly asking for and so we’ve started to look at and in so doing we’re increasing seeing the overlap between Serverless and what we understand to be kube-native.</p><p>The question is now: what’s the best option for us to implement the delivery of functions? Go “serverless” and make use of a vendor solution like AWS Lambda or Google Functions and commit to a vendor or remain ‘vendor-neutral’ and implement functions as kube-native using a second framework such as <a href="https://github.com/knative">knative</a> (pronounced “k-native”, rather than the far more satisfying “native”) or <a href="https://fission.io/">fission.io</a>?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1934f248171a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/kube-native-or-kube-lite-1934f248171a">Kube-Native or Kube-Lite?</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Starting with Istio]]></title>
            <link>https://medium.com/ww-engineering/starting-with-istio-610421f5a815?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/610421f5a815</guid>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[service-mesh]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Tue, 12 Jun 2018 14:36:31 GMT</pubDate>
            <atom:updated>2019-04-29T07:24:14.894Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*dUicApZ3r8_rxc05JhLtjA.png" /></figure><p>We’ve been talking about using Istio for nearly a year now. Digging into a recurring problem has now given us the excuse we’ve been looking for to get started with it.</p><p>Our apps each expose a “health” endpoint. This is really just a smoke-test to confirm that all the things the app relies on are available to it. E.g. downstream web APIs, databases, etc. request to /health will return a JSON payload and a relevant HTTP response code. The payload wil tell us what is or isn’t available and is therefore going to lead to a failed request.</p><p>Overtime we’ve seen these health checks flap and we often struggle to find what the cause for a given flap was. The downstream dependencies all appear to be healthy and show no signs of being failed (ocassionally we _will_ see a cascade of failures and know which one is the root is difficult, but that’s for another time).</p><p>We’re increasingly coming to suspect that a number of these health failures lie within the kubernetes networking subsystem. The kube proxy mechanism is a clever manipulation of IP tables to effectivly provide a cluster-wide, host neutral IP address to serve your kubernetes services from. This is part of the magic of Kubernetes and it’s what allows us as consumers of the kube service to worry less about where something is running. The problem we’re seeing suggests the loss of a request packet somewhere within the system. the kube proxy doesn’t provide a level of logging that helps us solve the problem and so we were a little stumped about where to go next.</p><p>We’re already making use of the weave network overlay within kube and so my first port of call was to see if any of the weave community has seen something similar or could suggest some answers. The reply I got was to use an application proxy which would handle things like retry requests. We’re already use nginx as an app proxy within the cluster in the role of ingress controller and while this does offer retriesm the ingress controller is really concerned about traffic coming into the cluster from without, or North-South traffic as it’s often called. We were seeing problems with traffic which was essentially already within the cluster, which is referred to as East-West. The folks on the weave slack channel offered Envoy as a possible solution. It’s a small light-weight application proxy which is finding friends with the kube community and this is where Istio comes in.</p><p>Istio is a “Service mesh” which makes use of the envoy proxy, building on it to provide a system-aware application layer within the cluster. Istio provides a control plane within the cluster and installs an envoy proxy into each application pod as a side car. By default, envoy will intercept all traffic into and out of a pod. Communication between the control plane and the proxies provides Istio with a network traffic view of what’s happening within the cluster but it also provides the operator with the ability to control how traffic flows within the cluster. It also allows us to wrap a futher layer of security around the traffic within the cluster by establishing TLS tunnels between each pod for communication, should you wish.</p><p>Further to this, because Istio deploys a traffic-intercepting agent into each pod it in the ideal location to understand where requests are failing, taking too long, etc. By sending these metrics to an external tool such as Zipkin or Jagaer, we’re able to built charts displaying how the services communicate with each other as well as where delays are occuring within the system.</p><p>In our scenario the benefits are wide ranging, without putting much effort into our Istio configuration we’re able to gain visibility and improved reliability as well as an opportunity to improve the security of the system as well as open up whole new paths of traffic management and application deployment options.</p><p>What does Istio add on top of kube? kubernetes is concerned about making sure your applications get deployed and are available on a relatively coarse-grained level. Sure, it’ll make sure you have the number of pods that you asked for, and it’ll take care of turning a pretty complex distribution and scaling problem into a simple declerative command but it’s much less concerned about your traffic on a request-by-request level and this is where Istio (other service meshes also available, please see linkerD, for example) steps in. In many ways it’s sits in a similar role to a traditional layer-7 loadbalancer (think F5) it’ less concerned about what traffic is coming into your cluster and more interested in what’s happeing within the cluster.</p><p>In part II I’ll cover what steps we’ve had to go through to install Istio, and the issues we found in doing so!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=610421f5a815" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/starting-with-istio-610421f5a815">Starting with Istio</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K8s, WS, AWS, ELB & NLB]]></title>
            <link>https://medium.com/ww-engineering/k8s-ws-aws-elb-nlb-5a23834d4f14?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a23834d4f14</guid>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Tue, 01 May 2018 14:22:19 GMT</pubDate>
            <atom:updated>2018-05-01T14:51:07.774Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Piq3et4lmoO8ZmU4YDAByQ.jpeg" /></figure><p>That’s a lot of acronyms!</p><p>We’ve been running our kube clusters in AWS for a couple of years now. Over that time we’ve progressed from using an ELB loadbalancer service per pod (simple but expensive!) on to using an nginx ingress controller with an ELB (for TLS termination duties) with a wildcard DNS record to get us there.</p><p>This has worked pretty well for us, but there have been some disadvantages, the most significant for us has been the lack of support for websockets on the ELB. I’ve spoken with a few people who say they have this working but we have failed to achieve it.</p><p>Since the release of kubernetes 1.9 and <a href="https://aws.amazon.com/elasticloadbalancing/">AWS Network Load Balancers</a> ( a pure layer-4 load balancer) we now have another approach to delivering websocket support. This has come just as we start to write a chatbot which is going to need it.</p><p>However adopting this technology introduces new challenges for us to solve.</p><p>Presently we use the Amazon ELB to terminate TLS connections and to inject header information, to provide us with real-ip info, for example. A benefit of having the ELB handle TLS offload is that we’re able to utilise AWS free certificates, managed through <a href="https://aws.amazon.com/certificate-manager/">ACM</a>. Unfortunately, AWS NLB do not offer TLS termination and so we need to handle this on our Ingress Controllers. The good news for us is that the kube nginx ingress controller already supports <a href="https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/tls.md">TLS termination</a>, along with <a href="https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/miscellaneous.md#websockets">websocket support</a>, we just have to make use of it.</p><p>While we’re keen to make use of websockets on our platform, Kube support for AWS NLB is still in alpha, so we’re taking this with a gently, gently approach.</p><p>Step 1:<br>Offer NLB load balancers alongside our existing ELBs</p><p>Step 2:<br>Update our ingress controllers to serve requests from both the ELB and NLB</p><p>Step 3:<br>Provide TLS termination on the ingress controllers</p><p>Step 4:<br>Productionise the above.</p><p><strong>Step 1</strong></p><p>This is actually pretty simple:<br>We currently deploy our ELBs using a pretty simple script and templates to provision and ELB, with appropriate ACM certificates assigned for each namespace.</p><pre>kind: Service<br>apiVersion: v1<br>metadata:<br>  name: nginx-ingress<br>  namespace: ${namespace}<br>  annotations:<br>    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: &quot;arn:aws:acm:eu-west-1:{account}:certificate/${cert-id}&quot;<br>    service.beta.kubernetes.io/aws-load-balancer-ssl-negotiation-policy: &quot;ELBSecurityPolicy-TLS-1-2-2017-01&quot;<br>    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: &quot;http&quot;<br>    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: &quot;443&quot;<br>spec:<br>  selector:<br>    name: nginx-ingress<br>  ports:<br>  - protocol: TCP<br>    name: https<br>    port: 443<br>    targetPort: 80<br>  - protocol: TCP<br>    name: http<br>    port: 80<br>    targetPort: 80<br>  type: LoadBalancer</pre><p>In order to provision an NLB, we simple create a similar template file for the NLB loadbalancer.</p><pre>kind: Service<br>apiVersion: v1<br>metadata:<br>  name: nginx-ingress-nlb<br>  annotations:<br>    service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb&quot;<br>spec:<br>  loadBalancerSourceRanges:<br>    - &quot;1.2.3.4/24&quot;<br>  externalTrafficPolicy: Local<br>  selector:<br>    name: nginx-ingress<br>  ports:<br>  - name: https<br>    port: 443<br>    protocol: TCP<br>    targetPort: 443<br>  type: LoadBalancer</pre><p>Note that the NLB only has port 443 defined: there’s <a href="https://github.com/kubernetes/kubernetes/issues/56703">currently a bug in kube</a> preventing the use of more than 1 port.</p><pre>externalTrafficPolicy: [Local|Cluster]</pre><p>It’s worth taking some time to read up and try and understand this value. The simple answer is that Local passes the client real-ip through to the apps, but may lead to less effective load distribution across your nodes (If I’ve understood it correctly!)</p><p>These services can co-exist in the same namespace. We just create a DNS entry for each Service and depending on what feature your require (i.e. websocket support) you use the appropriate DNS name.</p><p>e.g. if you want to access a websocket service use [service].ws.[namespace].ww.io. If you don’t need websockets, use [service].[namespace].ww.io.</p><p>Clearly this is a little redundant at the moment, Thanks to our use of ingress controllers, the service is available via either load balancer, it’s just websockets will only work through the NLB. Once we’re up to speed, and support is better than alpha, it’s likely we’ll drop the ELBs and only use NLB.</p><p><strong>Step 2</strong>:</p><p>The <a href="https://github.com/kubernetes/ingress-nginx">nginx ingress controllers</a> are proving to be extremely flexible for us. They support websockets and per-ingress resource TLS out of the box.</p><p>The few changes we’ve made are to increase the proxy read and proxy send timeouts from 60s to 3600s to better support long lived connections. Other than that, the SSL support is handled “natively” within the ingress resource definitions.</p><p><strong>Step 3</strong>:</p><p>Nginx ingress controllers already have <a href="https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/tls.md">really good support for TLS</a>, both as a default and at per ingress level. In the long-run we’re likely to move to using a common cert with multiple SANs and use the default option. However in the mean time it’s easier for us to define it at a per ingress level. To do this first create an certificate. Unfortunatly, we’re not able to make use of AWS ACM here, but <a href="https://letsencrypt.org/">Let’s Encrypt</a> is a great option and should be supported! Let’s encrypt is really intended to be used to be used as part of an automated process and <a href="https://wealthwizards.atlassian.net/wiki/spaces/REM/pages/341016635/Kube-Lego">kube-lego</a> appears to be a great way to introduce this into kube. It’s already <a href="https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/tls.md#automated-certificate-management-with-kube-lego">supported by the nginx ingress controllers</a> too.</p><p>However, for the sake of the PoC we’ll manually create a cert. Fortunately <a href="https://gethttpsforfree.com/">gethttpsforfree</a> is a great way of using let’s encrypt manually for these moments. Follow the instructions there to get a cert set and then add it to to kube using a TLS secret. This is also really simple!</p><pre>kubectl create secret tls nlb-tls-cert --key nlb-tls-cert.key --cert nlb-tls-cert.crt</pre><p>Once the secret has been defined, it’s trivial to define an ingress resource to make use of this cert:</p><pre>apiVersion: v1<br>items:<br>- apiVersion: extensions/v1beta1<br>  kind: Ingress<br>  metadata:<br>    name: websocket-example<br>  spec:<br>    rules:<br>    - host: websocket-example.demo.wizards.io<br>      http:<br>        paths:<br>        - backend:<br>            serviceName: websocket-example<br>            servicePort: 80<br>          path: /<br>    tls:<br>    - hosts:<br>      - websocket-example.demo.wizards.io<br>      secretName: nlb-tls-cert</pre><p>The great thing here is that the ingress resource is almost identical to our existing definitions. There’s just the addition of the last 4 lines, and there are no surprises in there, just the hostname it’s serving (which should match the host in the rules) and a reference to the secret we just created.</p><p>It should be possible to define this for all ingress resources, even if we’re not actually using the TLS component at this point.</p><p><strong>Step 4</strong></p><p>So, what’s needed to make this production ready?</p><ul><li>It’s still “alpha” within the kube code base, so wait until it’s past that before we even consider dropping our ELBs.</li><li>We’re already run into one of the known bugs, so we’ll take it easy for the time being!</li><li>AWS ACM was great becuase it managed all key rotation. We can replace that with Let’s encrypt and Kube-lego but we have to work through that and make it happen.</li><li>We need to ensure we’ve got the right TLS ciphers setup on the controllers, but this is perhaps easier now than it was on ELB as we have more control over it.</li><li>Ingress resources need to have the TLS definitions, or we have TLS on by default.</li><li>This means populating a TLS secret in each name space. No biggie, see above.</li><li>We don’t use ELB access logging so there’s no loss there.</li><li>A websocket app needs to have some way be share state across multiple instances. It’s beyond the scope of this problem, but should be considered.</li></ul><p><a href="https://aws.amazon.com/blogs/opensource/network-load-balancer-support-in-kubernetes-1-9/">This article</a> was a big help in getting the PoC up and running</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a23834d4f14" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/k8s-ws-aws-elb-nlb-5a23834d4f14">K8s, WS, AWS, ELB &amp; NLB</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Backups Are Fun!]]></title>
            <link>https://medium.com/ww-engineering/backups-are-fun-b91f17dccc8e?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b91f17dccc8e</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[backup]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Sat, 28 Apr 2018 12:49:36 GMT</pubDate>
            <atom:updated>2018-05-01T14:41:27.346Z</atom:updated>
            <content:encoded><![CDATA[<p>Ok, so they’re not actually fun, but in a rather perverse way I’ve rather enjoyed my last week working on them.</p><p>For a while now we’ve had a couple of items on our backlog that we’ve been mostly pretending aren’t there becuase they say “backup”. We already firedrill our backups on a monthly basis but we were finding too often that a backup had failed to complete correctly, leaving the backup in an unhealthy state.</p><p>We were also starting to build up quite a collection of historical backups. Part of a belt-and-braces approach to the retention policy (and acceptable at the time with backup files small enough.)</p><p>This led to these two tasks being raised: “Implement new backup policy”: — thank you GDPR for ensuring this was required and “Backup Visibility”. You can see why we were falling over each other to be the one to pick them up.</p><p>We persist all our data in MongoDB, so our backup process really only concerns MongoDB at this point. To date we’d been using a slightly modified container found in GitHub. Essentially, the container is a cron process which triggers a MongoDB client to list the databases, backup each one and then hand-over to S3cmd.</p><p>S3cmd would then encrypt each backup file and push it up to S3, where it was stored until needed. The S3 buckets also encrypt-at-rest so we’re pretty happy with the degree of protection afforded to the data in these backups.</p><p>The container runs inside Kube and this is where our reliability problem started. The backup, encrypt, push-to-S3 process appeared to be memory hungry and this was causing the host OS to kill the container at the most critical moment; i.e. when the backup was taking place.</p><p>This was resolved by putting some memory and cpu limits (we already had requests in there) on the pod. It turns out that while the process would happily consume gobs of memory, it didn’t need to in order to run and it’s actually happy with ~500MB.</p><p>So, original problem solved but we still need to address visibility and policy. Yawn.</p><p>Let’s start with policy. We push the encrypted backups to S3 which already has a pretty cool (ok, nerd cool,) lifecycle policy feature. This allows us to determine the retention policy for objects and discard them at the appropriate point. This is exactly what we need to implement our backup policy!</p><p>In order to get it to work with our backups we needed to name the backups with something the S3 lifecycle could use, either S3 tags or file paths. The backup container only date-stamped the files. This works fine when you want all files to be deleted after say 14 days (fine in a dev environment, for example). To meet our backup policy, we needed different retention periods; 9 days for “daily” backups, 40 days for weekly, etc, etc.</p><p>To achieve this, we put a little logic in to the script</p><pre># Start with a default &quot;daily&quot; path and update this to something more specific if the date logic matches</pre><pre>POLICY_CYCLE=daily</pre><pre># Check if it’s a Monday</pre><pre>WEEKDAY=\$(date +\%A)<br>case \$WEEKDAY in<br> “Monday”)<br> POLICY_CYCLE=weekly<br> ;;<br>esac</pre><pre># Check if it’s the first of the month and assign cycle accordingly (and over-ride weekly, it Monday is the first of the month)</pre><pre>DAYMONTH=\$(date +\%m.\%B)<br>case \$DAYMONTH in <br> “01.January”)<br> POLICY_CYCLE=yearly<br> ;;<br> “01.April”|”01.July”|”01.October”)<br> POLICY_CYCLE=quarterly<br> ;; “01.January”|”01.March”|”01.May”|”01.June”|”01.June”|”01.September”|”01.November”|”01.December”)<br> POLICY_CYCLE=monthly<br> ;;<br>esac</pre><p>Sure, this could be formatted more neatly but we now have a POLICY_CYCLE variable which allows us to label each backup file with the appropriate label in order to apply a life-cycle policy to it. <br>We’ve decided to take the approach of using the POLICY_CYCLE to define the path of the backup file.</p><p>Now we can apply a simple lifecycle policy to the S3 bucket, and henceforth S3 will deal with the retention of our backups and also moving them into cheaper long-term glacier storage! Super cool! (again if you’re a nerd, like me.)</p><pre>{<br>    &quot;Rules&quot;: [<br>        {<br>            &quot;Status&quot;: &quot;Enabled&quot;, <br>            &quot;NoncurrentVersionExpiration&quot;: {<br>                &quot;NoncurrentDays&quot;: 9<br>            }, <br>            &quot;Filter&quot;: {<br>                &quot;Prefix&quot;: &quot;daily/&quot;<br>            }, <br>            &quot;Expiration&quot;: {<br>                &quot;Days&quot;: 9<br>            }, <br>            &quot;AbortIncompleteMultipartUpload&quot;: {<br>                &quot;DaysAfterInitiation&quot;: 7<br>            }, <br>            &quot;ID&quot;: &quot;Daily Retention&quot;<br>        }, <br>        {<br>            &quot;Status&quot;: &quot;Enabled&quot;, <br>            &quot;NoncurrentVersionExpiration&quot;: {<br>                &quot;NoncurrentDays&quot;: 40<br>            }, <br>            &quot;NoncurrentVersionTransitions&quot;: [<br>                {<br>                    &quot;NoncurrentDays&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;Filter&quot;: {<br>                &quot;Prefix&quot;: &quot;weekly/&quot;<br>            }, <br>            &quot;Expiration&quot;: {<br>                &quot;Days&quot;: 40<br>            }, <br>            &quot;AbortIncompleteMultipartUpload&quot;: {<br>                &quot;DaysAfterInitiation&quot;: 7<br>            }, <br>            &quot;Transitions&quot;: [<br>                {<br>                    &quot;Days&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;ID&quot;: &quot;Weekly Retention&quot;<br>        }, <br>        {<br>            &quot;Status&quot;: &quot;Enabled&quot;, <br>            &quot;NoncurrentVersionExpiration&quot;: {<br>                &quot;NoncurrentDays&quot;: 365<br>            }, <br>            &quot;NoncurrentVersionTransitions&quot;: [<br>                {<br>                    &quot;NoncurrentDays&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;Filter&quot;: {<br>                &quot;Prefix&quot;: &quot;monthly/&quot;<br>            }, <br>            &quot;Expiration&quot;: {<br>                &quot;Days&quot;: 365<br>            }, <br>            &quot;AbortIncompleteMultipartUpload&quot;: {<br>                &quot;DaysAfterInitiation&quot;: 7<br>            }, <br>            &quot;Transitions&quot;: [<br>                {<br>                    &quot;Days&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;ID&quot;: &quot;Monthly Retention&quot;<br>        }, <br>        {<br>            &quot;Status&quot;: &quot;Enabled&quot;, <br>            &quot;NoncurrentVersionExpiration&quot;: {<br>                &quot;NoncurrentDays&quot;: 2190<br>            }, <br>            &quot;NoncurrentVersionTransitions&quot;: [<br>                {<br>                    &quot;NoncurrentDays&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;Filter&quot;: {<br>                &quot;Prefix&quot;: &quot;quarterly/&quot;<br>            }, <br>            &quot;Expiration&quot;: {<br>                &quot;Days&quot;: 2190<br>            }, <br>            &quot;AbortIncompleteMultipartUpload&quot;: {<br>                &quot;DaysAfterInitiation&quot;: 7<br>            }, <br>            &quot;Transitions&quot;: [<br>                {<br>                    &quot;Days&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;ID&quot;: &quot;Quarterly Retention&quot;<br>        }, <br>        {<br>            &quot;Status&quot;: &quot;Enabled&quot;, <br>            &quot;NoncurrentVersionExpiration&quot;: {<br>                &quot;NoncurrentDays&quot;: 43800<br>            }, <br>            &quot;NoncurrentVersionTransitions&quot;: [<br>                {<br>                    &quot;NoncurrentDays&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;Filter&quot;: {<br>                &quot;Prefix&quot;: &quot;yearly/&quot;<br>            }, <br>            &quot;Expiration&quot;: {<br>                &quot;Days&quot;: 43800<br>            }, <br>            &quot;AbortIncompleteMultipartUpload&quot;: {<br>                &quot;DaysAfterInitiation&quot;: 7<br>            }, <br>            &quot;Transitions&quot;: [<br>                {<br>                    &quot;Days&quot;: 9, <br>                    &quot;StorageClass&quot;: &quot;GLACIER&quot;<br>                }<br>            ], <br>            &quot;ID&quot;: &quot;Yearly Retention&quot;<br>        }<br>    ]<br>}</pre><p>With the policy problem sorted, now we just had to figure out how to make the backup status more visible.</p><p>There were quite a few options we ruled out; We could have sent an email each time it ran, or each time the bucket was updated but we don’t want to be notified each time something is doing what it should. Instead we wanted to know when it had failed, and be able to refer to an at-a-glance dashboard for status.</p><p>We already use influxDB along with Grafana to chart a number of system metrics and we were pretty sure we could do something with this to display our backup status.</p><p>The reasoning behind the approach was simple: emit an event to InfluxDB each time and instance backup completed successfully. If the backup failed, no event would be emitted. We then add a status page in Grafana showing all the events for instance backups int he past 24 hours. If there was no event for an instance, the staus would be red.</p><p>Next we had to figure out how to achieve this!<br>It turns out sending events to Influx is pretty simple and we could achieve it with a simple curl request:</p><pre># Define the command<br>POST2INFLUX=&quot;curl -XPOST --data-binary @- <a href="https://influx.wealthwizards.io:8086/write?db=backups">https://influxhost.example.com/write?db=backups</a>&quot;</pre><pre># Use it when the backup completes successfully:<br>echo -n &quot;instance_backup_completed,instance=${REPLICA_SET} value=true&quot; | $POST2INFLUX</pre><p>InfluxDB is happy to accept a boolean value into a data series, as long as all values in the series are boolean. We only wanted to record if a status was true or false so this was perfect.</p><p>Now all we needed to do was build a page in Grafana to display this info. Fortunately Vonage have written a really neat <a href="https://github.com/Vonage/Grafana_Status_panel">status panel plugin</a> for Grafana and InfluxDB. All we had to do now was figure out how to consume a boolean value to trigger a status change.</p><p>It took a while to get there, but it turns out you need to contort your logic into an odd combination of boolean, string and float values. <br>Influx DB recognises the series as containing boolean values (we used true/false). Granfa will plot the data as 0 or 1 (I had to chart the data with a heatmap to figure this out.. )Status panel recognises the data as strings, but the threshold function in status panel treats the data as a float!</p><p>I the end we set a threshold of 0.5 for critical; i.e. If we had a “true” value in the past 24-hours, then the status was OK/Green. If there was no value (i.e. 0) then status is Critical/Red. We set the threshold at 0.5 to try and add some clarity around this logic.</p><p>So now we have a simple, at-a-glance dashboard in Grafana to tell us if a backup failed, along with an alert (driven from the standard graph panel plugin, but with essentially the same logic). We’ve also extend this method out so we can monitor successful snapshots of our consul K/V store too. So it’s already proving to be pretty flexible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66cDZcnrfaNeEvNZb_fNBg.png" /></figure><p>2 backups stories completed in one week and the best part? I actually quite enjoyed it all!</p><p>We’ll be aiming to open source the mongoDB container shortly so others can benefit from this should they face the same kind of problem. The original container was pulled from a Tatum Labs repo on GitHub but I’m no longer able to track down this so my apologies. please provide me with a link if this looks familiar!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b91f17dccc8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ww-engineering/backups-are-fun-b91f17dccc8e">Backups Are Fun!</a> was originally published in <a href="https://medium.com/ww-engineering">Wealth Wizards Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Policies | making use of kubernetes network policies to add security to your clusters]]></title>
            <link>https://medium.com/@richard.marshall_58248/network-policies-making-use-of-kubernetes-network-policies-to-add-security-to-your-clusters-2dff7b6fe367?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dff7b6fe367</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[weave]]></category>
            <category><![CDATA[network-policies]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Fri, 26 Jan 2018 18:37:29 GMT</pubDate>
            <atom:updated>2018-04-24T20:18:50.958Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s a neat feature in kubernetes called <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/">Network Policies</a> which we’ve been using a little while now. Network Policies (or NetPols) are much like AWS security groups, but within the kube cluster.</p><p>The really great thing about NetPols is that they “understand” the tags you may already be attributing to your deployements, ingress controllers, etc. This means you can quite easily group related components and wrap a NetPol around these and limit access to these resources.</p><p>A great example would be to define a NetPol which restricts any access to a namespace except for any traffic which originates from the name space. This gives you a great level of isolation at the namespace level. You can the grant ingress to that namespace exclusively through a designated ingress controller on a specific port.</p><p>Like wise, you can create a network policy to restrict traffic to a database to only come from pods which actualy need to access a database. Using kubetags in your NetPols provides a really powerful and flexible way of locking down your intra-cluster, inter-namespace traffic for very little cost.</p><p>While Network Policies are managed through the kube API, much like ingress resources, they’re not actually implemented by kube. Instead you need something which understands these kube NetPols to actually turn then into something which can be enforced.</p><p>In our cluster we make use of the <a href="https://kubernetes.io/docs/tasks/administer-cluster/weave-network-policy/">Weave</a> plugin. Weave, or something similar, e.g. <a href="https://www.projectcalico.org/calico-networking-for-kubernetes/">Calico</a>, <a href="https://github.com/coreos/flannel#flannel">Flannel</a>, etc tend to come <a href="https://github.com/kubernetes/kops">out of the box</a> with kube deployments these days, so the chances are you already have something which is capable of implementing Network Policies.</p><p>Weave is an agent which is deployed onto each kube node. It manages things like inter-pod routing, but becuase it’s installed at the OS layer, it also has access to manipulate the IP Tables rules. This is how it implements the access restrictions defined by the network policies. Each policy is converted to a collection of IP tables rules, co-ordinated across each machine, which translates the kube tags into something that can be recognised on each machine.</p><p>One thing we’re hoping to achieve with Weave net in the future, though not tried yet is to include standalone hosts, outside the kube cluster, in the network policy by running the weave agent on those nodes. I’ll create a future post on how we get on with that!</p><p>As you may have picked-up; becuase network policies are implemeted using IP Tables, they operate at layer 3/4 of the OSI model (i.e. IP/TCP) so you can define which IPs/Ports you may or may not access, but they’re not able to operate on URLs, for example, which are at layer 7.</p><p>In order to do this you need to build rules into an ingress controller, or look at something more powerful like a service-mesh, e.g. <a href="https://istio.io/">Istio</a>. By combining the 2 you can build-up a great degree of security, with 2 independant, complimentary systems managing access to resources.</p><p>So, what does a network policy look like?</p><p>The following policy will prevent ingress access into a namespace to everything except traffic originating in the namespace (note that while Network Policies do support controlling egress, we’ve not yet tried this, but it’s on our roadmap!)</p><pre>--- <br>apiVersion: extensions/v1beta1 <br>kind: NetworkPolicy <br>metadata:   <br>  annotations:      <br>  name: namespace-isolation-live   <br>  namespace: live <br>spec:   <br>  ingress:   <br>  - from:     <br>    - namespaceSelector:         <br>        matchLabels:           <br>          name: live   <br>  podSelector: {} <br>---</pre><p>The policy is pretty simple:</p><p>Allow ingress from resources where the namespace matches “live” and apply to all pods (the ’{}’ ; denotes ALL pods in the namespace).</p><p>In order to actually serve traffic from the namespace we have another policy:</p><pre>--- <br>apiVersion: extensions/v1beta1<br>kind: NetworkPolicy<br>metadata:  <br>  name: elb-isolation-live<br>  namespace: live <br>spec:   <br>  ingress:   <br>  - ports:     <br>    - port: 443<br>      protocol: TCP<br>    - port: 80<br>      protocol: TCP<br>  - {}<br>  podSelector:<br>    matchLabels:<br>     name: ingress-controller<br>---</pre><p>likewise, this policy is alo pretty simple:</p><p>Allow ingress from all pods, where the ports are TCP:443 and TCP:80 and apply the policy to pods with have the label matching: ingress-controller (which our ingress controllers do)</p><p>Voila — “Security groups” within the kube cluster. what are you waiting for? Get securing!</p><p><em>Originally published at </em><a href="https://wealthwizards.io/2018/01/26/network-policies/"><em>wealthwizards.io</em></a><em> on January 26, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dff7b6fe367" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spot instances for the win!]]></title>
            <link>https://medium.com/@richard.marshall_58248/spot-instances-for-the-win-676b4381bc9b?source=rss-c4ffd37d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/676b4381bc9b</guid>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Rich Marshall]]></dc:creator>
            <pubDate>Tue, 19 Sep 2017 14:42:04 GMT</pubDate>
            <atom:updated>2018-03-01T10:56:20.246Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*AZCWp-nv6dC6N7VF." /></figure><p>Cloud computing is supposed to be cheap, right?</p><p>No longer do we need to fork out £5–10k for some silicon and tin, and pay for space and the power, the cables and the install, etc, etc. Building in the cloud meant we could go and provision a host and leave it running for a few hours and remove it when we were done. No PO/finance hoops to jump through, no approvals needed, just provision the host and do your work.</p><p>So, in some ways this was true, there was little or no upfront cost and it’s easier to beg forgiveness than permission, right? But the fact is we’ve moved on from the times when AWS was a demo environment, or a test site, or something that the devs were just toying with. Now it’s common for AWS (or Azure, or GCE) to be your only compute environment and the fact is the bills are much bigger now. AWS has become our biggest platform cost and so we’re always looking for ways to reduce our cost commitments there.</p><p>At the same time that AWS and cloud have become mainstream for many of us, so too have microservices, and while their development and testing benefits of microservices are well recognised, the little-recognised truth is that they also cost more to run. Why? Because as much as I may be doing the same amount of ‘computing’ as I was in the monolith (though I suspect we were actually doing less there) each microservice now wants its own pool of memory. The PHP app that we ran happily on a single 2GB server with 1CPU has now been split out into 40 different components, each with its own baseline memory consumption of 100MB, so I’ve already doubled my cost base just by using a more ‘efficient’ architecture.</p><p>Of course, AWS offers many ways of reducing your compute costs with them. There are many flavours of machine available, each with memory and CPU offerings tuned to your requirements. You can get 50%+ savings on the cost of compute power by committing to paying for the system for 3 years (you want the flexible benefits of cloud computing, right?). Beware the no-upfront reservations though — you’ll lose most of the benefits of elastic computing, with very little cost-saving benefits.</p><p>You could of course use an alternative provider, Google bends over backward to prove they have a better, cheaper, IaaS, but the truth is we’re currently too in-bed and busy to move provider (we’ve only just finished migrating away from Rackspace, so we’re in no hurry to start again!)</p><p>So, how can we win this game? Spot Instances. OK, so they may get turned off at any moment, but the fact is for the majority of common machine types you will pay 20% of the on-demand price for a spot instance. Looking at the historical pricing of spot instances also gives you a pretty good idea how likely it is that a spot instance will be abruptly terminated. The fact is, if you bid at the on-demand price for a machine — i.e. what you were GOING to pay, but put it on a spot instance instead, you’ll end up paying ~20% of what you were going to and your machine will almost certainly still be there in 3 months time. As long as your bid price remains above spot price, your machine will stay on and you will pay the spot price, not your bid!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/0*vBcT3Y6bg9H5ahj-." /></figure><p>What if this isn’t certain enough for you? If you really want to take advantage of spot instances, build your system to accommodate failure and then hedge your bids across multiple compute pools of different instance types. You can also reserve a baseline of machines, which you calculate to be the bare minimum needed to run your apps, and then use spots to supplement that baseline pool in order to give your systems more burst capacity.</p><p>How about moving your build pipeline on to spot instances or that load test environment?</p><p>Sure, you can’t bet your house on them, but given the right risk approach to them you can certainly save a ton of money of your compute costs.</p><p><em>Originally published at </em><a href="https://wealthwizards.io/2017/09/19/spot-instances-for-the-win/"><em>wealthwizards.io</em></a><em> on September 19, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=676b4381bc9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>