Accelerating the Delivery of Your Project in the Cloud in an Easy and Intuitive Way
GitOps is one of the ways to implement CI / CD concepts for applications with a native focus on the cloud, mainly in the development time experience.
Join the DZone community and get the full member experience.Join For Free
Git is currently the most used version control within the software development world, and it is where all the code and logic of the programming are concentrated. However, it is not only from code that an application is lived. Thus, it is also necessary that there are operations settings such as database, security definition, public routes, etc. And if to simplify delivery, increase the frequency of deployments, and empower the development team, do we place operations as infrastructure as code through an interactive API within the same Git repository? With that goal, GitOps was born. This article will explore this topic by demonstrating its advantages and why a development team should get to know you to simplify your life in the cloud.
In Software, the Main Focus Is on Risk-free Delivery
Over the years of software development, the entire technology industry can experience different methodologies to deliver a program. In the beginning, there was the waterfall model, and one of the characteristics of that moment was the period to deliver a version. An annual delivery was widespread, and at that moment, an entire operation and a deployment window were needed, which took hours to complete the operation. This caused operations such as updating databases, languages, or some third-party software to be discouraged since a simple deployment means a very complex, risky, and costly operation.
Over time there was a need for product delivery to be more frequent, especially to achieve better communication with users. With the focus, above all, on delivering the software and breaking the silos between the development team and the user itself, the Agile Manifesto came to attack this type of problem.
As the methodology and the teams got more mature over time, it was possible to find other bottlenecks in the delivery, with the operations part. The first major reinforcement to assist was the popularization of the cloud and its various types of available services (of which the analogy between pizza and cloud is one of the most famous comparisons). The big point of the cloud is the reduction of complexity.
A good example, taking the example of pizza, would be a pizzeria to make all the ingredients within the recipe, for example, cheese, yeast, etc. This approach would result in enormous energy expenditure on what is not delivery, making pizza, not to mention complexity and risk. So, it makes a lot more sense for this pizzeria to delegate this type of delivery and focus directly on your business.
In addition to the cloud, there was also a need to deliver even more teams, mainly between development and operations. The DevOps culture was born in a combination of best practices for these two elements.
Over time, it is possible to realize that the key to development is the customer's interaction and the development team itself. Various strategies are defined with constant delivery and the product's evolution constantly and incrementally.
To further facilitate this integration of the development team and the operations team, GitOps emerged. The principle is to bring the entire configuration of the application, Git repository, so that all operations would be under this team's control. This approach brings several:
Git becomes the only source of truth: Instead of having the configuration code at various points, like Jenkins, inside a server, etc. This repository, in addition to the code, will contain the operations information.
Git becomes the only configuration point: In addition to the code, there are several cases where some service needs, for example, a database. With that, it will be possible to add such services or, eventually, update them.
Git will have all the observable changes: One of the great advantages of the operation being within a version control is the possibility of having all the changes in the code, including the operation, as a commit. For example, it is possible to carry out a commit with a database update or a JVM update, and if there is no problem, it will be possible to revert the option and return to the original state.
A natural evolution of IaC: By using GitOps, you will naturally benefit from all the infrastructure points like code, IaC, how to reduce management overhead, make the application life cycle more efficient and bring speed and consistency within the operations.
A declarative API: a natural path of software development is the change from an imperative to declarative API, and GitOps meets this concept by informing exactly what resources and services the application needs.
CI/CD: One of the most famous concepts of GitOps is that GitOps is the meeting of CI / CD in cloud-native. The point is that this whole process happens more intuitively since, using techniques such as feature-branch, it is possible to test and observe each feature through a Pull Request. If it is tested and approved as soon as the merge for the branch is made, the code will be available to users shortly afterward.
GitOps in Real Life Is More Complicated Than It Looks
To make a successful GitOps solution it is necessary to configure several parts. They are often patched using Kubernetes, kubectl, Helm, OpenShift, Docker Swarm, Mesos, or Rancher connected to Jenkins, Travis CI, or Circle CI, in addition to an ELK stack.
However, until reaching this point of state of art there is a colossal complexity. And an important point of analysis when talking about architecture in the cloud environment is the relationship between complexity and risk. That is, the greater the complexity, the greater the risk of implementing the environment.
One way to reduce and prevent this complexity is to use cloud services that allow for greater abstraction. A greater abstraction decreases the complexity, which, in turn, the risk of implementing both GitOps and cloud operations purely.
Welcome Era of Services
As we already mentioned, one of the great advantages besides reducing the risk with a greater layer of abstraction is the focus. The previous example of the pizzeria focuses on making pizza instead of also worrying about making the ingredients. Giving priority to what is the company's core business, in addition to agility, guarantees delivery quality in addition to reduced time.
One way to do this is by using services that provide simplicity making the team have the main focus on delivering the project. Using a declarative API, the application will declare everything it needs. This type of service will manage the installation, creation, configuration, and trivial operations like security and credentials.
Platform.sh is the second generation of PaaS whose premise is to work with GitOps; that is, the development team realizes the needs of the application within the repository, and once it sends to the remote branch, every process is carried out until the deployment without any intervention from the operating team.
In general, to deploy to the cloud, three configuration files are required, in this case, Yaml files, and each file has a specific responsibility:
Application: this file will define information on how to build and build an application. It is also from there that it defines permission between services that the application will use from other applications (considering microservices).
Services: services that your application needs, such as database, messaging, or cache, are configured in this file.
Routes: Where routes are configured and which applications will have access to the public. It is possible to define several points, for example, the application cache and redirection.
To connect an application with the services, it is possible to use the best practices of the Twelve-Factor App, that is, overwriting the properties at the time of production with graces so that this change is transparent to the application, not to mention that the development team will not need to know the database user credentials and password, for example.
It is important to note that this type of superscript is supported by the most famous Java world frameworks, such as Micronaut, Quarkurs, Jakarta EE / MicroProfile, and Spring. With that, it is possible to migrate or create a new application and make it easier; there is a guide for the Java world's main frameworks.
GitOps allows an evolution within software development, ensuring greater empowerment to the development team, thanks to a declarative API. In addition to the team's proximity to the application code and infra information in a single point. This technique allows the breaking of silos between the teams and the customer and decreases the delivery time of the product, further facilitating the digital transformation of a company.
Opinions expressed by DZone contributors are their own.