mercredi 29 décembre 2021

mercredi 27 octobre 2021

Use GCP and gsutil to backup your archive files

I have the case of an old server, still running but already past the end of life. I needed to archive vzdump backups and virtual machine images just in case.

OS is too old to install GCP tools like gcloud and gsutil, but there is curl. So I can archive my files.

From my laptop, I can get my access token once the login is confirmed.

gcloud auth application-default login

gcloud auth application-default print-access-token

You received in response the access token to use with curl to upload the file to mybucket in Google Object Storage.

curl -v --upload-file vzdump-qemu-2210-2020_09_27-14_31_04.vma.gz -H "Authorization: Bearer access-token" https://storage.googleapis.com/mybucket/vzdump-qemu-2210-2020_09_27-14_31_04.vma.gz

Replace access-token and mybucket with your values. 

This way, I can externalize my backups and even try to provision some old machines as VM. Stay tuned.

mercredi 21 juillet 2021

Kubectl plugins the easy way

You know kubectl is today the Cloud console tool, the new SSH and bash and much more.

I use it every day and as always I only rely on my bash history and CTRL+R to find the last correct use.

For a long time, I read Ahmet Alp Balkan tweets about kubectl plugin but it sounds difficult.

Kubernetes the hard way, right?😁

(if you don't already follow Ahmet on Twitter)

So I was happy with my kubectl history until I assist to Paris Containers Day, especially 

Gaëlle Acas & Aurélie Vache's presentation check their video Kubectl plugin in a minute ! (in french)

Incroyable, it's super easy to create your kubectl plugin and they demonstrate in 4 steps :

  1. Create a file named kubectl-myfantasticplugin
  2. Make it executable, chmod +x kubectl-myfantasticplugin
  3. Move it into your PATH, mv kubectl-myfantasticplugin /usr/local/bin
  4. Run "kubectl myfantasticplugin"
You can create your plugin with any language and especially Go, Python, Rust, Quarkus or Bash.

Test yourself :
  1. copy kubectl-halloween bash script from their Github, 
  2. chmod +x kubectl-halloween 
  3. sudo mv kubectl-halloween /usr/local/bin/kubectl-halloween
  4.  kubectl halloween pod
  5. Get your emoji

NAME                                READY   STATUS    RESTARTS   AGE
🎃 my-nginx-5d59d67564-5q4mk           1/1     Running   0          4h52m
🎃 my-nginx-5d59d67564-5shv7           1/1     Running   0          4h52m
🎃 my-nginx-5d59d67564-nwrwk           1/1     Running   0          4h52m
🎃 nginx-deployment-66b6c48dd5-m9rdt   1/1     Running   0          11d
🎃 nginx-deployment-66b6c48dd5-vzw48   1/1     Running   0          11d

It's Awesome.
The best is to come. Now you know how to create kubectl plugins. 
You can create your own, use existing ones and share yours using Krew.

You can also create your own Krew index to share your kubectl plugin in your team, project or company.

And what to do with kubectl plugins ?
Everything ! View secrets, view certificate, resources utilizations, logs, and more.
Plugins are a great way to increase your agility and productivity.

Remember your old bash script, now it's a kubectl plugin and you can share it.

Find Gaelle and Aurelie slide deck, they explain everything better. 
Thank you for the inspiration.

Official documentation

And check Ahmet famous plugin