Showing posts with label cloud. Show all posts
Showing posts with label cloud. Show all posts

Wednesday, March 11, 2020

Infrastructure testing for Terraform with Clarity

DevOps Engineering is a reality. DevOps principles like Immutable Infrastructure, Infrastructure as Code, GitOps and Observability are the default building principles for any cloud computing serious initiative. However, Infrastructure, provisioning, automation it's not trivial, tools like Ansible and Terraform make the engineer's life easier, productivity and fun. As time goes by we have more and more infrastructure code, how we make sure we keep software rolling faster with stability and quality?  The answer is testing.  Infrastructure testing is a very tricky, mocking terraform it's not easy. There are some interesting solutions like LocalStack, TestContainers, and molecule for Ansible. These tools are great but they are more towards Integration or E2E testing with are expensive, involve several other components and often super slow to run. A simple approach more towards unit testing could be achieved using Clarity.

Enter Clarity

Clarity is a BDD(Behavior Driven Development) framework for Terraform. Clarity is a simple, single binary written in Go. Clarity uses *gherkin* as syntax. Clarity has its own set of matchers and HCL
parser. Clarity has an extensive set of matchers like:

  • always equal
  • never equals
  • does not equal
  • is greater than
  • is less than
  • exists
  • occurs (at least, at most, exactly) x times

All the matchers can be used for Terraform attributes or even for terraform values. Clarity is great but you need to keep in mind that clarity will check for static values, it would get dynamic values, so it's a great tool to hook on your PR add-ons or even as part of your CI/CD/GitOps pipeline.

Sample Code & Usage

After downloading the binary, adding to the path and getting proper execution permissions you need to have the binary on the same folder as terraform files are located. So you do your terraform files(*.tf) as usual and them you create *.feature file where we will have our specs for testing. Then after having all that we can run the tests via console, i.g: clarity main.feature. Let's take a look at the following sample.


As you can see the syntax is pretty simple and straight forward you provide the attributes and the values you expect to have in your terraform files and clarity will check it for us. There is this interesting extension you can install for VSCode which will make your life easier.

Running clarity will output something as similar:


The complete sample is here in my github.

Cheers,
Diego Pacheco

Thursday, January 2, 2020

Amazon Builder Library: Review Notes

During AWS RE:Invent 2019 amazon release Amazon Builder's library. Which are world-class Distributed Systems, Engineering, Cloud-Architecture, DevOps class and lessons learned through experience on how to build reliable and scalable systems. The library is really great, some articles are a bit extensive like 30min read but they are really well crafted and provide great insight on amazon best practices. Today I want to share my review notes on the Library. I highly recommend you read the library. Amazon content has links with their products and also links to further readings in the sense of theory & tools. It took me a weekend to go through all the articles(13 so far) and this time was well invested I had lots of fun and learn a lot.



Review Notes

My Amazon Builder's Library Notes

Companion Deck



I hope you enjoy!

Cheers,
Diego Pacheco

Wednesday, January 1, 2020

Amazon Aurora: Papers Review

Amazon Aurora is a very interesting piece of engineering. I want to share my review notes on 2 papers related to amazon aurora. I was wondering for a long time, 2 years if I should start publishing my reviews or not. I do structure learning and study for a long time for more than 15+ years, however, I often take notes on the papers and videos I see in my Evernote. After 2 years of thinking I decided to share my papers review notes. I believe this decision will improve my learnings because I will write even more about the things I study and read and often do in my day-by-day work. I don't work at Amazon however I like amazon a lot, they are a reference for me in regards of SOA(Service Oriented Architecture), DevOps, Cloud, and NoSQL/NewSQL databases now, which aurora they proved to me that cloud-native database it's a real thing and its not BS marketing.

Papers

Engineers often dont read papers, which is a big mistake because they loose often Deep Dive tech content related to Algorithms, Datastructures, Techniques, and lessons learned. So If you are reading this, start reading papers. The 2 amazon papers I'm talking about are:

