1. Pre-instructions
The process of creating and deploying an application using Kubesphere is basically mastered in the previous steps.
PS: (an application with multiple components, such as FastAPI + Redis + PostresQL)
- 1: Prepare the docker image of the service component required by the application
- 2: Configure the environment variables required by some mirrors of the current service (configure the secret keys, etc.)
- 3: Configure the PVC data mount volume of the service (mainly storage of static data of the service)
- 4: Configure the extranet status based on the service status
- 5: Identify the components of related services
Fastapi-hello World service foundation preparation
Service source: github.com/asdkant/fas…
2.1 Service Code
First we define a simple Hello World service: the code is as follows:
import fastapi
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Copy the code
2.2 Creating a Service Image Dockerfile
FROM tiangolo/ uvicorn-gunicorn-fastAPI :python3.7 COPY main.py /app/main.pyCopy the code
2.2 Uploading an image to DockerHub
Ps: The author himself has uploaded! Specific address:
Registry.hub.docker.com/r/asdkant/f…
If deployed using Docker can be directly:
docker pull asdkant/fastapi-hello-world
3. Start manual deployment
In fact, the deployment here is as simple as wordpress already deployed, or even less than that, mainly because our example does not need to mount external data storage, database dependencies, etc., so fade-out is just a simple service.
3.1 Building a self-made application
- Log in to our Kubesphere using project-regular.
- Enter the demo-project project we created last time:
- Build your own app:
3.2 Setting Basic Application Information
Set the application name to fastapi-hello-world
3.3 Adding Service Components
Select the non-stateless service:
The service name is fastapi-hello-world
3.4 Adding a Mirror for a Service
Search for images: FastAPI
– Confirm port:
3.5 Ignore environment variables and mount storage
These are not needed when the mirror is started, so we can not configure!!
3.6 Advanced Settings – Enabling Internet access
3.7 Confirmation successful – No additional services need to be added!
3.8 Click To view application details and check the enabled port number
The port number is 30758
3.9 Access Verification
To access the address is: http://192.168.219.143:30758/
4. Dynamic operation service expansion
4.1 Entering the Corresponding Workload:
4.2 Select the service to view the workload and go to details
4.3 Adjustment of working copy
4.4 Configuring Elastic Service Scaling
Fill in the rules for elastic expansion:
5. View container logs
5.1 Select a Container in the Container Group:
5.2 Viewing Log Details:
At the end
END
Jane: www.jianshu.com/u/d6960089b…
The Denver nuggets: juejin. Cn/user / 296393…
Public account: wechat search [children to a pot of wolfberry wine tea]
Let students | article | QQ: welcome to learn communication 】 【 308711822
- 1: The description in this paper is mainly my cognition and opinion. If there is any improper place, I hope you can correct me.
- 2: About the content of the article, part of the content is arranged from the Internet, if there is a link will be declared annotation; If there is no timely annotation of the link, if there is infringement please contact, I will immediately delete processing yo.