Giter VIP home page Giter VIP logo

Comments (6)

arman-yekkehkhani avatar arman-yekkehkhani commented on August 23, 2024 1

@wjmwss Here is a minimal build script with similar configurations. I assume the Kotlin API may not be fully covered yet, so you can follow a general approach using builders to build your config object incrementally.

import org.eclipse.jkube.kit.common.Assembly
import org.eclipse.jkube.kit.common.AssemblyConfiguration
import org.eclipse.jkube.kit.common.AssemblyFileSet
import org.eclipse.jkube.kit.config.image.ImageConfiguration
import org.eclipse.jkube.kit.config.image.build.BuildConfiguration

plugins {
    id("java")
    id("org.eclipse.jkube.kubernetes") version "1.16.2"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(platform("org.junit:junit-bom:5.9.1"))
    testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
    useJUnitPlatform()
}

kubernetes {
    val assemblyConfig = AssemblyConfiguration.builder()
            .targetDir("/deployments")
            .layers(listOf(Assembly.builder()
                    .fileSets(listOf(AssemblyFileSet.builder()
                            .directory(file("${project.rootDir}/build/dependencies"))
                            .build())
                    ).build()))
            .build()

    val buildConfig = BuildConfiguration.builder()
            .from("quay.io/jkube/jkube-java:0.0.13")
            .assembly(assemblyConfig)
            .env(mapOf(
                    "JAVA_LIB_DIR" to "/deployments/dependencies/*",
                    "JAVA_MAIN_CLASS" to "org.apache.camel.cdi.Main",
            ))
            .labels(mapOf(
                    "labelWithValue" to "foo",
                    "version" to "${project.version}",
                    "artifactId" to project.name,
            ))
            .ports(listOf("8787"))
            .build()

    val image = ImageConfiguration.builder()
            .name("jkube/${project.name}:${project.version}")
            .alias("camel-service")
            .build(buildConfig)
            .build()

    images = listOf(image)
}

from jkube.

rohanKanojia avatar rohanKanojia commented on August 23, 2024

@wjmwss : Hello, Could you please share more details on what you're trying to do? What configuration option do you want to use?

from jkube.

arman-yekkehkhani avatar arman-yekkehkhani commented on August 23, 2024

@wjmwss Here is an article by Rohan to get started using Jkube with Gradle Get started with Gradle plugins for Eclipse JKube. You might need to make slight adjustments to build script to compensate for the difference between Groovy and Koltin DSL.

from jkube.

wjmwss avatar wjmwss commented on August 23, 2024

@wjmwss : Hello, Could you please share more details on what you're trying to do? What configuration option do you want to use?

Thank you for your reply!

I'm a beginner in gradle kotlin dsl and now I hope to use the 'org.eclipse.jkube.kubernetes' plugin to quickly deploy my spring boot project to kubernetes.

I have referred to the official documentation of this plugin, the example in the documentation are all using gradle groovy dsl, I encountered difficulties in converting it to gradle kotlin dsl:
581718955956_ pic

No matter what I try, I cannot convert the example gradle groovy dsl in the documentation to gradle kotlin dsl:
591718956264_ pic

Can you please provide a complete example of using the 'org.eclipse.jkube.kubernetes' plugin about gradle kotlin dsl?

Thank you!

from jkube.

wjmwss avatar wjmwss commented on August 23, 2024

@wjmwss Here is an article by Rohan to get started using Jkube with Gradle Get started with Gradle plugins for Eclipse JKube. You might need to make slight adjustments to build script to compensate for the difference between Groovy and Koltin DSL.

Thank you for your reply!

I'm a beginner in gradle kotlin dsl, my biggest problem currently is not knowing how to convert gradle groovy dsl to gradle kotlin dsl.

In the source code of 'KubernetesExtension', I see that many of the input parameters to the f
unction are 'Closure'. 'Closure' in my understanding belongs to groovy syntax, and it seems that kotlin cannot be called?
601718956576_ pic

What can be called by kotlin is 'Action', and I see that all the functions of the 'KubernetesExtension', only the 'addImage' function use Action.
WX20240621-35926 PM@2x

Therefore, I cannot determine whether the 'org.eclipse.jkube.kubernetes' plugin supports kotlin DSL, and I am not sure if my understanding is correct.

from jkube.

wjmwss avatar wjmwss commented on August 23, 2024

@wjmwss Here is a minimal build script with similar configurations. I assume the Kotlin API may not be fully covered yet, so you can follow a general approach using builders to build your config object incrementally.

import org.eclipse.jkube.kit.common.Assembly
import org.eclipse.jkube.kit.common.AssemblyConfiguration
import org.eclipse.jkube.kit.common.AssemblyFileSet
import org.eclipse.jkube.kit.config.image.ImageConfiguration
import org.eclipse.jkube.kit.config.image.build.BuildConfiguration

plugins {
    id("java")
    id("org.eclipse.jkube.kubernetes") version "1.16.2"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(platform("org.junit:junit-bom:5.9.1"))
    testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
    useJUnitPlatform()
}

kubernetes {
    val assemblyConfig = AssemblyConfiguration.builder()
            .targetDir("/deployments")
            .layers(listOf(Assembly.builder()
                    .fileSets(listOf(AssemblyFileSet.builder()
                            .directory(file("${project.rootDir}/build/dependencies"))
                            .build())
                    ).build()))
            .build()

    val buildConfig = BuildConfiguration.builder()
            .from("quay.io/jkube/jkube-java:0.0.13")
            .assembly(assemblyConfig)
            .env(mapOf(
                    "JAVA_LIB_DIR" to "/deployments/dependencies/*",
                    "JAVA_MAIN_CLASS" to "org.apache.camel.cdi.Main",
            ))
            .labels(mapOf(
                    "labelWithValue" to "foo",
                    "version" to "${project.version}",
                    "artifactId" to project.name,
            ))
            .ports(listOf("8787"))
            .build()

    val image = ImageConfiguration.builder()
            .name("jkube/${project.name}:${project.version}")
            .alias("camel-service")
            .build(buildConfig)
            .build()

    images = listOf(image)
}

Your code example is very helpful to me, thank you so much!

from jkube.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.