mirror of
https://github.com/labring/sealos.git
synced 2026-08-29 01:39:49 +08:00
refactor(main): add qa for loggers (#3307)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
This commit is contained in:
@@ -107,6 +107,7 @@ func setRequireBuildahAnnotation(cmd *cobra.Command) {
|
||||
}
|
||||
|
||||
func onBootOnDie() {
|
||||
logger.CfgConsoleAndFileLogger(debug, constants.LogPath(), "sealos", false)
|
||||
val, err := system.Get(system.DataRootConfigKey)
|
||||
errExit(err)
|
||||
constants.DefaultClusterRootFsDir = val
|
||||
@@ -119,7 +120,6 @@ func onBootOnDie() {
|
||||
constants.Workdir(),
|
||||
}
|
||||
errExit(file.MkDirs(rootDirs...))
|
||||
logger.CfgConsoleAndFileLogger(debug, constants.LogPath(), "sealos", false)
|
||||
}
|
||||
|
||||
func errExit(err error) {
|
||||
|
||||
@@ -127,7 +127,32 @@ export SEALOS_DATA_ROOT=/data/sealos
|
||||
sealos run labring/kubernetes:v1.24.0
|
||||
```
|
||||
|
||||
### Q3:ssh传输文件时,如何禁止检查文件的md5?
|
||||
### Q3: 如何修改 Sealos 镜像数据和状态的存储路径?
|
||||
|
||||
> 在使用 Sealos 集群时,可能需要改变默认的镜像数据存储路径和状态数据的存储路径。默认情况下,这些数据被存储在 `/etc/containers/storage.conf` 文件定义的位置。
|
||||
|
||||
1. **查看当前存储配置**
|
||||
首先,我们可以使用下面的命令来查看当前的镜像存储配置:
|
||||
```
|
||||
sealos images --debug
|
||||
```
|
||||
这个命令会打印出包含当前存储配置的文件,例如:
|
||||
```
|
||||
2023-06-07T16:27:02 debug using file /etc/containers/storage.conf as container storage config
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```
|
||||
2. **修改镜像数据存储路径**
|
||||
如果你希望更改镜像数据的存储路径,你可以编辑 `/etc/containers/storage.conf` 文件。在这个文件中,找到并修改 `graphroot` 字段设置为新的路径。例如:
|
||||
```
|
||||
vim /etc/containers/storage.conf
|
||||
```
|
||||
在编辑器中,将 `graphroot` 字段的值修改为你希望的新路径。
|
||||
3. **修改状态数据存储路径**
|
||||
参考 Buildah 的设计,Sealos 同样提供了状态数据存储路径的设置。在同样的配置文件 `/etc/containers/storage.conf` 中,找到并修改 `runroot` 字段为新的路径。
|
||||
|
||||
通过以上步骤,你可以将 Sealos 集群的镜像数据和状态数据保存到新的地址。每次运行 Sealos 命令时,它都将使用你在 `graphroot` 和 `runroot` 中设置的新路径来分别存储镜像数据和状态数据。
|
||||
|
||||
### Q4:ssh传输文件时,如何禁止检查文件的md5?
|
||||
|
||||
在网络环境良好时,禁用md5检查可以极大提升传输速度。若不想在ssh传输文件时检查文件的md5,可将SEALOS_SCP_CHECKSUM环境变量设置为false以禁用此功能。建议将此环境变量设为全局,以便在多场景下使用。
|
||||
|
||||
|
||||
@@ -127,7 +127,32 @@ export SEALOS_DATA_ROOT=/data/sealos
|
||||
sealos run labring/kubernetes:v1.24.0
|
||||
```
|
||||
|
||||
### Q3:ssh传输文件时,如何禁止检查文件的md5?
|
||||
### Q3: 如何修改 Sealos 镜像数据和状态的存储路径?
|
||||
|
||||
> 在使用 Sealos 集群时,可能需要改变默认的镜像数据存储路径和状态数据的存储路径。默认情况下,这些数据被存储在 `/etc/containers/storage.conf` 文件定义的位置。
|
||||
|
||||
1. **查看当前存储配置**
|
||||
首先,我们可以使用下面的命令来查看当前的镜像存储配置:
|
||||
```
|
||||
sealos images --debug
|
||||
```
|
||||
这个命令会打印出包含当前存储配置的文件,例如:
|
||||
```
|
||||
2023-06-07T16:27:02 debug using file /etc/containers/storage.conf as container storage config
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```
|
||||
2. **修改镜像数据存储路径**
|
||||
如果你希望更改镜像数据的存储路径,你可以编辑 `/etc/containers/storage.conf` 文件。在这个文件中,找到并修改 `graphroot` 字段设置为新的路径。例如:
|
||||
```
|
||||
vim /etc/containers/storage.conf
|
||||
```
|
||||
在编辑器中,将 `graphroot` 字段的值修改为你希望的新路径。
|
||||
3. **修改状态数据存储路径**
|
||||
参考 Buildah 的设计,Sealos 同样提供了状态数据存储路径的设置。在同样的配置文件 `/etc/containers/storage.conf` 中,找到并修改 `runroot` 字段为新的路径。
|
||||
|
||||
通过以上步骤,你可以将 Sealos 集群的镜像数据和状态数据保存到新的地址。每次运行 Sealos 命令时,它都将使用你在 `graphroot` 和 `runroot` 中设置的新路径来分别存储镜像数据和状态数据。
|
||||
|
||||
### Q4:ssh传输文件时,如何禁止检查文件的md5?
|
||||
|
||||
在网络环境良好时,禁用md5检查可以极大提升传输速度。若不想在ssh传输文件时检查文件的md5,可将SEALOS_SCP_CHECKSUM环境变量设置为false以禁用此功能。建议将此环境变量设为全局,以便在多场景下使用。
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/labring/sealos/pkg/system"
|
||||
|
||||
"github.com/containers/buildah/pkg/parse"
|
||||
"github.com/containers/common/pkg/config"
|
||||
"github.com/containers/storage/pkg/homedir"
|
||||
@@ -33,7 +35,6 @@ import (
|
||||
|
||||
var (
|
||||
// use the defaultOverrideConfigFile var as default
|
||||
storageConfEnv = "CONTAINERS_STORAGE_CONF"
|
||||
defaultOverrideConfigFile = "/etc/containers/storage.conf"
|
||||
DefaultConfigFile string
|
||||
DefaultSignaturePolicyPath = config.DefaultSignaturePolicyPath
|
||||
@@ -47,7 +48,7 @@ func init() {
|
||||
_ = os.Setenv("TMPDIR", parse.GetTempDir())
|
||||
|
||||
// storage config path
|
||||
if path, ok := os.LookupEnv(storageConfEnv); ok {
|
||||
if path, ok := os.LookupEnv(system.ContainerStorageConfEnvKey); ok {
|
||||
DefaultConfigFile = path
|
||||
} else if !unshare.IsRootless() {
|
||||
DefaultConfigFile = defaultOverrideConfigFile
|
||||
@@ -56,8 +57,6 @@ func init() {
|
||||
DefaultConfigFile, err = types.DefaultConfigFile(true)
|
||||
bailOnError(err, "")
|
||||
}
|
||||
logger.Debug("using file %s as container storage config", DefaultConfigFile)
|
||||
|
||||
// config path
|
||||
if unshare.IsRootless() {
|
||||
configHome, err := homedir.GetConfigHome()
|
||||
@@ -137,6 +136,7 @@ func setupRegistriesFile() error {
|
||||
}
|
||||
|
||||
func setupStorageConfigFile() error {
|
||||
logger.Debug("using file %s as container storage config", DefaultConfigFile)
|
||||
var content string
|
||||
if unshare.IsRootless() {
|
||||
runRoot := fmt.Sprintf("/run/user/%d", unshare.GetRootlessUID())
|
||||
|
||||
Reference in New Issue
Block a user