Saturday, April 18, 2020

The simplest GitlabCI pipline for building and deploying a java microservice to Google Cloud Run

I keep spending some of my free time playing around with Slack and specifically Slack bots. More to come on future posts but for now I can tell that I am amazed by the quality of the Slack Java SDK called Bolt.

In this post I want to share a very simple Gitlab-CI pipeline that I use for building and deploying my toy slack bot. It has 4 stages and each stage 1 step (very simple).
  • Build
  • Dockerise
  • Deploy to Google Cloud (Run) 
  • Notify a private Slack channel 
A side note regarding Gitlab-CI, I know my ex-colleague Kostis has some valid points and concerns :) regarding other CI/CD services out there and the amount of integration they offer to clouds like Google.

There is a case that this pipeline might change a bit in the future - since Gitlab is actually trying to simplify the integration between its shared runner / CI and clouds like google. Service Account definition or integration in the pipeline might become simpler and you might not be required to save JSON files in variables and then inject them on specific steps. For those interested on GitlabCI here is a list of issues that I am following their resolution

What you will need ( is also documented on the snippet):
  • A google cloud account and a project (usually you get one preconfigured)
  • Inside the project you need to enable Google Container Registry and Google Cloud Run Apis
  • I have created 2 separate Service Accounts, one with the appropriate rights on the project, that will allow my pipeline to push to my private container registry and the second one will allow the pipeline to make use of the gcloud cli and deploy/activate the new revisions of my Cloud Run application
  • A Slack channel / Webhook, so that I send deployment status notifications - once my bot is deployed
  • A bash script - on the root of the repo - more or less this one.

Monday, April 13, 2020

Keep track of your O.S dependencies - v2 - newreleases.io

For many years now I have been using artifactlistener to get updates on my mailbox on new releases or libraries and project that I use at work or on personal projects. It is a very decent service and I still use it. These were times that things like dependabot were still not a thing :) + I was mostly interested on the notifications side, rather than updating my deps automatically.

Since I'm using Slack a lot I was searching for something more friendly and integrated directly to it, instead of creating hooks and IFTT actions. I tried newreleases.io and I think is very very decent.

Here the main features currently .
  • Email and Slack notifications (multiple channels if you really want)
  • Telegram/Hangouts and some other channels for receiving notifications
  • Regular updates on projects hosted on different services from Github / Bitbucket etc
  • Custom build config files - can parse your build file and look up the projects.
  • Configuration over the notification settings .

Sweet!!

Sunday, April 12, 2020

A simple gitlab-ci pipeline, for a java project built with gradle, dockerized and pushed to a Google Container Registry

I have been working on a small personal project during these days (a silly slack bot). Usually I try to mix and match technologies that I am using at work, with stuff that I really enjoy and I have a very strong opinion. So I get to improve on stuff that I don't necessarily enjoy using day to day :P with stuff that I really like.

In this particular small post I want just to share a dead simple GitlabCI pipeline for a small service based on Java , built with gradle, dockerized and then pushed the image to a private registry on Google. You may ask why GCR, its part of my small project.

So we have
  • Java web api service, based on JDK 11
  • Built with Gradle 6.3
  • Has to be Dockerized and pushed to a private registry on Google Cloud.
  • It is hosted on gitlab and I am using Gitlab-CI (free).

Project Structure

You can assume the following standard structure. Java sources, gradle build script, a Dockerfile on the root of the folder + gitlab-ci.yml definition. I am not going to elaborate on the build script, code etc.


Pre-req

  • You need a Google Cloud account, and a new project configured (in this example the name of the project is called javapapo)
  • You need to enable the Docker Registry on Google Cloud for your project ( Enable the Container Registry API.) see here.
  • In order to be able to push to your private docker registry from a service like Gitlab, you need to a way to authenticate. There several options out there but it seems that most of the people do prefer to create a specific 'SERVICE_ACCOUNT', and then get a JSON token. See here

