Skip to content

Commit

Permalink
Add a sample for Jib
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Oct 22, 2018
1 parent 0cc1497 commit d114f70
Show file tree
Hide file tree
Showing 18 changed files with 296 additions and 12 deletions.
10 changes: 5 additions & 5 deletions examples/annotated-skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ build:
# bazel:
# target: //:skaffold_example.tar

# jibMaven is an artifacts built with Maven, typically (but not only) a Java project.
# jibMaven builds containers using the Jib plugin for Maven.
# jibMaven:
# module: modulename
# profile: profilename
# module: modulename # selects which maven module to build
# profile: profilename # selects which maven profile to activate

# jibGradle is an artifacts built with Gradle, typically (but not only) a Java project.
# jibGradle builds containers using the Jib plugin for Gradle.
# jibGradle:
# project: projectname
# project: projectname # selects which gradle project to build

# This next section is where you'll put your specific builder configuration.
# Valid builders are `local`, `googleCloudBuild` and `kaniko`.
Expand Down
2 changes: 1 addition & 1 deletion examples/bazel/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build:
bazel: # <2>
target: //:skaffold_example.tar # <3>
----
<1> make sure the workspace contains the bazel files (`WORKSPACE`, `BUILD`)
<1> make sure the context contains the bazel files (`WORKSPACE`, `BUILD`)
<2> add bazel to each artifact
<3> specify target - our builder will use this to load to the image to the Docker daemon

Expand Down
5 changes: 5 additions & 0 deletions examples/jib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
.classpath
.project
.settings
.vscode
31 changes: 31 additions & 0 deletions examples/jib/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== 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: {}
----

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::[]
29 changes: 29 additions & 0 deletions examples/jib/k8s/web.yaml
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

48 changes: 48 additions & 0 deletions examples/jib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>
</jvmFlags>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions examples/jib/skaffold.yaml
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: {}
11 changes: 11 additions & 0 deletions examples/jib/src/main/java/hello/Application.java
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);
}
}
12 changes: 12 additions & 0 deletions examples/jib/src/main/java/hello/HelloController.java
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!";
}
}
10 changes: 5 additions & 5 deletions integration/examples/annotated-skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ build:
# bazel:
# target: //:skaffold_example.tar

# jibMaven is an artifacts built with Maven, typically (but not only) a Java project.
# jibMaven builds containers using the Jib plugin for Maven.
# jibMaven:
# module: modulename
# profile: profilename
# module: modulename # selects which maven module to build
# profile: profilename # selects which maven profile to activate

# jibGradle is an artifacts built with Gradle, typically (but not only) a Java project.
# jibGradle builds containers using the Jib plugin for Gradle.
# jibGradle:
# project: projectname
# project: projectname # selects which gradle project to build

# This next section is where you'll put your specific builder configuration.
# Valid builders are `local`, `googleCloudBuild`, `kaniko`, and `acr`.
Expand Down
2 changes: 1 addition & 1 deletion integration/examples/bazel/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build:
bazel: # <2>
target: //:skaffold_example.tar # <3>
----
<1> make sure the workspace contains the bazel files (`WORKSPACE`, `BUILD`)
<1> make sure the context contains the bazel files (`WORKSPACE`, `BUILD`)
<2> add bazel to each artifact
<3> specify target - our builder will use this to load to the image to the Docker daemon

Expand Down
5 changes: 5 additions & 0 deletions integration/examples/jib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
.classpath
.project
.settings
.vscode
31 changes: 31 additions & 0 deletions integration/examples/jib/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== 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-jib
context: .
jibMaven: {}
----

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::[]
29 changes: 29 additions & 0 deletions integration/examples/jib/k8s/web.yaml
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

48 changes: 48 additions & 0 deletions integration/examples/jib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>
</jvmFlags>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions integration/examples/jib/skaffold.yaml
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: {}
11 changes: 11 additions & 0 deletions integration/examples/jib/src/main/java/hello/Application.java
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);
}
}
12 changes: 12 additions & 0 deletions integration/examples/jib/src/main/java/hello/HelloController.java
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!";
}
}

0 comments on commit d114f70

Please sign in to comment.