Kubernetes service account for pod

Hi 🙋‍♂️, In this article I will talk about how to authenticate your applications to the Kubernetes API via the service accounts feature. Citing the Kubernetes docs, a service account for a pod: “provides an identity for processes that run in a Pod. When you (a human) access the cluster (for example, using kubectl), you are authenticated by the apiserver as a particular User Account (currently this is usually admin, unless your cluster administrator has customized your cluster)....

June 5, 2021 · 3 min · Denis Nuțiu

FastAPI Uvicorn logging in Production

Hello 🙋‍♂️, Running a ⏩FastAPI ⏩ application in production is very easy and fast, but along the way some Uvicorn logs are lost. In this article I will discuss how to write a custom UvicornWorker and to centralize your logging configuration into a single file. To keep things as simple as possible I’ve put all my code in a single Python file. main.py import uvicorn as uvicorn from fastapi import FastAPI, APIRouter router = APIRouter(prefix="") def create_app(): fast_app = FastAPI() fast_app....

May 18, 2021 · 3 min · Denis Nuțiu

Kubernetes OpenID Connect Integration with Resource Owner Flow

Hello 😄, In this article, I will demonstrate how to configure Kubernetes (minikube) to use OpenID Connect as an authentication strategy. We will cover the Resource Owner Password flow. Feel free chose the right authentication flow depending on your application’s needs. Please refer to this diagram in order to choose the flow: Note that the Client Credentials flow is not supported by Kubernetes. According to the official docs: “To identify the user, the authenticator uses the id_token (not the access_token) from the OAuth2 token response as a bearer token....

May 14, 2021 · 6 min · Denis Nuțiu

Context Managers and Cross Cutting concerns in Python

Hello, In this short article I would like to talk about context managers. I personally consider that at the core they are just a form of decorators. If you don’t know what a decorator is check the Decorator Pattern Wikipedia article. Decorators can be used to implement cross-cutting concerns. We have componentA and we need logging and security, we could write the logic for logging and security handling in componentA but some people consider component a should be componentA not componentAthatAlsoKnowsAboutSecurityAndOtherStuff....

March 7, 2021 · 4 min · Denis Nuțiu

Constructor Injection and Null Object Design Patterns

The Constructor Injection design pattern is a pattern that helps you declare all the required dependencies of a class in it’s constructor. This is useful because it helps you decouple the code, you can specify an interface instead of a concrete type, remember, program to an interface. Also, in the constructor it is easier to guard against null objects. The calling code doesn’t have to worry about null exceptions every time it uses a dependency....

November 7, 2020 · 2 min · Denis Nuțiu

Composition Root Pattern: How to Write Modular Software

The composition root is a design pattern which helps you structure a software application by implementing a class that builds all the other classes. In this example we will examine this pattern in Python. Here’s the object graph of the classes that we’re going to implement: I have designed a sample application that we’re going to use. It contains three components: ConsoleInputListener, ConsolePrinter and RomanianTranslator and a value object class: Message....

November 6, 2020 · 3 min · Denis Nuțiu

Introduction to Pyenv for Linux Users

Hello, In this article I will introduce you to pyenv, a tool for managing python environments. Installing pyenv is pretty straight forward, you’ll need to clone the repo and add the binaries to the path. For a typical Debian based distro using the Zsh shell the instructions would be: git clone https://github.com/pyenv/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc Then, in order for this to take effect, you need to reload the shell with: source ~/....

June 27, 2020 · 4 min · Denis Nuțiu