Pipeline

The source of the pipeline can be found on this Gitlab Snippet (its public. I have added inline comments.





Adding the service account JSON as a Base64 variable on the CI/CD settings of the project

References:

  • https://gist.github.com/foklepoint/2f9087375830068ec032ef326d93f423
  • https://github.com/JanMikes/gitlab-ci-push-to-gcr 
  • https://forum.gitlab.com/t/gitlab-ci-docker-template-credentials/23373
  • https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#making-docker-in-docker-builds-faster-with-docker-layer-caching
  • https://stackoverflow.com/questions/47280922/role-of-docker-in-docker-dind-service-in-gitlab-ci
  • https://medium.com/@gaforres/publishing-google-cloud-container-registry-images-from-gitlab-ci-23c45356ff0e


Friday, April 10, 2020

Starting all over again with DCS world - noob advice. #dcsworld



As you can imagine this post is all about flying, well simulator kind of flying. I have decided to kill some time on DCS World during this pandemic. I have been trying to improve as a pilot and fighter in general but obviously I was not taking it very seriously. The thing with a simulator like DCS is that you need to invest time, reading about the planes, doing the tutorials, learning about the strengths of your jet, reading about RADAR capabilities, weapons configs and of course practise. 

Yes of course, you can ignore all of that and just try the easy game mode with one of the free (planes) that come with the game - but if you are like me a fighter-jet junkie it is not enough. When you start discovering the list of available modules (jets) you most probably going to find your favourite and then you will buy it. But this just the start. When you install the module and you start the game inside the cockpit of a Sukhoi 27 or an F15 or an F18 its not easy any-more, it needs time. Learn the switches, learn the cockpit, find out about this and that. But I guess this is the beauty of it. DCS is definitely a game for people that want to get as close as possible to experience the complexity and challenge of being a fighter pilot from the comfort of their office desk or play room.

For those of you that you want to give it a try here is my noob advice - level 1. 
  • You need a decent gaming PC - but you don't have to spend thousands of euros, my Hades NUC is actually coping very well.
  • The game itself is free! You download the small installer and then you wait a bit - since you need to torrent the real thing. It needs some serious space on your hard-drive, watch out.
  • You can install it through Steam as well, I opted to download the game separately.
  • Once you are ready - the free package contains 2  jets and 1 area map
    • Sukhoi Su-25T Frogfoot & TF-51D Mustang
  • Then sky is the limit in terms of adding new maps, missions and modules. 
  • I would recommend you add the Flaming Cliffs 3 package. It will give you a bunch of sexy Russian fighters and plenty of action.
    • Later on you can expand - sometimes some modules they do have discounts etc, so you can add modern US jets like the F18 or F15 or the F16, or try to feel a bit like Maverick and buy the F14 Tomcat (it seems that is very popular judging from the videos of people on youtube).
  • After my first week trying to fly the SU25 or the SU27 using my keyboard it was obvious that I needed a HOTAS setup. Sky is the limit again but since I am  not very good and I have countless hours of practise ahead of me  I started with some good enough but not super sophisticated gear. So I bought the Thurstmaster 16000M combo.  
 Once you have all the above - which I consider a good starting point if you really want to play seriously then here is my level 2 noob advice.
  •  Depending on how many modules you will buy it is more than certain that soon you will realise that you can not properly fly them. Yes you can have a good time crashing or firing a missile but that is all.
  • Pick one or 2 jets maximum and focus on them. Make note that mastering for example Russian jets is kind of different for some of the more sophisticated US jets. Obviously this is a simulator and many things depend on the level of detail and depth of each module. In many cases the developers have really provided a very deep experience on all levels, the flight model, the radar model, the avionics etc etc. 
  • When you add a jet fighter module it usually comes with training - sessions. Go through the training!  They are really good, most of them you have a scripted voice over telling you what to do, what to press and showing you everything on the cockpit. I still find my self doing training sessions - until I kind of remember all the sequences and the procedures!
  • While going through the training sessions and assuming you have a HOTAS combo installed- try to browse the forums ( just google) for key maps for your jet and your setup. Example here.
    • For example for me that I am a Thrustmaster 1600M owner - I try to find profiles that match my device and the jet I am interested in. These profiles will configure your HOTAS on each jet and each button activate different functionality.,
      • TM16000Throttle - mirage2000.lua
      • TM16000Stick-F16.lua
Once you have reached the second maturity level where you have understood the complexity of the game and now you are seriously trying to configure your controls, you are comfortable searching for configs for your devices and you go through the training missions - getting comfortable with your jet here is my level 3 noob advice.

  • Start watching youtube - seriously. Here is a list of must have / follow channels
    • Grim Reapers. God bless this guy without his videos I would be lost. Start here there is a big list of tutorials and videos for almost every jet.
    • Growling Sidewinder: This is a bit more advanced but the videos are really helping me to understand tactics and dog fighting. Amazing work. 
  • Start reading about your jet, in my case this is the Mirage2000C so the more you know about the specific jet capabilities and especially its RADAR the better.
    • Try to find guides that will you help you - For example Mudspike - Chuck's guides is a great place to start and download information. 
  • Watching the various videos and reading these guides or parts of them - try to replay the tutorials and make notes. In order to be competent - you need to come close to a fighter pilot routine where is like 100% familiar with all the buttons and procedures and the jet is like an extension of himself. I guess going through this process I can understand how complex and difficult it is to be a fighter pilot - the workload and the amount of information you need to process is too big and at the same time you need to fight. 
    • Also, I really started to understand how automation on this field and especially on the cockpit or on the capabilities of the radar can actually be a game changer factor and sometimes give you the advantage over other more competent pilots but with less advanced jets on electronics.
Last but not least, practise, practise practise. By the way I am still doing all the above and I am slowly starting now to understand the limitations of my jet. In think in this past week I managed to fully understand my radar and start discovering targets and locking them or using the weapons. Is a long process but at the same time I make pauses and I do read about stuff that I have not before despite being a fighter jet junkie. Radar details, the Doppler effect, specifics of INS, GPS details and obviously flying.

 
Currently I dont dare to go on public servers - I still struggle to properly dog fight the AI of the game so is going to be a looong process. But..fights on!

  

Saturday, March 14, 2020

Ah these wallpapers...

 original photo here.

I remember the old days where I used to collect HD wallpapers. Spending hours and hours on different sites (do you remember devianart), trying to find stuff that I like and making sure this 'wallpapers' folder was always backed-up. I had multiple copies of it on CDs and then DVDs and then somewhere online. It is kind of funny how our taste changes over the years and that is reflected to our wallpapers collection as well.

Kind of similar effect like the one we have with our tast for clothes as we grow older. Anyway, its been like years now that I have abandoned that 'wallpapers' folder. I must have deleted it actually from the last resort backup - some Amazon S3 folder, all these pics were not me anymore. I also got tired, I dont have so much free time either, think we all have better things to do.

Here is a thing though, when I was young enough and I had enough free time to spend on wallpaper collection (like many of you did, I know that) I could not afford a good or big monitor. Now that I can afford a big curved HD Samsung monitor and I really love it, I really need some nice backgrounds. Damn it!

One thing that changed over the years is that I kind of funcy change, like fck yeah change this desktop wallpaper every few hours why not , as long as it is a decent image of some sort. The old days where my wallpapers were only HD photos of fighter jets are long gone - but I do miss sometimes my Mirage 2000 over the Aegean Sea collection.


For a long time I used to rely on Kuvva Wallpapers. I loved it, actually I was mind blown, so many nice pics and the app was so nice. I think at some point the app stopped being free  or something happened (i can not remember) and I had to pick something else.

In the past one or two years I have been using Unsplash Wallpapers on the Mac and for my Windows10 Gaming NUC - which I regurarly find myself updating it and stuff - I discovered Splashy for Windows. I think they work both very nice and they deliver good wallpapers.

If you have any recommendations of similar Wallpaper Rotation apps - leave a comment here or on twitter @javapapo.



Thursday, January 30, 2020

tfenv - a must have terraform version manager!

As a mac user and active developer I use a lot of package managers, update managers etc.

Most of the people would be familiar with things like:
  1. homebrew
  2. sdkman (for JVM developers)

If you happen to be like me and use Terraform, then I have only nice things to say about tfenv. Not sure if you have ever struggled to jump around different terraform stacks,that had different terraform version requirements. Hopefully this challenge will gradually fade out with the wide adoption of 0.12 but is still a case. Maybe a stack is still using 0.11 and your new stuff 0.12. Maybe you found that there is a bug on a minor version for your aws provider and you want to re-run your stack with the previous minor version?

https://github.com/tfutils/tfenv

A true productivity gem :)  - deserves a star!


