To working in devops, you have to develop a very wide breadth of knowledge just to be able to do your job. However because you need a braoder understanding, your knowledge tends to be shallower in places. For the past few weeks I’ve been working on a project to migrate our microservices into a Kubernetes cluster. I’d like to run you few a few of the things I’ve been working with.
it starts with springI started working on some Spring Java projects. The existing projects get most of their configuration from runtime flags. Since we run Docker containers in Kubernetes, we wanted to be able to modify the config from Kubernetes. This involved modifying the command we run within the Docker container to use environmental variables and also setting the defaults for those environmental variables. I started the process running a few vim find and replaces to see what the end result might look like. These quickly grew and with a bit of googling I ended up with the following:
This converts the entire existing command into the new format in one go and incidentally taught me way more about vim’s find and replace feature than I ever knew before.
%s, ,\r,g | %s,-D\(.*\)=,\U&,g | %s,\(\u\|\d\)\(\.\)\(\u\|\d\),\1\u_\3\u,g | %s,=,=", | %s,$," \\,g | %s,-D,,g %s, ,\r,g | %s,-D\([^=]*\)=\(.*\),-D\1=\$\U\1, | %s,\(\u\|\d\)\(\.\)\(\u\|\d\),\1\u_\3\u,g | %s,=\$,="\$,g | %s,.*=.*\u$,&",g | %s,$, \\,g
throw in some javaBecause of some major changes that had been made recently to a process tracking tool some of our projects failed to compile. It was now time to fire up Intellij, a Java IDE, and learn how to use it. Once I was up and running in Intellij I was with the help of some colleagues that know more Java than I do able to go through the code with and fix where it was broken. In the process I learned a bit more about how Java works and how to debug issues with it.
a smidge of log4jLogging in the Docker world is a bit different from before. While before we used to log to files in Docker, we now want to log to stdout and stderr. This avoids having to go into containers to see the log files. After some reading up on log4j I was able to write up a new log4j properties file that ensure that everything we logged went to console.
and now to drop some thingsI next started work on some Dropwizard projects. Dropwizard projects use a YAML configuration file. With the addition of a bit of a code you can get Dropwizard to lookup environmental variables. This, however, requires you to specify what your environmental variables are called in the YAML configuration file. Since I was parsing YAML, I turned to Python which has some modules to parse YAML with. Each variable name had to be unique, so I ended up having to learn the intricacies of how Python dictionaries and arrays worked. I came up with an elegant solution that ran down the layers of the YAML file before pushing the modified results up the chain untill the entire file was updated.
If you enjoyed the read, drop us a comment below or share the article, follow us on Twitter or subscribe to our #MetaBeers newsletter. Before you go, grab a PDF of the article, and let us know if it’s time we worked together.