Programming

Estimate costs related to infrastructure as code changes

Photo by Micheile Henderson on Unsplash
Photo by Micheile Henderson on Unsplash

Cloud computing is awesome for growing and scaling up infrastructure quickly to follow product needs. However, this elasticity and flexibility come at a cost. Reviewing your bill daily is crucial to avoid unpleasant surprises at the end of the month. Cloud providers offer tools ( here some examples for AWS) and good practices to help you saving money.

Most of the time, infrastructure as code (IaC) is employed to maintain and facilitate the evolution of this underlying. Like any other type of language, it should follow the same good practices and pass the code review step with other contributors. As…


CODEX

Discover Kubernetes IN Docker and create use it in Travis CI project

Representation of the possibility to deploy Kubernetes cluster in Docker with Kind
Photo by Call Me Fred on Unsplash

In this article, we’ll have a look at how to deploy a Kubernetes cluster from scratch for a testing strategy. When developing Kubernetes-dependent features as Helm charts for example you need a cluster to test them. We don’t always have a reserved cluster for CI or maybe you want to have isolated tests to avoid side effects.

At the beginning of Kubernetes popularity raise, an easy way to play and learn was to deploy a cluster using Minikube. We’ll see why it is not the most suitable solution for pipelines compared to currently available solutions. Now it is possible to…


Simulate and test your code interactions with AWS

Figurine made of Amazon boxes
Photo by Daniel Eledut on Unsplash.

Do you need to test some pieces of code interacting with AWS? In this article, I’m going to introduce the Moto library whose aim is to mock out AWS services. That means you won’t have to deploy anything in the AWS cloud to test your code.

In the first part, we’ll create a simple piece of code interacting with the Elastic Compute (EC2) service. We’ll examine the different ways of mocking provided by Moto. This will give you an overview of its possibilities.

Next, we’ll couple the Moto library and pytest framework to have clean and scalable unit tests.

Prerequisites

First…


Run code linters and scanners in your CI/CD

Photo by Danil Shostak on Unsplash
Photo by Danil Shostak on Unsplash

In a previous article, I presented to you coding-style importance and pre-commit framework. Today, we’re going to handle pre-commit for Terraform code. It will be in charge of validating code using linters and scanners. For any new git commit, we’ll be able to ensure there is no regression and keep a constant quality.

First of all, we’ll create a Terraform module for having something to test. The modules are good to not duplicate code and should be hardly tested to be reliable. We’ll have a look at which pre-commit plugins to use for Terraform.

Once the module in place, we’ll…


Cloud, Infrastructure as Code

What type of load-balancer should I use? How to do with Terraform?

Photo by Piret Ilver on Unsplash
Photo by Piret Ilver on Unsplash

Recently I have confronted myself with the need of using a static IP with load-balancers. The reason was to be able to whitelist IP addresses in firewalls. By making some researches, I have discovered that ELBv1 does not support this feature. ELBs manage IP addresses behind the scene you have no control over it.

The first step was to migrate to a network load-balancer (NLB). In the first section, we’re going to inspect its characteristics. Then we put in place a small Terraform project to assigned reserved public IP to an NLB.

Network Load Balancer

At first view, the NLB looks like ELBv1…


IoT, Programming, Technology

Track your home temperature and humidity with a Raspberry Pi

Photo by Luke Chesser on Unsplash

Prometheus is an open-source project for monitoring and alerting metrics. It relies on a time-series database that is well suited to IoT purposes. In this article, we’ll see how to collect temperature and humidity from a Raspberry Pi. These metrics are collecting from a DHT22/AM2302 sensor. We’re going to see how to connect the sensor to the card and confirm data acquisition.

The next step is the implementation of a Prometheus exporter in Golang. An exporter exposes the metrics through an HTTP server with good format. The Prometheus server calls the exporter to collect and stores the metrics. …


DevOps, Containers

Take your first steps with containerd and run your docker images as usual

Photo by ines mills on Unsplash

In December 2020, the Kubernetes project has deprecated docker. Through this lecture, we are going to have a first look at the dockerhistory to understand the reasons for this deprecation. This will bring us next to discover containerdand figure out its advantages.

We will practice containerd by installing it on a Raspberry Pi. This target platform is a good scenario to dig into the different components needed to use containerd. There are no available binaries so we will build them from the sources. …


Programming, Methodology

See how to enhance code quality and gain time

Photo by Joshua Aragon on Unsplash
Photo by Joshua Aragon on Unsplash

Code is not something frozen through time but it evolves with the team and the project. Writing good code does not imply only writing code well suited to the use case and optimized but also readable. Sometimes during the project lifecycle, the code readability may decrease. This could come due to a variety of factors as few described below to give you a picture :

  • You have not defined a clear coding style and each developer has his own
  • There is a newcomer and he has his own coding habits from his previous experience

The Coding Style

Quality comes from standards

Standardization has a lot of advantages…


Programming, Python

Figure out how to represent elegantly data structures with ease

abstract view of a tall geometric building
Photo by Julien Moreau on Unsplash

Dataclasses are among the new features introduced by Python 3.7. Its goal is to simplify the class creation containing mainly data without functionality. This can be compared to commonly used data structures.

When using a class as a data structure, we have to implement the same methods as __init__() and __repr__(), which is cumbersome. Dataclasses autogenerates these methods for us. This offers more transparency in the language.

Immersion in Dataclasses

Declaration

The declaration of a data class is done by affecting a decorator to a class. In the example below, we will create a data class to represent GPS coordinates:

You can directly…


DevOps, CI/CD, Kubernetes

This is how to build and deploy an application to Kubernetes in a single file

Photo by Matt Bowden on Unsplash

In October 2020, HashiCorp announced the launch of its product named Waypoint. It provides a modern workflow to build, deploy and release across platforms. We’re going to build a golang application and release it to Kubernetes.

The build step will detect the source language and compile it with cloud-native buildpacks. The resulting outcome will be a docker image stored in a Harbor remote registry. We’ll see how to configure Harbor on a local Kubernetes cluster.

Waypoint will reuse this image to deploy and release it into the cluster. …

Guillaume Vincent

DevOps Engineer & AWS Certified Solution Architect. Cloud enthusiast and automation addict. Find out more content at https://getbetterdevops.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store