Comments (6)
@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.
@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.
@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 : 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:
No matter what I try, I cannot convert the example gradle groovy dsl in the documentation to gradle kotlin dsl:
Can you please provide a complete example of using the 'org.eclipse.jkube.kubernetes' plugin about gradle kotlin dsl?
Thank you!
from jkube.
@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?
What can be called by kotlin is 'Action', and I see that all the functions of the 'KubernetesExtension', only the 'addImage' function use Action.
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 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)
- ImageNameTest: Unnecessary 'toString()' call HOT 2
- KarafHealthCheckEnricher: Unnecessary 'toString()' call
- HelmServiceInstallIT is failing on Windows HOT 1
- DeploymentConfigHandlerTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 1
- KubernetesResourceUtilTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 2
- ProbeHandlerTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 1
- ServiceHandlerTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 1
- CronJobHandlerTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))`
- Fix failing Eclipse JKube Dependencies Check Jenkins Pipeline
- PortForwardService : Anonymous `new Thread()` can be replaced with `new Thread(() -> {…}) ` HOT 3
- WebAppGeneratorTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 1
- BuildRecreateMode: Remove unnecessary `private` modifier in enum constructor HOT 1
- ImageNameTest : refactor `namesUsedByDockerTests()` test into two separate tests HOT 1
- ControllerViaPluginConfigurationEnricherTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 7
- IngressEnricherTest : Replace AssertJ's deprecated `asList()` DSL method with `asInstanceOf(InstanceOfAssertFactories.list(type.class))` HOT 4
- MicronautGenerator not getting invoked for Micronaut4 Maven project
- Bump Jolokia version used in images to 2.1.0
- Release Eclipse JKube 1.18.0
- `k8s:resource` doesn't automatically pick up port from Micronaut `application.properties` HOT 1
- [Maven Quickstarts]: hello-world curl request fails HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jkube.