Manage static files for Django when deployed on kubernetes

Posted on 2021-03-31 in Trucs et astuces • Tagged with devops, k8s, kubernetes, Django, Python

This will be a continuation of my article Some tips to deploy Django in kubernetes. In this previous article, I talked about generic tips you should apply to deploy Django into kuberentes. Here, I'll focus on static files.

If you don't already know that, gunicorn (or any other app server …


Continue reading

Some tips to deploy Django in kubernetes

Posted on 2021-03-29 in Trucs et astuces • Tagged with devops, k8s, kubernetes, Django, Python

I am not going to go into details in this article about how you can deploy Django in kubernetes. I am just going to highlight the main points you should pay attention to when deploying a Django app. I expect you to have prior knowledge about how to deploy an …


Continue reading

Enable basic authentication to all pages of a NextJS site

Posted on 2021-03-28 in Trucs et astuces • Tagged with devops

It's not as obvious at it seems. You can protect your API routes or some pages by following the documentation, but nothing to protect everything in one go with basic authentication (to protect your pre-production site from normal user for instance). Despite NexJS having a server component, I didn't find …


Continue reading

Extract kubectl configmap/secret to .env file

Posted on 2021-03-21 in Trucs et astuces • Tagged with devops, k8s, kubernetes

You can extract data from your kubernetes config maps into a .env file with the commands below (requires you to have jq installed):

# Get the data in JSON.
kubectl get configmap my-map --output json |
    # Extract the data section.
    jq '.data' |
    # Replace each "key": "value" pair with "key=value"
    jq -r …

Continue reading

Server tips

Posted on 2020-09-17 in Trucs et astuces

Start systemd services automatically for a user

By default sysemtd services linked to a user – created with systemctl --user enable --now service for instance – are only started after the first login of the user. To start them when the server starts, you …


Continue reading

CSS tips

Posted on 2019-03-10 in Trucs et astuces • Tagged with CSS

Apply style to IE11 only

Put the style in this media query:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    // Put CSS here
}

PyCharm tips

Posted on 2019-03-10 in Trucs et astuces • Tagged with Python, IDE, PyCharm

View print output immediately

Add PYTHONUNBUFFERED=1 in run config or .env (only use .env if you use the plugin). This is meant to immediately view the output …


Continue reading

ZSH tips

Posted on 2018-10-09 in Trucs et astuces • Tagged with ZSH, Shell, Linux

Sommaire

ZBell

Useful to have a notification when a long command completes.

To enable it, add zbell to your plugins array if you are using oh-my-zsh or source the definition file.

To configure:

  • The minimum time commands must take for the notification to happen, use: ZBELL_DURATION. For instance ZBELL_DURATION …

Continue reading

Bash tricks

Posted on 2018-10-03 in Trucs et astuces • Tagged with Bash, Shell, Linux

Sommaire

Scripts

Use this at the top of all your Bash scripts to avoid problems:

# Exit on error.
set -e
# Don't allow undefined variable.
set -u
# Make pipeline fail if any command in it fail.
set -o pipefail

Heroku tips

Posted on 2018-10-03 in Trucs et astuces • Tagged with devops, Heroku

Use an editor

By default there is no editor on Heroku. To get one, you can use the heroku-nano plugin like this (or by installing as a plugin):

mkdir bin
cd bin
curl https://github.com/Ehryk/heroku-nano/raw/master/heroku-nano-2.5.1/nano.tar.gz --location --silent > nano.tar …

Continue reading