Amazon Aurora: On Avoiding Distributed Consensus for I/Os, Commits, and Membership Changes
https://dl.acm.org/doi/10.1145/3183713.3196937

Amazon Aurora: Design Considerations for High Throughput Cloud-Native Relational Databases
https://www.allthingsdistributed.com/files/p1041-verbitski.pdf

I highly recommend you read the papers if you want to learn more about cloud-native databases.

Reviews

Amazon Aurora: On Avoiding Distributed Consensus for I/Os, Commits, and Membership Changes
https://github.com/diegopacheco/notes/blob/master/paper_reviews/aws_aurora/diegopacheco_paper_review_Amazon_Aurora_On_Avoiding_Distributed_Consensus_for_IOs_Commits_and_Membership_Changes.pdf

Amazon Aurora: Design Considerations for High Throughput Cloud-Native Relational Databases
https://github.com/diegopacheco/notes/blob/master/paper_reviews/aws_aurora/diegopacheco_paper_review_Amazon_Aurora_Design_Considerations_for_High_Throughput_CloudNative_RelationalDatabases.pdf.pdf

I hope you enjoy it. More to come.

Cheers,
Diego Pacheco

Saturday, April 20, 2019

Reflections on Serverless:From SOA to Serverless part 3

This is the 3rd part and last one on the series: Reflections on Serverless from SOA to Serverless. On the previous parts 1 and 2 I was explaining how software architecture evolved in several movements and how much we need to change our mindset in the sense of Culture, Movements, and Experiments. Our tools are changing pretty quickly and multi/poly cloud will be soon a reality for most companies. Even if so few companies have this problem in sense of availability and active-active global biz, most of the companies can benefit from multi-poly cloud in sense of getting lock in free from cloud vendors, cost reduction for better and multi offerings, better solutions for specific problems and much much more.

The Deep Dive

For this last post, I want to cover more details around specific issues and promises around Serverless per se. At the end of the post, you will have access to a slide deck with more information and structure in a more fluid and clean way :D

Mind the Lock-in

Remember STATE is not part of serverless and you need to use state someplace else, so serverless could be a potential accelerator for cloud usage, therefore, you could get lock in pretty fast. There are solutions for that like - using open standards, open APIs, there we go on the SOA path again.

Cold Bootstrap 

We need to realize that Serverless has issues like Startup time(also know as cold bootstrap). This problem will be fixed soon and there are ways we can deal with the thios problem right now. So the first thing we need to know and mind startup times for all major serverless providers(aws, Google, and Azure). Secondly, we can use fast startup times in languages like Rust and Go. If you work with java you can use GraalVM and Kubernetes based serverless in order to fix this problem.

Do not use Serverless(FaaS) for

This does not mean you cannot do it but it means actually that this is not the best FIT:

  • High-frequency trading or extremely low latency applications. 
  • Large-Scale in memory Statefull solutions(could be done with Serverless if state if out)
  • Long-running stateful jobs(could be done with Serverless if state if out)

Serverless and FaaS: 2 Different Things

Serverless is a NoOPS cloud billing model where you may use or maybe not use FaaS(Function as a Service) abstraction, model. We can see Aurora for instance in AWS. Where you have a Serverless DB without any new abstraction model for programming, you actually can still use MySQL and PostgreSQL APIs.  FaaS is about runtime abstraction at least until the last google next 19. Now Google is offering a Serverless(with Docker) where you can control the language runtime - called Google Cloud Run.  Google Cloud runs with KVM and gVisor at a low level.

Portability with Serverless

There is a spec called cloudevents -  Which is supported by Azure in production already and allow you to have multi-cloud serverless(Faas) solutions talking to each other without lock-in. This spec still is in the early days but is getting traction as the time pass.

The Deck



Serverless is the future and it's here. We need to keep in mind that Serverless and FaaS are different things and that cloud(single, multi, poly) billing models are changing and we will need to adapt our solutions and thinking. Serverless might become the default model on the cloud. We need re-think our solutions and get ahead in order to take full benefit from the multi-poly cloud world. Serverless makes more sense now them ever.

