add auto init/unseal for vault

This commit is contained in:
2024-05-06 00:00:18 +03:00
parent 772b8ceb57
commit e6689a1dda
21 changed files with 779 additions and 114 deletions

View File

@@ -15,7 +15,7 @@ type Host struct {
}
type Config struct {
DataDir string
WorkDir string
Credentials struct {
User string `yaml:"user"`
Password string `yaml:"password"`
@@ -43,9 +43,9 @@ type Config struct {
var instance *Config
func CreateConfig(configPath string, dataDir string, password string) *Config {
func CreateConfig(configPath string, workDir string, password string) *Config {
instance = &Config{}
instance.DataDir = dataDir
instance.WorkDir = workDir
if err := cleanenv.ReadConfig(configPath, instance); err != nil {
helper, _ := cleanenv.GetDescription(instance, nil)

21
pkg/config/kubernetes.go Normal file
View File

@@ -0,0 +1,21 @@
package config
import (
"path/filepath"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
var kubernetesConfig *rest.Config
func GetKubernetesConfig() *rest.Config {
appConfig := GetConfig()
kubeconfigPath := filepath.Join(appConfig.WorkDir, "k8s-admin.conf")
kubernetesConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
if err != nil {
panic(err.Error())
}
return kubernetesConfig
}

View File

@@ -1,11 +1,13 @@
package config
type SecretsStorage struct {
ChartRef string `yaml:"chart_ref" env-default:"kube-forge/vault"`
ChartVersion string `yaml:"chart_version" env-default:"0.1.0"`
Enabled bool `yaml:"enabled"`
Image string `yaml:"image" env-default:"kubesphere/fluent-operator"`
Tag string `yaml:"tag" env-default:"v2.7.0"`
ChartRef string `yaml:"chart_ref" env-default:"kube-forge/vault"`
ChartVersion string `yaml:"chart_version" env-default:"0.1.0"`
Enabled bool `yaml:"enabled"`
KeyShares int `yaml:"key_shares" env-default:"5"`
KeyThreshold int `yaml:"key_threshold" env-default:"3"`
UnsealKeys []string `yaml:"unseal_keys" env-default:"[]"`
RootToken string
Expose struct {
Type string `yaml:"type"`
Domain string `yaml:"domain"`