K8S utilities


License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.saiprasadkrishnamurthy
ArtifactId

ArtifactId

k8s-utils-maven-plugin
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

K8S utilities
K8S utilities
Project URL

Project URL

https://github.com/SaiprasadKrishnamurthy/k8s-utils-maven-plugin
Source Code Management

Source Code Management

https://github.com/SaiprasadKrishnamurthy/k8s-utils-maven-plugin.git

Download k8s-utils-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.saiprasadkrishnamurthy</groupId>
    <artifactId>k8s-utils-maven-plugin</artifactId>
    <version>1.2</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.commons : commons-configuration2 jar 2.7
com.github.ulisesbocchio : jasypt-spring-boot-starter jar 2.1.1
org.yaml : snakeyaml jar 1.24
commons-io : commons-io jar 2.6

provided (3)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.6.0
org.apache.maven : maven-core jar 3.6.0
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5

Project Modules

There are no modules declared in this project.

Kubernetes Deployment Generator for Spring Boot apps.

This maven plugin acts as a bridge between your spring-boot app and kubernetes and generates the necessary Kubernetes deployment descriptors, config maps and utility shell scrips simply by extracting the application.properties and your maven metadata.

Usage in your pom.

        <plugin>
                <groupId>com.github.saiprasadkrishnamurthy</groupId>
                <artifactId>k8s-utils-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>generate-kubernetes-deployment-descriptors</id>
                        <goals>
                            <goal>generate-deployment</goal>
                        </goals>
                        <configuration>
                            <dockerImageNamespace>dockerhub.com</dockerImageNamespace>
                            <dockerImagePrefix>appname</dockerImagePrefix>
                            <replicas>1</replicas>
                            <volumeMount>/mymount</volumeMount>
                        </configuration>
                    </execution>
                </executions>
         </plugin>

Pass the relevant parameters above in your section. This plugin gets kicked off during the prepare-package phase by default.

Once this is run, you'll find target/k8s directory created.

Let's assume if your spring boot application has the following structure of application properties.

src
    main
        resources
            application.properties
            application-local.properties
            application-dev.properties
            application-test.properties
            application-staging.properties
            application-prod.properties

For every spring environment profile (local, dev, test, staging, prod), a pair of Kubernetes files would be created

  • <application_name>-deployment- yml
  • <application_name>-configmap-.yml

Assume your project's artifact id is: user-search-service

target
     k8s
        user-search-service-deployment-local.yml
        user-search-service-configmap-local.yml
        user-search-service-deployment-dev.yml
        user-search-service-configmap-dev.yml
        user-search-service-deployment-test.yml
        user-search-service-configmap-test.yml
        user-search-service-deployment-staging.yml
        user-search-service-configmap-staging.yml
        user-search-service-deployment-prod.yml
        user-search-service-configmap-prod.yml

In addition to that, 3 utility shell scripts would be created:

  • deploy_configs.sh - Script that helps you to deploy a specific environment specific config map for this service using kubectl.
  • deploy_service.sh - Script that helps you to deploy a specific environment specific deployment for this service using kubectl.
  • logs.sh - Script that helps you to tail the logs.

Versions

Version
1.2
1.1
1.0