k8s
This visualization is a reference cheat sheet for command-line workflows, primarily centered on Kubernetes cluster management, SSH key handling, and Docker operations. It presents plain-text code snippets and terminal output showing commands like `kubectl config get-contexts`, `ssh-add -l`, and `docker build`, along with the expected results. The examples cover additional utilities such as `git diff`, `rsync`, `ffmpeg` encoding, and PDF conversion with `convert` and `montage`. The data shown is static text and command outputs, not a graphical rendering, so no visualization libraries are used.
AI-generated descriptionk8s
Get available contexts
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
docker-for-desktop docker-for-desktop-cluster docker-for-desktop
* matchboxaks matchboxaks clusterUser_rolexorg-rg_matchboxaks
minikube minikube minikube
portfolioaks portfolioaks clusterUser_portfolio-rg_portfolioaks
rolexorgaks rolexorgaks clusterUser_rolexorg-rg_rolexorgaks
Set context
$ kubectl config use-context docker-for-desktop
See how it is going
$ kubectl cluster-info
SSH
List active ssh-agent keys
$ ssh-add -l
2048 SHA256:5g46yzdbvsjFlfrzirtysaifXjV1ovjqk5g0cJoSDAM /Users/abernier/.ssh/id_rsa (RSA)
Add a key to ssh-agent
$ ssh-add ~/.ssh/bitbucket_rsa
NB: we add here the private key bitbucket_rsa (not the public one)
Remove a key from ssh-agent
$ ssh-add -d ~/.ssh/bitbucket_rsa
Test a connection
see: https://help.github.com/en/articles/using-ssh-over-the-https-port
$ ssh -T git@bitbucket.org
logged in as abernier_
or on another port:
$ ssh -T -p 7999 git@bitbucket.rlx-prod.com
Docker
nyancat from Ubuntu v18.04
docker build -t foo - <<EOF && docker run -it foo --rm
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y nyancat
ENTRYPOINT ["nyancat"]
EOF
list processus running on a port
lsof -i :4444
vpnkit 52904 abernier 24u IPv4 0x815ff215ffa91625 0t0 TCP *:krb524 (LISTEN)
vpnkit 52904 abernier 25u IPv6 0x815ff2160369a455 0t0 TCP localhost:krb524 (LISTEN)
and kill them:
kill -9 $(lsof -ti :4444)
patching
$ diff file_v1 file_v2 >file_v2.patch
them applying it:
patch file <file_v2.patch
git
diff between 2 commits
git diff -w <commitA>..<commitB> path/to/*.html
- NB1:
git logto grab<commitN> - NB2:
-wfor ignoring whitespaces changes
Patch
See: https://stackoverflow.com/questions/3418277/how-to-apply-git-diff-patch-without-git-installed
Generate:
git diff > patchfile
Apply (without git):
patch -p1 <patchfile
chmod
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
rsync 2 folders
rsync -av --delete --exclude .git --exclude .DS_Store folderA/ folderB/
or syncing local <=> remote
rsync -av --delete --exclude .git --exclude .DS_Store ~/Sites/quick-front/dist/ dev@5emeg.com:/home/projects/www/quick-front/web/
.bash_profile
# Path
PATH=${HOME}/bin:${PATH}
# Editor
export EDITOR='subl -w'
git tag
<increment package.json.version>
git add package.json
git commit -m "bump version"
git tag v0.1.4
git push --tags
npm private dependency
...
"dependencies": {
"myprivaterepo": "git+ssh://git@github.com/abernier/myprivaterepo.git#v0.1.4"
}
convert a multi-pages PDF to images
first install imagemagick:
brew install imagemagick
brew install ghostscript
brew link --overwrite ghostscript
brew reinstall imagemagick --build-from-source
then:
convert -alpha off -density 300 -depth 8 pages.pdf -resize 25% -background white -quality 95 pages_%02d.jpg
montage -mode concatenate -tile 2x pages_*.jpg pages.jpg
merge sereval PDFs together
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=filemerged.pdf file1.pdf file2.pdf
install rbenv
brew install rbenv ruby-build
Then add eval "$(rbenv init -)" line to your ~/.bash_profile
Then :
source ~/.bash_profile
rbenv install -l
rbenv install 2.1.1
rbenv global 2.1.1
rbenv version
2.1.1 (set by /Users/antoinebernier/.rbenv/version)
create a file
cat <<EOF > hi.txt
hi,
there!
EOF
Test gzip compression (outputs bytes)
gzip -c filename.min.js | wc -c
Exec amélioré (le nom du fichier est transmis à xargs et dispo sous $0 dans la commande sh)
find . -name "*.txt" -print0 | xargs -0 -I '{}' sh -c 'echo $0' '{}'
ffmpeg
INSTALL
On mac:
brew install ffmpeg --devel --with-libvpx b--with-fdk-aac
or with static version (see: https://gist.github.com/abernier/bbe6e3f8fa2b96b593731d55956a09a8):
curl -o- https://cdn.rawgit.com/abernier/bbe6e3f8fa2b96b593731d55956a09a8/raw/89b3c4648f93f99a382f7a674af07bdabd0017cc/ffmpeg-4.0-install.sh | sh
HTML5 video encoding
see: https://gist.github.com/Vestride/278e13915894821e1d6f
<video>
<source src="myvid.webm" type="video/webm; codecs=vp9,vorbis">
<source src="myvid.mp4" type="video/mp4">
</video>
ffmpeg -i myvid.mov -vcodec h264 -acodec aac -pix_fmt yuv420p -profile:v baseline -level 3 myvid.mp4
ffmpeg -i myvid.mov -vcodec libvpx-vp9 -b:v 1M -acodec libvorbis myvid.webm
rotate
ffmpeg -i in.mov -vf "transpose=1" out.mov
with:
0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip
see: http://stackoverflow.com/a/9570992/133327
lossless crop
ffmpeg -i in.mov -filter:v "crop=out_w:out_h:x:y" -c:v libx264 -crf 0 -c:a copy out.mp4
with:
out_w-- width of the output rectangleout_h-- height of the output rectanglex,y-- top left corner of the output rectangle
see: http://video.stackexchange.com/a/4571 and https://stackoverflow.com/questions/33378548/ffmpeg-crop-a-video-without-losing-the-quality
scale
ffmpeg -i in.avi -vf scale=320:-1 out.avi
see: https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg
trim
without re-encoding
ffmpeg -i in.mp4 -vcodec copy -acodec copy -ss 00:01:00.000 -t 00:00:10.000 out.mp4
with:
-ss-- start time-t-- duration
screenshot
ffmpeg -i in.mp4 -ss 00:00:05.000 -vframes 1 out.png
or in JPG
ffmpeg -i in.mp4 -ss 00:00:05.000 -vframes 1 -q:v 1 out.jpg
q:v between 1 and 31 (1 being the highest)
Convert all xvid videos found into mp4
cd /Volumes/TRANSCEND && find . \( -iname '*.avi' -o -iname '*.divx' \) -exec bash -c 'ffmpeg -i $0 -c:v libx264 -crf 19 -c:a aac -b:a 192k -ac 2 ${0%.*}.mp4' {} \;
Remove sound
ffmpeg -i myvid.mp4 -c copy -an myvid-nosound.mp4