Cheers,
Diego Pacheco

Tuesday, March 5, 2019

Reflections on Serverless:From SOA to Serverless part 1

New technology is great. It's very important to open space for new ideas, better solutions, cheaper, faster and exciting new things. However, even with technology, there are principles and lessons learned with previous technologies we need to carry on otherwise we will keep making the same mistakes and we might not take full advantage of new tech. Why? Because often new tech requires a new way of things and often times also require to keep some things from the previous movements. Companies want to do Serverless now a day, often because cloud vendors are pushing that hard and because of the short term cost benefit. However, in the long run, Serverless solutions might be way more expensive than in-house solutions using OSS. There is no silver bullet, you need to understand what you are doing in order to take full benefit from new approaches, techs, and ideas rather than just moving everything from on-trend to another.  I want to share some thoughts from several architecture models and principles that was evolving from SOA to Apis to Microservices to Cloud-Native Microservices to Serverless.  For instance, Serverless is going forward following some SOA Principles, did you know? For this blog post, I will provide a set of explanations on my view of the architecture evolution and at the end of the post you will have access to a 40min video, explaining some ideas on the post but with a video.

From SOA to Serverless

SOA is not about technology(SOA is not about ESB), SOA is about principles, these principles are alive nowadays more than you can imagine.




SOA was the foundations of everything. SOA is about abstractions(contract) and the big picture(Service Orientation - SO), seeing the whole system spectrum and it should not be used or a simple Service alone or single project alone. One of the main benefits of SOA is the Backward compatibility(BC) approach. Soa is not a specific technology neither just an ESB.


 
Microservices are a kind of SOA with 2 different aspects. First of all the granularity which is smaller than SOA, SOA never gave a prescription on who granular a service might be but in my experience often was quite big. Seconds Microservices are about isolation. In other words, having they dedicated OS, Servers, Git repository, Build the pipeline, and so on and on. Microservices requires lots of DevOps work. Microservices are not the silver bullet there are problem domains where it does not make sense to have small granularity and therefore this could lead to bad design and coupling. It's very important to talk about SOA in Microservices and Serverless context because these architecture models evolve from one to another and if you just see Serverless as a self-contained thing (meaning: not learning from SOA and Microservices) you most likely will be doing it wrong.

Microservices required DevOps Engineering. When we are doing microservices on the cloud, we can use most of the benefits from the cloud by doing cloud-native microservices which you can be done by using NetflixOSS / Spring Boot Stacks or nowadays you can use Kubernetes with Istio.

What is Serverless?

FaaS and Serverless are different things. Often people think Serverless is about FaaS only. Often Serverless is related to FaaS. However you most likely to have Serverless when you are doing FaaS but you might be doing Serverless and have no FaaS. Because Serverless is a cloud model, where often the cloud provider takes care of the operation for you. This is the case for Managed Services for Databases like Aurora but also for other engines like Kafka, MongoDB and much more.  FaaS(which was called microservices for a brief moment - for some people) is the evolution of microservices, however, FaaS is Event driven and microservices can be Event driven but also can be RPC.

Serverless and Kubernetes



Kubenetes is the cloud multi-cloud / poly-cloud way to go. Ks is the open source / open standard cloud spec, which means, you can use cloud without getting locked-in by a cloud vendor. Kubernetes allow you to run all kinds o workloads from RPC, Analytics / Batch / Streaming, Machine Learning Training and also Serverless. The cool thing about running Serverless in kubernetes is the fact that is all portable, not only the code running in Serverless but also the whole infrastructure which is great. Somewhere in the future cloud should be about COST them being able to move things around is better not only for better usage of cloud reservation but also for strategic negotiations.

Serverless Require less DevOps work, it does not mean you can do NoOPS. It means you have less DevOps / Ops work. You still need to automate the deploy of your functions(in case you are doing Serverless with Faas), if you think about CloudSQL or RDS you will have more things to automate. Serverless end up has less moving pieces from you and more pieces for the cloud provider whoever is providing the Service.

