Gradle Deployment to K8s

Use the gradle deployment plugin for in-tool-deployment

The gradle deployment plugin integrates smoothly with your existing Gradle Build Pipeline.
This is an opinionated plugin to deploy docker images and helm charts to kubernetes.

Deployment configurations are organised through profiles and directives.

Available directives are: dockerLogin,dockerBuild, dockerPush, deploy,helmPush

The plugin is build for a multi-module setup. You may define default values in the rootProject and customize them in the
subProjects

Requirements

  • helm is installed and available in path (only needed for deploy directive)
  • helmpush is installed and available in path (only needed for helmPush
    directive)
  • docker is installed and available in path

Quickstart

Per default the plugin expects your sources in the following directories:

Continue reading

You first container in Kubernetes

Get your docker image running in the MayopeCloud

We will start with a rather short introduction in kubernetes, create a namespace using the MayopeCloudConsole.
Using this namespace we will deploy a docker container and make it accessible from the internet.

What can I do with kubernetes?

Kubernetes is a tool to orchestrate containers. It enables you to run, configure, scale and connect them against each other.

Orchestrate containers

How does kubernetes archive this?

Kubernetes can be understood as a tool to connect multiple (physical or virtual) machines and enable them to share workloads.

Continue reading

Documentation as Code

Make Code a first class citizen!

Documentation as code states that you store the documentation of your
project/service at the same location where you store your code.
This has some clear advantages:

  • You don’t need to search for you documentation, everybody is aware where it is and how to extend it
  • You can update the documentation for an issue in the same pull/merge-request where you make the respective technical changes.
  • If the documentation uses the same quality process as code you can ensure its quality
  • You can make building the documentation part of your build process and therefore include test results,
    static code analyzer results, code documentation and so on in your documentation deployment.

The only downside is, that developers usually do not enjoy writing documentation and if you store it in your repository,
you are going to have a technical overhead for building and deploying the documentation.

Continue reading

Gradle as a Tool for monorepositories

Why do we need monorepositories in the first place?

This article does a great job in explaining what a monorepo is and why you may need it: What is a monorepo?

To summarize it you have a couple of advantages:

  • Single source of truth
  • Pull-Requests accross services are possible and reviewable in one pull request
  • Simplified code sharing accross services
  • Common build logic for all services

There are also some downsides for using a monorepository for example vsc scalability, cross team ownership or the temptation to introduce tight coupling between services.

Continue reading

Adding parameters to a Gradle plugin

Introduction

Last time I wrote about the basic setup of a Gradle plugin in Kotlin(Writing a Gradle plugin with Kotlin ).

This time we want to add some parameters to this plugin to make it more generic.

Basics

Gradle is a build automation tool from the java ecosystem. It has a lot of plugins for various use cases.

Buildfiles are describedin Groovy as default but Gradle recently added the possibility to also write build scripts in a Kotlin DSL.

Continue reading

Dependency Injection with Koin

What is dependency injection

Dependency injection is a technique to organize dependencies of services at runtime. If you have a really large application you may have encountered the problem of passing some objects down the whole stack and maybe using singletons and static method to overcome this.

But these are hard to substitute in Tests. Though to avoid this we let a framework organize these dependency issues for us. See Wikipedia .

Continue reading

Functional Kotlin starting from Java

This post is about the transition from Kotlin sourcecode that looks like java code to code that uses the functional Kotlin constructs.

Starting up

I will write about a completely made up class here but I experienced that you can do that with almost any class in the entire codebase.

Inspiration from the daily programmer: word funnel

Starting with Java

We start with the java implementation of the word funnel puzzle mentioned above

Continue reading

Migrate Keycloak like SQL

What is Keycloak?

Keycloak is an authorization provider that supports various authentication protocols. You can use it with OAuth, LDAP, Kerberos, etc.

It is based on the free WildFly application server.

Why is migration a Problem?

You can manage Keycloak through an admin ui, or with the provided REST-Api. Keycloak also supports realm export and import. So we could just track keycloak changes through the export file.

The difficulty of this approach is, that the realm export has to be done before starting the Keycloak server. This makes the export really difficult in some scenarios.

Continue reading

Null pointer in Kotlin

The Null Pointer Problem

Java devs have struggled withe the Problem of the NullPointerException for years and more years to come. It has been named the ‘Billion Dollar Mistake’ and it probably did cost something ranging in this number.

Kotlin is coming up with a pretty neat solutions to this old Problem. It does not prevent NullPonterExceptions completely but it warns you every time you are about to introduce code that could lend to this technical debt.

Continue reading

Operator Overloading in Kotlin

What is operator overloading?

Operator overloading has its root in the language C++. It means, that you can define the behavior if an operator (e.g. +, -, *, …) is applied to your type. (Wikipedia )

In C++ this looks like the following.

Given we have a class Vector containing a x and a y field as coordinates. We can define the operator plus + as follows:

    Vector operator + (Vector const &obj) { 
         Vector res; 
         res.x = x + obj.x; 
         res.y = y + obj.y; 
         return res; 
    } 

Continue reading