-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jib sample #1147
Jib sample #1147
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target | ||
.classpath | ||
.project | ||
.settings | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== Example: Jib | ||
:icons: font | ||
|
||
Jib is one of the supported builders in Skaffold. | ||
[Jib](https://github.com/GoogleContainerTools/jib) builds Docker and OCI images | ||
for your Java applications and is available as plugins for Maven and Gradle. | ||
|
||
The way you configure it in `skaffold.yaml` is the following build stanza: | ||
|
||
[source,yaml] | ||
---- | ||
build: | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/skaffold-example | ||
context: . | ||
jibMaven: {} | ||
---- | ||
|
||
Please note that this example is for a standalone Maven project, where | ||
all dependencies are resolved from outside. The Jib builder requires | ||
that the projects are configured to use the Jib plugins for Maven or Gradle. | ||
Multi-module builds require a bit additional configuration. | ||
|
||
ifndef::env-github[] | ||
==== link:{github-repo-tree}/examples/jib[Example files icon:github[]] | ||
|
||
[source,yaml, indent=3, title=skaffold.yaml] | ||
---- | ||
include::skaffold.yaml[] | ||
---- | ||
|
||
[source,xml, indent=3, title=pom.xml, syntax=xml] | ||
---- | ||
include::pom.xml[] | ||
---- | ||
endif::[] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: web | ||
spec: | ||
ports: | ||
- port: 8080 | ||
name: http | ||
type: LoadBalancer | ||
selector: | ||
app: web | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: web | ||
image: gcr.io/k8s-skaffold/skaffold-jib | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.skaffold</groupId> | ||
<artifactId>hello-spring-boot</artifactId> | ||
<version>0.1.0</version> | ||
<description>Spring Boot with Skaffold and Jib</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.0.5.RELEASE</version> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>hello</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>jib-maven-plugin</artifactId> | ||
<version>0.9.11</version> | ||
<configuration> | ||
<container> | ||
<jvmFlags> | ||
<jvmFlag>-Djava.security.egd=file:/dev/./urandom</jvmFlag> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of a funny bug: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6202721 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should also just include the other container-enabling JVM flags here too:
|
||
<jvmFlag>-XX:+UnlockExperimentalVMOptions</jvmFlag> | ||
<jvmFlag>-XX:+UseCGroupMemoryLimitForHeap</jvmFlag> | ||
</jvmFlags> | ||
</container> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: skaffold/v1alpha4 | ||
kind: Config | ||
build: | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/skaffold-jib | ||
jibMaven: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hello; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Application { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package hello; | ||
|
||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@RestController | ||
public class HelloController { | ||
@RequestMapping("/") | ||
public String index() { | ||
return "Hello, World!"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target | ||
.classpath | ||
.project | ||
.settings | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== Example: Jib | ||
:icons: font | ||
|
||
Jib is one of the supported builders in Skaffold. | ||
[Jib](https://github.com/GoogleContainerTools/jib) builds Docker and OCI images | ||
for your Java applications and is available as plugins for Maven and Gradle. | ||
|
||
The way you configure it in `skaffold.yaml` is the following build stanza: | ||
|
||
[source,yaml] | ||
---- | ||
build: | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/skaffold-example | ||
context: . | ||
jibMaven: {} | ||
---- | ||
|
||
Please note that this example is for a standalone Maven project, where | ||
all dependencies are resolved from outside. The Jib builder requires | ||
that the projects are configured to use the Jib plugins for Maven or Gradle. | ||
Multi-module builds require a bit additional configuration. | ||
|
||
ifndef::env-github[] | ||
==== link:{github-repo-tree}/examples/jib[Example files icon:github[]] | ||
|
||
[source,yaml, indent=3, title=skaffold.yaml] | ||
---- | ||
include::skaffold.yaml[] | ||
---- | ||
|
||
[source,xml, indent=3, title=pom.xml, syntax=xml] | ||
---- | ||
include::pom.xml[] | ||
---- | ||
endif::[] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: web | ||
spec: | ||
ports: | ||
- port: 8080 | ||
name: http | ||
type: LoadBalancer | ||
selector: | ||
app: web | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: web | ||
image: gcr.io/k8s-skaffold/skaffold-jib | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.skaffold</groupId> | ||
<artifactId>hello-spring-boot</artifactId> | ||
<version>0.1.0</version> | ||
<description>Spring Boot with Skaffold and Jib</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.0.5.RELEASE</version> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>hello</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>jib-maven-plugin</artifactId> | ||
<version>0.9.11</version> | ||
<configuration> | ||
<container> | ||
<jvmFlags> | ||
<jvmFlag>-Djava.security.egd=file:/dev/./urandom</jvmFlag> | ||
<jvmFlag>-XX:+UnlockExperimentalVMOptions</jvmFlag> | ||
<jvmFlag>-XX:+UseCGroupMemoryLimitForHeap</jvmFlag> | ||
</jvmFlags> | ||
</container> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: skaffold/v1alpha4 | ||
kind: Config | ||
build: | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/skaffold-jib | ||
jibMaven: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hello; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Application { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package hello; | ||
|
||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@RestController | ||
public class HelloController { | ||
@RequestMapping("/") | ||
public String index() { | ||
return "Hello, World!"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth mentioning that this example is for a standalone Maven project, where all dependencies are resolved from outside. The Jib builder requires that the projects are configured to use the Jib plugins for Maven or Gradle. Multi-module builds require a bit additional configuration.