There is an open spec for Serverless called *Cloud Events*. Cloud events describe the events(inputs, outputs) in a standard way. Does this sound like an SOA Contract? Yes. We also see the same willing to have portability like we saw in SOA Manifesto. IF you don't think this is the future you don't need to take my word from granting take Kelseys.

Video

Next, you will see a brief story about the evolution of Service architectures, starting from SOA and getting into Serverless on Kuberntes. You also will see some benefits and trade-offs of each wave of technology evolution.

Reflections on Serverless from Diego Pacheco on Vimeo.


Slides



Doing Serverless without Kubernetes is a recipe for Lock In. Serverless need to embrace SOA values like Open Standards, Contracts(Cloud Events) and API Versioning / Backward Compatibility features otherwise your system will continue to break and you might take full advantage of Serverless.

Cheers,
Diego Pacheco

Sunday, March 3, 2019

Kubernetes Everywhere with k3s

Kubernetes is becoming the truly cloud-native specification for the cloud. However not all software runs on the cloud, there are other uses cases like embedded software(IoT and microcontrollers) besides IoT there is another kind of computation that is growing more a more nowadays called Edge, thanks to the low latency and facility capabilities. Would be great run the same infrastructure for the edge/IoT as we do for the cloud? Well, rancher folks addressed that with k3s. A super lightweight kubernetes distribution where they replace things and remove features instead of adding, This is great not only for the IoT/Edge uses cases but also for folks who study the cluster in the academia and for the developers in 2 fronts. First on the CI/CD front, so we can spin up a lightweight cluster to run all kinds of tests, this also has a perfect fit with GitOPS model.

Another developer use case is the local machine scenario. For developer is very important to have a set of lightweight solutions, so they can run on the local machines this is important for a lot of reasons like:

  • A sandbox to play and do experiments
  • Learn effectively
  • Debug and Troubleshoot
  • Simulate some kinds of bugs in order to add tests

Not all scenarios can be covered with the local environment and that does not kill the need to have a cloud environment for development. However, this is a powerful tool for the developer and speeds up things a lot. 

Running k3s Locally

k3s is super lightweight and super fast. The solutions are pretty new but have lots of potentials. There are some limitations in k3s like there is no ALPHA specs support.

Running the Server



















Echo App Spec



Get Pods







Running a service in kubernetes using k3s

















cheers,
Diego Pacheco

Thursday, February 14, 2019

Istio & Kubernetes: Developer Productivity and freedom to deliver your OKRs

Innovation is a must have for companies today and work with the product mindset. Given the digital transformation, we live in, having a product mindset is more than delivering software but it is empowering teams and working with OKR-based management models that focus on Business Objectives rather than what teams have to do.

Development teams are motivated by challenges and they should have the freedom to make choices. But these choices can often have a very high cost for the business and low return. Cloud usage is certainly a great disruptive force for all digital businesses. 

There are many ways to architect Cloud-Native solutions (get the most out of cloud) often for a short-term view many companies are opting for Managed Services solution. These solutions, which are often database solutions, but not limited to the database, give a lot of speed for software development but bring two major problems in the long run.




Managed Services Issue 1 - Cloud Vendor Lock-in

When using managed services there is a cost reduction and bottleneck of DevOps, which is a difficult skill set to hire. However, when using managed services proprietary APIs, you are certainly thinking that you are taking a lot of value out of your cloud vendor, based on usage. Using 100% of a service does not mean better value for the business. In the long term it costs more but often these decisions are taken by lack of software architecture knowledge to support in making the best technical decision.

Managed Services Issue 2 - Cost

Increasingly there are more and more cloud providers and the cost is more and more a central issue not just for software architecture but for the business as well. It is necessary to have solutions that are COST-EFFECTIVE but often this math is made only considering the initial cost of OPS that the cloud provider absorbs. But in the long run, it is much cheaper to run this kind of solution on Compute layers than to run as a managed service. However, when using computer solution many times it is necessary to perform many integrations and development of cloud-native architectures to enable digital products. Soon this equation becomes complex and once again it is common for companies to tend to managed services for cost reduction and simplicity of execution even if this sacrifices portability in the long run.

