Skip to content

Latest commit

 

History

History
135 lines (110 loc) · 3.15 KB

README.md

File metadata and controls

135 lines (110 loc) · 3.15 KB

skaffold-jib-demo

A command line tool that facilitates continuous development for Kubernetes applications.

Maven and Gradle plugins to build container images for your Java applications.

Kubernetes Dev Workflow without Skaffold + Jib

  1. Change source files
  2. Rebuild the project
  3. Build a Docker container locally
    • You need Dockerfile
    • You need Docker installed locally
  4. Run the container locally
  5. Push the built container to a remote container registry
  6. Deploy the container to the dev Kubernetes cluster
  7. Set up port forwarding
  8. Access http://localhost:<port>

Dev Workflow with Jib

  1. Change source files
  2. Rebuild the project. These steps are now gone:
    1. Build a Docker container locally
      • You need Dockerfile
      • You need Docker installed locally
    2. Run the container locally
    3. Push the built container to a remote container registry
  3. Deploy the built container to the dev Kubernetes cluster
  4. Set up port forwarding
  5. Access http://localhost:<port>
  • Setting up Jib for Gradle:
 plugins {
   id 'io.spring.dependency-management' version '1.0.6.RELEASE'
   id 'com.github.johnrengelman.shadow' version '4.0.0'
+  id 'com.google.cloud.tools.jib' version '0.10.0'
 }
  • Setting up Jib for Maven:
     <plugins>
+      <plugin>
+        <groupId>com.google.cloud.tools</groupId>
+        <artifactId>jib-maven-plugin</artifactId>
+        <version>0.10.0</version>
+      </plugin>
     </plugins>

Dev Workflow with Skaffold + Jib

  1. Change source files
  2. Access http://localhost:<port>

No need to use kubectl.

  • Setting up Skaffold for the whole project:
apiVersion: skaffold/v1beta1
kind: Config
build:
  artifacts:
  - image: gcr.io/chanseok-playground-new/java-frontend
    jibMaven: {}
    context: java-frontend
  - image: gcr.io/chanseok-playground-new/groovy-backend
    jibGradle: {}
    context: groovy-backend
  - image: gcr.io/chanseok-playground-new/nodejs-backend
    context: nodejs-backend
    sync:
      '*.js': .

Demo App Structure

Mono repo with 3 microservices written in different languages and frameworks.

Node.js Backend

Returns "Greetings from Node.js!"

Uses Dockerfile.

nodejs-backend/
├── Dockerfile
├── index.js
└── package.json

Groovy Backend

Returns "Greetings from Groovy!"

Uses Micronaut framework + Gradle + Jib.

groovy-backend/
├── build.gradle
└── src/main/
    └── groovy/backend/
        ├── Application.groovy
        └── WebController.groovy

Java Frontend

Accesses the two backends.

Uses Spark web framework + Maven + Jib.

java-frontend/
├── pom.xml
└── src/main
    ├── java/frontend/Frontend.java
    └── resources/static/index.html

Kubernetes YAML Files (Deployments and Services)

The usual YAML files you will have for Kubernetes deployement:

k8s/
├── nodejs-backend.yaml
├── groovy-backend.yaml
└── java-frontend.yaml

Skaffold Config

skaffold.yaml