konveyor / tackle2-addon-jkube

Tackle (2nd generation) addon for generating K8s manifests for Java applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tackle2 Addon Jkube

This project exposes JKube's kubernetes-maven-plugin as an addon for Tackle2, enabling Java applications with Maven integration to have container image and Kubernetes manifests built for them.

This addon focus on two tasks:

  • Generates container images with flexible and powerful configuration.
  • Generates vanilla Kubernetes descriptors (YAML files).

It leverages the Kubernetes Maven plugin to generate container image and Kubernetes manifests.

Development

To browse code - Open in VSCode

We use tackle2-hub addon package to integrate addon with tackle2-hub. Here is a good starter template to build an addon - Test Addon. Tackle Hub handles all requests to an addon via Task APIs and forward these requests to desired addon.

A simple request for an addon would look like this:

host="${HOST:-localhost:8080/hub}"

# Make a request to hub
request_cmd="$(curl -i -o - -X POST ${host}/tasks -d \
'{
    "name":"Jkube",
    "state": "Ready",
    "locator": "jkube",
    "addon": "jkube",
    "application": {"id": 2},
    "data": {}
}')"

In above request we mention addon: jkube as an addon identifier and application: {id: 2} states the application against which this addon will be executed. The data field here is empty because we are not accepting any data for this addon, but we can pass data during api request to addons which accepts data, and we use this struct to receive data for the addon.

Once a request is received - addon will fetch the application mentioned in the request and perform the operations defined in the addon. For this addon we perform following operations:

  • Fetch the application (clone GitHub/subversion repository)
  • Parse the maven config file and add kubernetes-maven-plugin to pom.xml
  • Build the application using maven build
  • Use kubernetes-maven-plugin to generate container image and k8s manifests
  • Commit the generated resources to repo

Development Environment Setup

Steps to successfully execute Jkube addon:

  1. Clone this repo

    https://github.com/konveyor/tackle2-addon-jkube.git
  2. Start a minikube environment and install tackle

    make start-minikube install-tackle
  3. Add Jkube addon to tackle - jkube addon

    kubectl apply -f hack/addon.yml
  4. Create an application in Tackle using this command

    host="${HOST:-localhost:8080/hub}"
    # Create an Application
    curl -X POST ${host}/applications -d \
    '{
        "createUser": "tackle",
        "name":"JkubeDemo",
        "description": "Spring Boot demo application.",
        "repository": {
          "name": "jkube_demo",
          "url": "https://github.com/mundra-ankur/jkube_demo.git",
          "branch": "main"
        },
        "businessService": {"id":1}
    }' | jq -M .
  5. Get an application id (required in step 7), list all applications using

    kubectl port-forward service/tackle-ui 8080:8080 -n konveyor-tackle
    curl -X GET localhost:8080/hub/applications | jq .
  6. Populate required data in tackle, including application against which addon will be executed - reference, jkube-data

    bash hack/task.sh
  7. Create task to run JKube addon against our application - task

    bash hack/task_ready.sh

Follow the Jkube Addon Demonstration for end-to-end setup and execution.

Reference - Windup Addon

For Windup addon, we have build an end-to-end pipeline to test the addon.

Here you will find everything you need to successfully execute an addon, we did it using GitHub actions. This pipeline is very loosely coupled, and you can utilize its pieces to create your own workflow, to test your addon quickly.

Output

  • Deployment artifacts
    • Dockerfile
    • Kubernetes Manifests

Jkube Addon Demonstration

Jkube_Addon_Demonstration.-.HD.1080p.mov

📽️ Watch on YouTube

About

Tackle (2nd generation) addon for generating K8s manifests for Java applications


Languages

Language:Go 82.1%Language:Shell 10.4%Language:Makefile 3.8%Language:Dockerfile 3.7%