Saturday, January 18, 2020

Διαβάζει κανείς blog; ποιός ξέρει.

Αναρωτιέμαι πολλές φορές αν ο κόσμος συνεχίζει να διαβάζει blog. Καταραμένη Google όταν μας έκοψες το Google Reader χάλασες όλη την φάση. Νιώθω ενοχές που δεν γράφω τόσο συχνά. Το έχω γράψει και παλιά, όλα αυτά τα χρόνια έχουν περάσει πολλά post από το μυαλό μου και συνεχίζω να μην τα γράφω. Eλπίζω ότι το 2020 θα είμαι πιο παραγωγικός, τα ίδια έλεγα και την περασμένη χρονιά.

Το 2019 ήταν μια αρκετά περιπετειώδης χρονιά για μένα, ιδιαίτερα επαγγελματικά! Θέλω να γράψω κάποια στιγμή μερικά πράγματα αλλά επειδή ο κόσμος είναι μικρός ακόμα και εδώ στο Λονδίνο θα πρέπει να τα φιλτράρω κάπως. Το 2020 μοιάζει να ξεκινάει αντίστοιχα, θα δούμε. Αναρωτιέμαι αν διανύω μια  κρίση ταυτότητας - επαγγελματική.

Για την ώρα αποφάσισα να κλείσω οριστικά τον λογαριασμό μου στο Facebook και σκέφτομαι μαζί με την βοήθεια και παρέα φίλου να προσπαθήσω να επαναφέρω το papocast ή weekend geeks ή όπως άλλο το πούμε.  Δεν έχω ιδέα αν ο κόσμος ακούει πια podcast πόσο μάλλον ελληνικά podcast.  Vrypan παραμένω μελαγχολικά κολλημένος στην περίοδο που ήμουν ακροατής σου - μάλλον το μόνο ελληνικό podcast που άκουγα. 

Δειλά δειλά έχω ξεκινήσει να ακούω κάποια τεχνολογικά podcast ξανά

Eπιτέλους δίνω μια ευκαιρία στα audio books , συγκεκριμένα με το audible. Επιτέλους βρήκα μια καλή παρέα στα αργά και επίπονα για την ώρα (καταραμένη δίαιτα) τρεξίματα στο παρκο. Το πρώτο βιβλιο που φαίνεται ότι θα τελειώσω σύντομα δεν είναι άλλο από το Permanent Record του E.Snowden. Εχω κατά ενθουσιαστεί με την όλη εμπειρία του audio book αλλά και τον ίδιο τον Snowden.

Τέλος, ανακάλυψα τυχαία μια μπάντα που μου θυμίζει αρκετά τους αγαπημένους Opeth , πάω στοίχημα οι γνώστες τους ξέρουν ήδη. Soen.

 Χαιρετισμούς απ' το δροσερό Λονδίνο.