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. Logging
    1. Log Query
  1. Developer Guide
    1. Introduction to S2I
    1. Custom S2I Template
  1. API Documentation
    1. API Guide
    1. How to Access KubeSphere API
KubeSphere®️ 2020 All Rights Reserved.

Source to Image: Publish Your App without Dockerfile

What is Source to Image

As Features and Benefits elaborates, Source-to-Image (S2I) is a toolkit and workflow for building reproducible container images from source code. S2I produces ready-to-run images by injecting source code into a container image and letting the container prepare that source code for execution. KubeSphere integrates S2I to enable automatically building images and publishing to Kubernetes without writing Dockerfile.

Objective

This tutorial will use S2I to import source code of a Java sample project into KubeSphere, build a docker image and push to a target registry, finally publish to Kubernetes and expose the service to outside.

S2I Process

Prerequisites

Estimated Time

20-30 minutes

Hands-on Lab

Step 1: Create Secrets

Log in KubeSphere with the account project-regular. Go to your project and create the secrets for DockerHub and GitHub. Please reference Creating Common-used Secrets.

Note you may not need to create GitHub Secret if your forked project below is open to public.

Step 2: Fork Project

Log in GitHub and fork the GitHub repository devops-java-sample to your personal GitHub account.

Fork Project

Step 3: Create Service

Fill in Basic Information

3.1 Navigate to Application Workloads → Services, click Create Service.

Create Service

3.2 Choose Java under Build a new service from source code repository, then name it s2i-demo and click Next.

Build Settings

3.3. Now we need go to GitHub and copy the URL of the forked repository first.

GitHub

3.4. Paste the URL in Code URL, enter <dockerhub_username>/<image_name> into imageName, e.g. pengfeizhou/s2i-sample in this demo. As for secret and Target image repository, you need to choose the secrets created in step 1, let's say dockerhub-id and github-id respectively.

Note: KubeSphere has built in common S2I templates for Java, Node.js and Python. It allows you to customize S2I template for other languages.

Build Settings

3.5. Click Next to Container Setting tab. In the Service Settings part, name the service http-port for example. Container Port and Service Port are both 8080.

Container Settings

3.6. Scroll down to Health Checker, check it and click Add Container ready check, fill in the contents as follows:

  • Port: enter 8080; it maps to the service port that we need to check.
  • Initial Delay(s): 30; number of seconds after the container has started before liveness or readiness probes are initiated.
  • Timeout(s): 10; number of seconds after the probe times out. Default is 1 second.

Health Checker

Then click to save it when you are done, and click Next.

Create S2I Deployment

Click Next again to skip Mount Volumes. Check Internet Access, then choose NodePort to expose S2I service through <NodeIP>:<NodePort>. Now click Create to start the S2I process.

Internet Access

Step 4: Verify Build Progress

Choose Image Builder, drill into the new generated S2I build.

Build Progress

You will be able to inspect the logs by expanding Job Records. Normally you can see it outputs "Build completed successfully" in the end.

Build Logs

So far this S2I build has created corresponding Job, Deployment and Service accordingly, We can verify each resource object as follows.

Job

Job

Deployment

Deployment

Service

Service

Step 5: Access S2I Service

Go into S2I service detailed page, access this service through either Endpoints, or <ClusterIP>:<Service Port>, or <NodeIP>:<NodePort>.

Access Service

$ curl 10.233.90.126:8080
Really appreciate your star, that is the power of our life.

Tip: If you need to access to this service externally, make sure the traffic can pass through the NodePort. You may configure firewall and port forward according to your environment.

Step 6: Verify Image Registry

Since you set DockerHub as the target registry, you can log in to your personal DockerHub to check if the sample image has been pushed by the S2I job.

Image in DockerHub

Congratulation! You have been familiar with S2I tool.