forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Object Storage guide docs (labring#4579)
* add object storage guide doc * fix java code format * add doc to 4.0/docs * fix java code format * add docs for object storage * fix * fix * Compress large picture * Compress large picture 2
- Loading branch information
Showing
28 changed files
with
351 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
--- | ||
sidebar_position: 0 | ||
--- | ||
|
||
# Object Storage | ||
|
||
**Object Storage** is Sealos' built-in object storage service, which is primarily used to store and manage unstructured | ||
data. | ||
|
||
Currently, **Object Storage** has the following features: | ||
|
||
- Upload files to bucket | ||
- Download files from bucket | ||
- Expose the access permission of the bucket | ||
- Use SDK to access bucket | ||
- Monitors bucket resource metrics | ||
|
||
## Quick start | ||
|
||
### Upload files to bucket | ||
|
||
Go to Object Storage | ||
![](./images/1.png) | ||
|
||
Create a bucket | ||
![](./images/2.png) | ||
|
||
Set bucket name to test and permission to private | ||
![](./images/3.png) | ||
|
||
Bucket is created successfully | ||
![](./images/4.png) | ||
|
||
Upload file | ||
![](./images/5.png) | ||
|
||
File uploaded successfully | ||
![](./images/6.png) | ||
|
||
### Expose the access permission of the bucket | ||
|
||
Click the Edit button | ||
![](./images/7.png) | ||
|
||
Set Bucket Permission to publicRead and click the Application button | ||
![](./images/8.png) | ||
|
||
Copy file link | ||
![](./images/9.png) | ||
|
||
Paste to browser address bar to access files | ||
![](./images/10.png) | ||
|
||
### View the access key configuration | ||
|
||
An Object Storage user consists of a unique access key (username) and corresponding secret key (password). Internal is | ||
the internal access address of Object Storage, and External is the external access address of Object Storage. | ||
![](./images/11.png) | ||
|
||
### Use SDK to access bucket | ||
|
||
The SDK requires three parameters to access bucket: AccessKey, SecretKey, and Endpoint (Internal or External). If the | ||
Region parameter is required, us-east-1 is used by default. | ||
|
||
#### Go Client SDK | ||
|
||
Detailed documentation reference: https://min.io/docs/minio/linux/developers/go/API.html | ||
|
||
Example: Use the Go Client SDK to upload the style.css file to the sv3dd7u4-test bucket, and set the endpoint to the | ||
external address. If the service is deployed in the K8s cluster, you can change the endpoint to the internal address. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
) | ||
import "github.com/minio/minio-go/v7" | ||
import "github.com/minio/minio-go/v7/pkg/credentials" | ||
|
||
func main() { | ||
endpoint := "objectstorageapi.xxx.xxx.xxx" | ||
accessKey := "xxxxxxxx" | ||
secretKey := "xxxxxxxxxxxxxxxx" | ||
// init minio client | ||
minioClient, err := minio.New(endpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(accessKey, secretKey, ""), | ||
}) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
// get local file | ||
file, err := os.Open("./style.css") | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
defer file.Close() | ||
|
||
fileStat, err := file.Stat() | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
// put object | ||
uploadInfo, err := minioClient.PutObject(context.Background(), "sv3dd7u4-test", "style.css", file, fileStat.Size(), minio.PutObjectOptions{ContentType: "text/css"}) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
fmt.Println("Successfully uploaded bytes: ", uploadInfo) | ||
} | ||
``` | ||
|
||
File uploaded successfully | ||
![](./images/12.png) | ||
|
||
#### Java Client SDK | ||
|
||
Detailed documentation reference: https://min.io/docs/minio/linux/developers/java/API.html | ||
|
||
Example: Use the Java Client SDK to upload the style1.css file to the sv3dd7u4-test bucket, and set the endpoint to the | ||
external address. If the service is deployed in the K8s cluster, you can change the endpoint to the internal address. | ||
|
||
```xml | ||
|
||
<dependency> | ||
<groupId>io.minio</groupId> | ||
<artifactId>minio</artifactId> | ||
<version>8.5.9</version> | ||
</dependency> | ||
``` | ||
|
||
```javascript | ||
package org.example; | ||
|
||
import io.minio.MinioClient; | ||
import io.minio.UploadObjectArgs; | ||
|
||
public class FileUploader { | ||
public static void main(String[] args) throws Exception { | ||
|
||
MinioClient minioClient = | ||
MinioClient.builder() | ||
.endpoint("https://objectstorageapi.xxx.xxx.xxx") | ||
.credentials("xxxxxxxx", "xxxxxxxxxxxxxxxx") | ||
.build(); | ||
|
||
|
||
minioClient.uploadObject( | ||
UploadObjectArgs.builder() | ||
.bucket("sv3dd7u4-test") | ||
.object("style1.css") | ||
.filename("src/main/java/org/example/style1.css") | ||
.build()); | ||
|
||
System.out.println("Successfully uploaded bytes."); | ||
} | ||
} | ||
``` | ||
|
||
File uploaded successfully | ||
![](./images/13.png) | ||
|
||
#### Omit other language SDK | ||
|
||
Detailed documentation reference: https://min.io/docs/minio/linux/developers/minio-drivers.html | ||
|
||
|
||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
175 changes: 175 additions & 0 deletions
175
docs/4.0/i18n/zh-Hans/guides/objectstorage/objectstorage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
--- | ||
sidebar_position: 0 | ||
--- | ||
|
||
# 对象存储 | ||
|
||
「对象存储」是 Sealos 内置的对象存储服务,主要用于存储和管理非结构化数据。 | ||
|
||
目前「对象存储」具备以下功能: | ||
|
||
- 上传文件到「存储桶」 | ||
- 从「存储桶」下载文件 | ||
- 公开「存储桶」的访问权限 | ||
- 使用 SDK 访问「存储桶」 | ||
- 监控「存储桶」资源指标 | ||
|
||
## 快速开始 | ||
|
||
### 上传文件 | ||
|
||
进入「对象存储」 | ||
![](./images/1.png) | ||
|
||
创建「存储桶」 | ||
![](./images/2.png) | ||
|
||
设置「存储桶」名字为 test,权限为 private | ||
![](./images/3.png) | ||
|
||
「存储桶」创建成功 | ||
![](./images/4.png) | ||
|
||
上传文件 | ||
![](./images/5.png) | ||
|
||
上传文件成功 | ||
![](./images/6.png) | ||
|
||
### 公开「存储桶」的访问权限 | ||
|
||
点击「编辑」 | ||
![](./images/7.png) | ||
|
||
设置「存储桶权限」为 publicRead,点击「应用」 | ||
![](./images/8.png) | ||
|
||
复制文件链接 | ||
![](./images/9.png) | ||
|
||
粘贴到浏览器地址栏访问文件 | ||
![](./images/10.png) | ||
|
||
### 查看访问密钥配置 | ||
|
||
对象存储用户由唯一的 Access Key(用户名)和对应的 Secret Key(密码)组成。Internal 为对象存储的内部访问地址,External | ||
为对象存储的外部访问地址。 | ||
![](./images/11.png) | ||
|
||
### 使用 SDK 访问「存储桶」 | ||
|
||
SDK 访问「存储桶」需要三个参数:AccessKey、SecretKey、Endpoint。参数都在访问密钥中,Internal 是内网地址 Endpoint,External 是外网地址 | ||
Endpoint。如果需要使用 Region 参数,默认使用 us-east-1。 | ||
|
||
#### Go Client SDK | ||
|
||
详细文档参考:https://min.io/docs/minio/linux/developers/go/API.html | ||
|
||
例子:使用 Go Client SDK 上传 style.css 文件到 sv3dd7u4-test 存储桶,将 Endpoint 设置为外网地址 External。如果服务部署在当前 | ||
K8s 集群内,可以将 Endpoint 改为内网地址 Internal。 | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
) | ||
import "github.com/minio/minio-go/v7" | ||
import "github.com/minio/minio-go/v7/pkg/credentials" | ||
|
||
func main() { | ||
endpoint := "objectstorageapi.xxx.xxx.xxx" | ||
accessKey := "xxxxxxxx" | ||
secretKey := "xxxxxxxxxxxxxxxx" | ||
// init minio client | ||
minioClient, err := minio.New(endpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(accessKey, secretKey, ""), | ||
}) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
// get local file | ||
file, err := os.Open("./style.css") | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
defer file.Close() | ||
|
||
fileStat, err := file.Stat() | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
// put object | ||
uploadInfo, err := minioClient.PutObject(context.Background(), "sv3dd7u4-test", "style.css", file, fileStat.Size(), minio.PutObjectOptions{ContentType: "text/css"}) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
fmt.Println("Successfully uploaded bytes: ", uploadInfo) | ||
} | ||
``` | ||
|
||
文件上传成功 | ||
![](./images/12.png) | ||
|
||
#### Java Client SDK | ||
|
||
详细文档参考:https://min.io/docs/minio/linux/developers/java/API.html | ||
|
||
例子:使用 Java Client SDK 上传 style1.css 文件到 sv3dd7u4-test 存储桶,将 Endpoint 设置为外网地址 External。如果服务部署在当前 | ||
K8s 集群内,可以将 Endpoint 改为内网地址 Internal。 | ||
|
||
```xml | ||
|
||
<dependency> | ||
<groupId>io.minio</groupId> | ||
<artifactId>minio</artifactId> | ||
<version>8.5.9</version> | ||
</dependency> | ||
``` | ||
|
||
```javascript | ||
package org.example; | ||
|
||
import io.minio.MinioClient; | ||
import io.minio.UploadObjectArgs; | ||
|
||
public class FileUploader { | ||
public static void main(String[] args) throws Exception { | ||
|
||
MinioClient minioClient = | ||
MinioClient.builder() | ||
.endpoint("https://objectstorageapi.xxx.xxx.xxx") | ||
.credentials("xxxxxxxx", "xxxxxxxxxxxxxxxx") | ||
.build(); | ||
|
||
|
||
minioClient.uploadObject( | ||
UploadObjectArgs.builder() | ||
.bucket("sv3dd7u4-test") | ||
.object("style1.css") | ||
.filename("src/main/java/org/example/style1.css") | ||
.build()); | ||
|
||
System.out.println("Successfully uploaded bytes."); | ||
} | ||
} | ||
``` | ||
|
||
文件上传成功 | ||
![](./images/13.png) | ||
|
||
#### 其他语言 SDK 略 | ||
|
||
详细文档参考:https://min.io/docs/minio/linux/developers/minio-drivers.html | ||
|
||
|
||
|
||
|
||
|
||
|