Skip to main content
French version below

Useful aliases to create when interacting with a Kubernetes cluster

When we work on Kubernetes projects, we very regularly have to execute some kubectl commands. To save time, we created a list of aliases on our servers that, not surprisingly, made it easier for us to interact with our Kubernetes clusters.

Below a list we compiled some of the most useful aliases we created:

get_bo='kubectl -n app-prd get pods -l app=app-bo'
get_fo='kubectl -n app-prd get pods -l app=app-fo'
get_pods='kubectl get pods -n app-prd -o wide'
get_varnish='kubectl -n app-prd get pods -l app=varnish'
ssh_bo_fpm='kubectl -c app-fpm -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-bo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_bo_nginx='kubectl -c app-nginx -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-bo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_fo_fpm='kubectl -c app-fpm -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-fo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_fo_nginx='kubectl -c app-nginx -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-fo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_varnish='kubectl -c varnish -n app-prd -it exec $(kubectl -n app-prd get pods -l app=varnish -o json | jq -r .items[0].metadata.name) -- bash'
varnish_flush='kubectl -n app-prd get pods -l app=varnish -o name | xargs -I{} kubectl -c varnish -n app-prd exec {} -- varnishadm "ban req.url ~ ."'

Alias utiles pour interagir avec un cluster Kubernetes

Lorsque nous travaillons sur des projets Kubernetes, il nous arrive très régulièrement de devoir exécuter certaines commandes kubectl. Par gain de temps, nous avons créé une liste d’alias sur nos serveurs qui, sans surprise, nous ont permis d’interagir plus facilement avec nos clusters Kubernetes.

Ci-dessous une liste compilée de quelques alias les plus utiles:

get_bo='kubectl -n app-prd get pods -l app=app-bo'
get_fo='kubectl -n app-prd get pods -l app=app-fo'
get_pods='kubectl get pods -n app-prd -o wide'
get_varnish='kubectl -n app-prd get pods -l app=varnish'
ssh_bo_fpm='kubectl -c app-fpm -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-bo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_bo_nginx='kubectl -c app-nginx -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-bo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_fo_fpm='kubectl -c app-fpm -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-fo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_fo_nginx='kubectl -c app-nginx -n app-prd -it exec $(kubectl -n app-prd get pods -l app=app-fo -o json | jq -r .items[0].metadata.name) -- bash'
ssh_varnish='kubectl -c varnish -n app-prd -it exec $(kubectl -n app-prd get pods -l app=varnish -o json | jq -r .items[0].metadata.name) -- bash'
varnish_flush='kubectl -n app-prd get pods -l app=varnish -o name | xargs -I{} kubectl -c varnish -n app-prd exec {} -- varnishadm "ban req.url ~ ."'
Close Menu

OÙ NOUS TROUVER


PARIS

Bâtiment Crisco Duo
7 avenue de la Cristallerie
92310 Sèvres

NANTES

Centre d’affaires Euptouyou
4 rue Edith Piaf Immeuble Asturia C
44800 Saint-Herblain

TÉLÉPHONE

01 46 48 26 00

EMAIL

[email protected]