Remove the Complexity of Agent Configuration with GitHub Actions and Git Hooks

Post

Instana recently introduced GitOps based Agent Management to enable our customers to deal with the configurations of their Instana agents. GitOps Agent Management allows users to manage their agent configuration the same way they deal with code: strict versioning guarantees, using Git as the versioning system of choice, and automated rollout.

Every configuration passed to the Instana agent can be versioned, including pinning Instana to a specified version of their choosing and to which Instana backend or backends an agent should report to. Instana agents can report the same data to multiple backends, this is useful, for example, in migration scenarios as well as, for engineers, to test agents in parallel against multiple versions of the backend to avoid regressions. In the first build of GitOps, the Instana agent would update its configurations upon startup or restart, using a pull model. This was just the beginning. Instana agents are often long-lived, thanks to their capacity of automatically updating themselves with over-the-air updates, so it is natural to want to push configuration updates to the Instana agents on demand.

With this GitOps Agent Management update, notification can be pushed to the Instana agents to pull configuration updates. The integration within your DevOps workflow is straightforward, with a ready-made GitHub Action and sample Git Hook that automates the push notifications to the Instana backend.

But first, let’s dissect how configuration updates are triggered and how they take place.

Lifecycle of a configuration update

The diagram below shows how the update of agent configurations works with the new Git flow.

How The Update Of Agent Configurations Works With
^How the update of agent configurations works with the new Git flow.

The diagram shows two groups of Instana agents, organized in different agent zones: Production EMEA, and Production LATAM. Agent zones is a way you can set declarative groups for Instana agents according to how you subdivide your environments. If you do not provide custom zones, the Instana agent will use information available from the underpinning Cloud provider facilities (e.g, the availability zone on Amazon Elastic Cloud Computing).

Agents in both zones report into the same Instana backend, and fetch configurations from different branches of the Git repository hosting the agent configurations. When the team operating the agents push a change to the branch prod-emea of the Git repository, the Git repository automatically invokes the HTTP API of the Instana backend to notify agents in the prod-emea to update their configurations, which the Instana agents immediately do. Now, the last piece of the puzzle is “how do we make the Git repository call the Instana backend API?” This is where the new GitHub Action and the sample Git hook come into play!

GitHub Actions

According to GitHub, “GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.”

GitHub actions are organized in Workflows, allowing you to set up complex pipelines that automate acting upon changes to your GitHub repos, like creating releases, triggering the deployment of artifacts (like Instana agent configurations!) and so on.

The new Instana GitHub action for GitOps allows you to plug the trigger of agent configuration updates directly into your GitHub workflows. It is straightforward, our documentation and the GitOps Demo repository provide you with plenty of examples to get started. When you complete the setup, you will see something like this in your Git repository:

Word Image 297
^Automatic update of agent configurations via the GitHub action.

Using the GitHub action is an easy one-time setup, and with it, rolling out new configurations to your Instana agents is as easy as running a git push command to the right branch.

Git Hooks

When you run your own Git servers, like Gerrit Code Review, you can use Git hooks to execute programs in different phases of the lifecycle of git operations. For example, you may trigger your unit tests using a pre-commit hook or, more relevant to the use-case, have your Git server invoke the Instana backend API in a post-receive hook. We provide you an example to get started in the gitops-demo repository. The outcome is the same as the GitHub Action: easy one-time setup, and with it, rolling out new configurations to your Instana agents is as easy as running a git push command to the right branch. Below you see an example of what your prompt could look like when using the sample post-receive hook:

$ gitops-test# git push origin HEAD:main
[detached HEAD 9632c09] origin
1 file changed, 1 insertion(+), 1 deletion(-)
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 376 bytes | 376.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: GitOps update: Triggering the configuration update of agents matching the following query: 'entity.zone:"test"' ... OK
699ada9..9632c09 HEAD -> main

Notice that the outcome of the invocation of the Instana backend API is also returned to your git client (“remote: GitOps update: Triggering the configuration update of agents matching the following query: ‘entity.zone:”test”‘ … OK”), providing complete visibility.

Getting Started with Git-based configuration management

Don’t just take my word for it, though. You can get started with GitOps in your Instana instance today. If you don’t already have an Instana instance, check out Git-based configuration management with a free trial instance now. Once you see what automating the full monitoring lifecycle can do for you, you’ll wonder why anybody made you do it manually to begin with.

Play with Instana’s APM Observability Sandbox

Announcement, Developer, Product
Instana was founded to enable DevOps teams to tame the complexities of their cloud-native, microservices based applications. To that end, Instana created the first fully automated Application Performance Monitoring (APM) platform. Instana’s...
|

Start your FREE TRIAL today!

As the leading provider of Automatic Application Performance Monitoring (APM) solutions for microservices, Instana has developed the automatic monitoring and AI-based analysis DevOps needs to manage the performance of modern applications. Instana is the only APM solution that automatically discovers, maps and visualizes microservice applications without continuous additional engineering. Customers using Instana achieve operational excellence and deliver better software faster. Visit https://www.instana.com to learn more.