v2.1
v2.0
v1.0
  1. Release Notes
    1. Release Notes - 2.1.1Latest
    1. Release Notes - 2.1.0
    1. Release Notes - 2.0.2
    1. Release Notes - 2.0.1
    1. Release Notes - 2.0.0
  1. Introduction
    1. Introduction
    1. Features
    1. Architecture
    1. Advantages
    1. Glossary
  1. Installation
    1. Introduction
      1. Intro
      2. Port Requirements
      3. Kubernetes Cluster Configuration
    1. Install on Linux
      1. All-in-One Installation
      2. Multi-Node Installation
      3. High Availability Configuration
      4. Air Gapped Installation
      5. StorageClass Configuration
      6. Enable All Components
    1. Install on Kubernetes
      1. Prerequisites
      2. Install on K8s
      3. Air Gapped Installation
      4. Install on GKE
    1. Pluggable Components
      1. Pluggable Components
      2. Enable Application Store
      3. Enable DevOps System
      4. Enable Logging System
      5. Enable Service Mesh
      6. Enable Alerting and Notification
      7. Enable Metrics-server for HPA
      8. Verify Components Installation
    1. Upgrade
      1. Overview
      2. All-in-One
      3. Multi-node
    1. Third-Party Tools
      1. Configure Harbor
      2. Access Built-in SonarQube and Jenkins
      3. Enable built-in Grafana Installation
      4. Load Balancer plugin in Bare Metal - Porter
    1. Authentication Integration
      1. Configure LDAP/AD
    1. Cluster Operations
      1. Add or Cordon Nodes
      2. High Risk Operations
      3. Uninstall KubeSphere
  1. Quick Start
    1. 1. Getting Started with Multi-tenancy
    1. 2. Expose your App Using Ingress
    1. 3. Compose and Deploy Wordpress to K8s
    1. 4. Deploy Grafana Using App Template
    1. 5. Job to Compute π to 2000 Places
    1. 6. Create Horizontal Pod Autoscaler
    1. 7. S2I: Publish your App without Dockerfile
    1. 8. B2I: Publish Artifacts to Kubernete
    1. 9. CI/CD based on Spring Boot Project
    1. 10. Jenkinsfile-free Pipeline with Graphical Editing Panel
    1. 11. Canary Release of Bookinfo App
    1. 12. Canary Release based on Ingress-Nginx
    1. 13. Application Store
  1. DevOps
    1. Pipeline
    1. Create SonarQube Token
    1. Credentials
    1. Set CI Node for Dependency Cache
    1. Set Email Server for KubeSphere Pipeline
  1. User Guide
    1. Configration Center
      1. Secrets
      2. ConfigMap
      3. Configure Image Registry
  1. Logging
    1. Log Query
  1. Developer Guide
    1. Introduction to S2I
    1. Custom S2I Template
  1. API Documentation
    1. API Documentation
    1. How to Access KubeSphere API
  1. Troubleshooting
    1. Troubleshooting Guide for Installation
KubeSphere®️ 2020 All Rights Reserved.

Binary to Image - Publish Artifacts to Kubernetes

Edit

What is Binary to Image

As similar as Source to Image (S2I), Binary to Image (B2I) is a toolkit and workflow for building reproducible container images from binary executables like Jar, War, binary package, etc. All you need to do is to upload your artifact, and specify the image repository such as DockerHub or Harbor to where you want to push. After you run a B2I process, your image will be pushed to the target repository and your application will be automatically deployed to Kubernetes as well.

How does B2I Improve CD Efficiency

From the introduction above we can see B2I bridges your binary executables to cloud native services with no complicated configurations or coding which is extremely useful for legacy applications and the users who are not familiar with Docker and Kubernetes. Moreover, with B2I tool, as said, you do not need to write Dockerfile, it not only reduces learning costs but improves publishing efficiency, which enables developers to focus on business itself. In a word, B2I can greatly empower enterprises for continuous delivery that is one of the keys to digital transformation.

