In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
I believe many inexperienced people don't know what to do about how to use the new Binary-to-Image function of KubeSphere Container platform 2.1.Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
What is Binary-to-image?
Binary-to-image (B2I) is a new feature of KubeSphere container platform in version 2.1.0. It is designed to help developers and OPS quickly package products or binary Package into Docker images and publish them to image repositories such as DockerHub or Harbor after the project is packaged into products such as WAR, JAR, Binary, etc. And support to create a service, push the product generation image to the repository with one click, and create its deployment (Deployment) and service (Service) and finally automatically publish it to the Kubernetes.
Binary-to-image characteristics
Binary-to-image (B2I) can greatly empower developers and operation and maintenance users in the process of rapid deployment and micro-service transformation of actual projects. B2I does not need to write a line of Dockerfile to reduce learning costs while improving publishing efficiency, so that users can better focus on the business itself.
The following figure outlines the business implementation process of B2I, which has instrumented and flowed the following steps, so it only needs to be done in a single form.
① creates B2I-type services in KubeSphere, uploading artifacts or binary packages
② B2I will create K8s Job, Deployment and Service in the background
③ automatically packages the product into a Docker image
④ push image to DockerHub or harbor
⑤ B2I Job will use the images in the repository in the Deloyment created in step 2
⑥ automatically publishes to Kubernetes
Description: in the above process, B2I Job will also perform the function of status reporting in the background
Next, two examples are used to introduce the two ways of using B2I. This paper provides sample products WAR, JAR and Binary to facilitate practical operation.
The following five product packages are provided for testing, or you can submit individual packaged test projects to the KubeSphere community.
Sample package sample project (code repository) b2i-war-java8.warSpring-MVC-Showcaseb2i-war-java11.warSpringMVC5b2i-binaryDevOps-go-sampleb2i-jar-java11.jarjava-maven-exampleb2i-jar-java8.jardevops-java-sample creation service uses B2I
The first example will implement B2I by creating a service, implementing the six steps in the figure above. In version 2.1.0, the way to create services and user experience has become more convenient and efficient than in version 2.0.x.
prerequisite
B2I belongs to the DevOps functional component, so it is necessary to open and install the DevOps component before use.
Create key
Since the packaged Docker image needs to be pushed to the image repository in the automatic construction process of B2I, you need to create an image repository key (Secret) first. Create a DockerHub key below. For more information, please see several commonly used keys.
Create a service
Click create Service under Application load → Service.
Drop down to build a new service through artifacts, select WAR, here only take a Spring-MVC-Showcase project repository as an example, and upload its WAR package (b2i-war-java8) b2i-war-java8.war to KubeSphere.
Custom name, such as b2i-war-java8. In the next build settings, default stateless service. Click to upload the local artifact b2i-war-java8.war, and select tomcat85-java8-centos7:latest in the construction environment.
The image name is /, tag defaults to latest, and the target image repository selects the created dockerhub-secret.
The next step is to set the container. The image name and port name can be customized. Enter the default 8080 of tomcat for container port and service port.
Because it is a stateless service, mount storage is skipped.
Check the public network access in the advanced settings, set it to NodePort, and click create.
Verification statu
After B2I is created, check the build status of B2I under the build image, including execution records (dynamic logs), resource status, mirror artifacts, environment variables, and Events.
View the build image
View Servic
View deployment status
View task execution status
If you are accustomed to using the kubectl command line, you can also see which resources B2i has created through the kubectl get all-n PRJECT_NAME through the toolkit → Web Kubectl.
Web kubectl View Resources
Access servic
From the list of services, you can see that the NodePort is 30571, so the Spring-MVC-Showcase service is accessed in the browser through: / spring-mvc-showcase/ (the default access path is the tomcat service).
View image push
Log in to the DockerHub account to view the Docker images automatically pushed by B2I.
Build an image using B2I
The first example is that B2I is completed by creating a service, and finally the WAR packet of Spring-MVC-Showcase is mirrored and deployed to Kubernetes. Using B2I in the way of building images is more like a quick tool for automatically generating images based on artifacts, and will not be automatically released to Kubernetes in the end.
The following will use a sample project based on the Go language to package the Binary artifact-b2i-binary (click to download) to demonstrate the second use of B2I-build images using B2I.
Upload product package
1. Click create build Image under build Image, and then select binary.
2. Next, upload the downloaded b2i-binary to KubeSphere. The image name can be customized /. Select the created dockerhub-secret in the target image repository, and click create.
Verify B2I status
View Task
Verify image push
Log in to the DockerHub account to view the Docker images automatically pushed by B2I.
Summary
You can use the above two different ways to complete the automatic mirror construction of B2I according to your needs. Generally speaking, projects like the Java language can be packaged into JAR/WAR packages through mvn package commands, while languages like C, C++ and Go that do not need to run time can be packaged into binary format artifacts using their own build commands, and finally the artifacts can be quickly packaged into an Docker image through KubeSphere B2I and published to the image repository and Kubernetes. Projects in scripted languages such as Python, Nodejs and PHP can be built and released automatically like B2I through KubeSphere Source-to-Image (S2I).
KubeSphere (https://github.com/kubesphere/kubesphere) is an open source application-centric container management platform that supports deployment on any infrastructure and provides easy-to-use UI, which greatly reduces the complexity of daily development, testing, operation and maintenance, and aims to solve the storage, network, security and ease of use of Kubernetes itself. Help enterprises easily cope with business scenarios such as agile development and automatic monitoring and maintenance, end-to-end application delivery, micro-service governance, multi-tenant management, multi-cluster management, service and network management, image warehouse, AI platform, edge computing and so on.
After reading the above, have you mastered how to use the new Binary-to-Image feature of KubeSphere Container platform 2.1? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.