v2.0
v1.0
  1. Release Notes
    1. Release Notes - 2.0.2Latest
    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. Intruction
      1. Intro
      2. Port Requirements
    1. Install on Linux
      1. All-in-One Installation
      2. Multi-Node Installation
      3. Installing HA Master and Etcd Cluster
      4. Storage Configuration Instruction
    1. Install on Kubernetes
      1. Prerequisites
      2. Online Installation
      3. Offline Installation
    1. Related Tools
      1. Integrating Harbor Registry
    1. Cluster Operation
      1. Adding New Nodes
      2. High Risk Operation
      3. Uninstalling KubeSphere
  1. Quick Start
    1. Getting Started with Multitenancy
    1. Exposing your APP using Ingress
    1. Deploying a MySQL Application
    1. Deploying a Wordpress Website
    1. Job to compute π to 2000 places
    1. Deploying Grafana using APP Template
    1. Creating Horizontal Pod Autoscaler
    1. S2i: Publish your app without Dockerfile
    1. Canary Release of Microservice APP
    1. CI/CD based on Spring Boot Project
    1. Building a Pipeline in a Graphical Panel
    1. CI/CD based on GitLab and Harbor
    1. Ingress-Nginx for Grayscale Release
  1. Cluster Admin Guide
    1. Multi-tenant Management
      1. Overview of Multi-tenant Management
      2. Overview of Role Management
    1. Platform Management
      1. Account Management
      2. Platform Roles Management
    1. Infrastructure
      1. Service Components
      2. Nodes
      3. Storage Classes
    1. Monitoring Center
      1. Physical Resources
      2. Application Resources
    1. Application Repository
    1. Jenkins System Settings
  1. User Guide
    1. Application Template
    1. Workloads
      1. Deployments
      2. StatefulSets
      3. DaemonSets
      4. Jobs
      5. CronJobs
    1. Storage
      1. Volumes
    1. Network & Services
      1. Services
      2. Routes
    1. Configuration Center
      1. Secret
      2. ConfigMap
      3. Image Registry
    1. Project Settings
      1. Basic Information
      2. Member Roles
      3. Project Members
      4. Internet Access
    1. DevOps Project
      1. DevOps Project Management
      2. DevOps Project Management
      3. DevOps Project Management
      4. DevOps Project Management
      5. DevOps Project Management
  1. Development Guide
    1. Preparing the Development Environment
    1. Development Workflow
  1. API Documentation
    1. API Guide
    1. How to invoke KubeSphere API
KubeSphere®️ 2020 All Rights Reserved.

Source to Image: Publish your app without Dockerfile

Source to Image (S2I) is a tool that allows a programmer to input source codes and transfer the codes into runnable program to Docker image. This tool enables programers to build images even when they don't know about Dockerfile. By inputing source codes into the source code compiler, Builder image, Source to Image can transfer the codes into Docker images.

Objective

The example below is an official Java demonstration for Hello World. It will show you how to use Source to Image on KubeSphere to build image, push the images to mirroring repositories and finally deploy them to clusters.

Prerequisites

Estimated Time

20-30 minutes (The time varies according to the Internet speed and other factors.)

Hands-on Lab

Create Secrets

Create the secrets for DockerHub repository and GitHub codes repository as dockerhub-id and github-id. Please refer to Creating Common Secrets

Fork Project

Login GitHub. Fork the GitHub repository devops-java-sample to your personal GitHUb.

Create a Deployment

Step 1: Fill in basic information

1.1 Click Deployment and enter.

1.2 Click Create.

  • Name: (Necessary) Name the deployment as s2i-test;
  • Nickname: It can be customized.
  • Description: Simply decirbe the deployment information. This is customizable.

Step 2: Container Group Template Settings

2.1. Click Next and then click Add Container.

2.2. Then choose Build a new container image from code.

2.3. Fork the Repository Sample to your personal GItHUb. Then copy your personal repository's git address.

2.4. Refer to the following information and fill in.

Note: KubeSphere has built in common s2i templates for Java, Node.js and Python. If you need to customize other languages or use the s2i template, please refer to Customized s2i template.

  • Code URL: Paste the git address fromt he last step (Git, HTTP and HTTPS are fine. You can also specify the related path in the source code terminal);
  • Secret: Inject the secret github-idinto the S2I Pod;
  • Mirroring Template: Choose kubespheredev/java-8-centos7 as the Builder image.
  • Code relative path: Use / by default.
  • Image Name: It can be customized. The user names here are dockerhub_username>/hello and dockerhub_username.
  • Tag: The mirroring tag can be latest by default.
  • Target image repository: Choose dockerhub-id created in the previous step.

2.4. Scroll down to Container Specification. It is suggested to set CPU and RAM's biggest storages as 500M and 1000Mi.

2.5. Scroll down to Service Settings. The port number is 8080:

2.6. Then click Save.

The duplicate number is 1. The click Next.

Step 3: Create s2i Deployment

No need to set storage volume. Click Next. Save the tag by default. Then choose Create. Complete the s2i deployment.

Complete the creation

The green check below indicates that the mirroring had been created by s2i.

Check the container group. Function well.

Verify The Operation Results

If the deployment was successful through s2i, you will see the setted image in Dockerhub. The name and tage have been setted in the Container Group Template Setting. If you want to check the deployment results, you can configerate as follows.

Step 1: Create a Service

Choose Network & Services → Services on the left menu, then click on the Create button.

Step 2: Fill in the basic information

This step is similar to deployment creation, e.g. Name : s2i-test-service. The rest are customized as below.

Step 3: Service Settings

3.1. Choose the first item Virtual IP: Access the service through the internal IP of the cluster.

3.2. Then click on the Specify Workload and choose springboot-s2i deployment as below.

3.3. Click save. Refer to the port information as follows.

  • Port name: s2i-port
  • TCP defaulted, Port Number: 8080 and the target port is 8080.
  • Finish the settings then click Next.

Step 5: Tag setting

Setting by default then click Next.

Step 6: Setting External Network Access

Select the access method as NodePort.

For now, the service check has been created. As below, the Virtual IP is 10.233.40.2, the service port is 8080 and the Nodeport is 30454.

Step 7: Verify Visits

If you visit the HelloWorld service from the internal network, you can login cluster nodes through SSH or use Cluster admin to login KubeSphere. Then putin the following command in web kubectl:

# curl {$Virtual IP}:{$Port} or curl {$Node IP}:{$NodePort}
$ curl 10.233.60.196:8080
Hello,World!

Tip: If you need to access to this service from external network, you may need to bind to the public network EIP and set port forwarding and firewall rules. Forward the Internal Network Port 30454 to the source port 30454 in the forwarding rule. Then open this port in the firewall to ensure the external network traffic can pass this port. For operations on the QingCloud platform, you can refer to Cloud Platform Setting Port Forward and Firewall.

Verify the Service and Image Push

Since we set the target mirroring repository as DockerHub, you can login your personal DockerHub to check the image pushed by Source to Image. If you find hello:latest, the image has been successfully pushed to DockerHub