The following figure describes the step-by-step process of B2I. B2I has instrumented and streamlined the steps, so it takes few clicks to complete in KubeSphere console.

B2I Process

  • ① Create B2I in KubeSphere console and upload artifact or binary package
  • ② B2I will create K8s Job, Deployment and Service based on the uploaded binary
  • ③ Automatically package the artifact into Docker image
  • ④ Push image to DockerHub or Harbor
  • ⑤ B2I Job will pull the image from registry for Deployment created in the second step
  • ⑥ Automatically publish the service to Kubernetes

Note: In the process, the B2I Job also reports status in the backend.

In this document, we will walk you through how to use B2I in KubeSphere. For more testing purposes on your own, we provide five artifact packages that you can download from the sites in the following tables.

Artifact Package (Click to download) GitHub Repository
b2i-war-java8.war Spring-MVC-Showcase
b2i-war-java11.war SpringMVC5
b2i-binary DevOps-go-sample
b2i-jar-java11.jar java-maven-example
b2i-jar-java8.jar devops-java-sample

Prerequisites

Hands-on Lab

In this lab, we will learn how to use B2I by creating service in KubeSphere, and how to automatically complete six steps described in the workflow graph above.

Step 1: Create a Secret

We need to create a secret since B2I Job will push the image to DockerHub. If you have finished S2I lab, you already have the secret created. Otherwise, log in KubeSphere with the account project-regular. Go to your project and create the secret for DockerHub. Please reference Creating Common-used Secrets.

Step 2: Create a Service

2.1. Select Application Workloads → Services, then click Create to create a new service through the artifact.

Create Service

2.2. Scroll down to Build a new service through the artifact and choose war. We will use the Spring-MVC-Showcase project as a sample by uploading the WAR artifact (b2i-war-java8) to KubeSphere.

2.3. Enter service name b2i-war-java8, click Next.

2.4. Refer to the following instructions to fill in Build Settings.

  • Upload b2i-war-java8.war to KubeSphere.
  • Choose tomcat85-java8-centos7:latest as the build environment.
  • Enter <DOCKERHUB_USERNAME>/<IMAGE NAME> or <HARBOR-PROJECT_NAME>/<IMAGE NAME> as image name.
  • Tag the image, for instance, latest.
  • Select dockerhub-secret that we created in previous step as target image repository: .

Build Settings

2.5. Click Next to the Container Settings and configure the basic info as shown in the figure below.

Container Settings

2.6. Click Next and continue to click Next to skip Mount Volumes.

2.7. Check Internet Access and choose NodePort, then click Create.

Internet Access

Step 3: Verify B2I Build Status

3.1. Choose Image Builder and click into b2i-war-java8-xxx to inspect B2I building status.

Image Builder

3.2. Now it is ready to verify the status. You can expand the Job records to inspect the rolling logs. Normally, it will execute successfully in 2~4 minutes.

Job Records

Step 4: Verify the resources created by B2I

Service

Service

Deployment

Deployment

Job

Job

Alternatively, if you want to use command line to inspect those resources, you can use web kubectl from the Toolbox at the bottom right of console. Note it requires cluster admin account to open the tool.

Web Kubectl

Step 5: Access the Service

Click into service b2i-war-java8. We can get the NodePort and Endpoints. Thereby we can access the Spring-MVC-Showcase service via Endpoints within cluster, or browse the web service externally using http://{$Node IP}:{$NodePort}/{$Binary-Package-Name}/.

Resource Info

For the example above, enter http://139.198.111.111:30182/b2i-war-java8/ to access Spring-MVC-Showcase. Make sure the traffic can pass through the NodePort.

Access the Service

Step 6: Verify Image in DockerHub

Sign in DockerHub with your account, you can find the image was successfully pushed to DockerHub with tag latest.

Image in DockerHub

Congratulation! Now you know how to use B2I to package your artifacts into Docker image, however, without learning Docker.