Istio & Kubernetes: Changing the Rules of the Game

The Market changes fast, nowadays we no longer need to choose between productivity, low initial cost, and profitability because with Kubernetes and Istio we can have the 3. That same we can have the maximum of productivity giving total freedom for the technical teams, low cost of ramp up and still be portable to work multi/poly cloud solution.

With Kubernetes and Istio it is possible to develop microservices in a disconnected form of any cloud provider. Because Kubernetes in conjunction with Istio and Envoy (Lyft's open source proxy solution - Uber Concurrent Us) uses the kubernetes abstraction translation service for the cloud provider. That way your solution is not stuck with any specific cloud vendor.

There are solutions to create, run, update, maintain and destroy kubernetes clusters of in multiple clouds like AWS (Amazon) and GCP (Google) like Kops. Kops is an open source software that does all this for us still being able to generate Terraform templates for the translation of specific solutions from Google's cloud(GCP) or AWS. For example, in Kubernetes there is the concept of gateway that is used for transfer data and with Kops, this concept will be translated into an Elastic Load Balancer (ELB) in AWS for example.

Why Use Istio?

Istio allows the developer to use any language and any server. There is no such thing as a binary coupling as there was in the NetflixOSS Stack that forced the use of Java and a series of intrusive dependencies in the classpath. With Istio we have the same abstractions that exist in the NetflixOSS Stack but at the platform level, thus leaving the very productive developer and much more focused on business, digital products, without losing all the benefits of a cloud-native architecture.

Business Benefits

By using Kubernetes and Istio the business can deliver digital products with extreme productivity and at the same time not be locked-in by cloud vendors. So in the future, if the business realizes it more economically viable to migrate to another cloud-provider this is possible in a transparent way. In addition, it is less sensitive to the cloud provider's cost variations and has the strategic freedom to go where it makes more sense and has the best cost.

There is another great benefit that is in the motivation part of the technical team that helps keep the professionals motivated and the turn-over low because that way the technical team can try out new servers, new languages independently and delivering value to the business. Engineers are motivated by challenges and new technologies, often tied systems do not allow experimentation what is bad for the motivation of the technical team as well as experimenting with new technologies to solve problems and create new business models. With istio, everyone wins.

For the Devops Team

Creating digital Stacks in the cloud is not a simple task and is expensive. Often the Devops team is under-resourced and cannot keep up with internal demand. The solution to this problem lies in, building and releasing tools for the developers to be more productive. Building self-service tools and services and thus freeing the Devops team to focus on improving tools and availability of digital products.

Solutions such as Kubernetes, Kops, and Istio help to remove a lot of manual work from the business engineer and thus deliver a high-profit stack to the business with little effort. Istio provides a complete solution with Observability (Logs, Metrics, Traces) of the entire Kubernetes stack.

For Developers

In addition to being able to use any language at the end of the day is not bound to the decisions that come from above and is free to reach the OKRs in the best way they understand besides having the possibility to experiment new technologies of easy integration to the stack of existing services. Another advantage is that with the setup time fast and complete isolation is very simple to have more environments and debottleneck platforms teams to release components.

Kubernetes and Istio have great potential and this is just the beginning of the journey. If you are doing digital transformation or starting a new project you need to consider this solution as it has many advantages compared to previous approaches of First Wave of Microservices with Stack of NetflixOSS, ManagedServices using proprietary APIs of cloud providers. We are actually talking about something that is "Game Changing" for the business and for the technical teams.

Cheers,

Diego Pacheco

Monday, February 11, 2019

Running Istio on EKS

Besides all network overhead, Istio offers very interesting trade-off for sacrificing latency and network overhead for developer productivity and stack independence. In previous posts, I blogged a lot about kubernetes, Istio, Aws, Kops, Eksctl and EKS. Today I will show how to run Istio in AWS using EKS. Keep in mind EKS don't support Alpha* Specs right now(v1,v2 or v3) so some demos from the istio best selection of slideware won't work. But is possible to have istio installed and booking app running.




Running Istio in AWS with EKS and eksctl



Cheers,
Diego Pacheco

Wednesday, February 6, 2019

Running k8s on EKS

EKS is the new AWS managed Service for Kubernetes launched at last Re-Invent 2018.  EKS is not available in all regions right now. EKS an option for those who don't want to use KOPS.  For this blog post, I will show how to easily set up a kubernetes cluster in AWS using EKS.  EKS has some benefits, first of all, is a managed service that you are not locked in since the API is kubernetes based so you can easily migrate to other kubernetes installation or even other kubernetes installation in other cloud vendor or on-premises.




EKS Benefits
  • Managed Service without lock-in (Kubernetes API, specs, kubectl)
  • There is no Control Plane management (Multi-AZ, Automatic patches, and updates)
  • Secure by Default (Secure and encrypted communications between worker nodes and master)
  • Conformant and Compatible (EKS runs certified kubernetes. Compatible with standard k8s envs)
IMHO this is what most of the companies are looking for, in other words, *Serverless*. 

The Pain Points

I don't want to paint a rosy picture of EKS like any new technology there are problems such as:
  • Poor Documentation - very few docs
  • Lack of Observability - It's a kind of black blocks compared with Kops.
  • When you do something wrong and har to figure it what you did it wrong.
  • Error-Prone - Is very easy to make mistakes(eksctl fix that)
  • In a Long Run is more expensive than running on EC2 with Kops
  • Alpha APIS is not supported. 
It's important to keep in mind that EKS is a very new service and it should get better and the time passes. 

Running Kubernetes in EKS using EKSCTL

EKSCTL is a great tool. Written in go, makes eks cluster creatin way less error-prone and many simples to get a cluster up and running. So let's get started! Basically, we will install the AWS Authenticator and EKSCTL them we can create the cluster and deploy nginx in kubernetes after that we can access the nginx application in the browser(before that you will need to enable the SG access for your IP). Them we destroy the cluster.


Creating a cluster














 Deploying nginx in Kubernetes












Nginx up and running on AWS(Need to enable 80 port SG access)

















Nginx AWS ELB Created by EKS and K8s with EKSCTL



 K8s Nodes Running on EC2 via EKS and EKSCTL





















Destroying the cluster







Cheers,
Diego Pacheco

Tuesday, February 5, 2019

Running Istio on AWS with Kops

In previous posts, I show how to run Istio in Minikube and with Docker-Compose/Consul in local env, today I will show how to run on AWS using KOPS.

This installation is Linux based(Ubuntu), I'm running all commands from my local-desktop, if you don't use Linux(shame on you) you can create a virtual-machine on AWS with ubuntu and run this commands there, also is possible to run Vagrant with Linux and them run this commands on Vagrant box as well. Istio runs smoothly in AWS with Kops. You don't need much, pretty much 3 machines(1 master node, 2 minions).  Keep in mind this is not a production-grade setup, for production, you should be running with 3 masters at least for High Availability.




Installing and Running Istio with Kops



Master and Worker nodes on AWS EC2 Console










Istio Metrics in Grafana

















Jaeger - Distributed Tracing






















Kiali - Observability

















BookInfo ServiceMesh (4 microservices) running on Istio / Kubernetes in AWS

Prometheus(Cloud-Native Observability) - Metrics, Dashboards, and Alerts 

















ServiceGraph























That's it - I hope you enjoyed.

Cheers,
Diego Pacheco

Chuyên mục văn hoá giải trí của VnExpress

.

© 2017 www.blogthuthuatwin10.com

Tầng 5, Tòa nhà FPT Cầu Giấy, phố Duy Tân, Phường Dịch Vọng Hậu, Quận Cầu Giấy, Hà Nội
Email: nguyenanhtuan2401@gmail.com
Điện thoại: 0908 562 750 ext 4548; Liên hệ quảng cáo: 4567.