update observability module
This commit is contained in:
@@ -15,9 +15,10 @@ type Host struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
WorkDir string
|
||||
Verbose bool
|
||||
Credentials struct {
|
||||
WorkDir string
|
||||
KubeconfigFile string `yaml:"kubeconfig_file" env-default:"k8s-admin.conf"`
|
||||
Verbose bool
|
||||
Credentials struct {
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
AskSudoPassword bool `yaml:"ask_sudo_password"`
|
||||
|
||||
48
internal/config/helm.go
Normal file
48
internal/config/helm.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
helm_client "github.com/mittwald/go-helm-client"
|
||||
)
|
||||
|
||||
var client *helm_client.Client
|
||||
|
||||
func CreateHelmClient() helm_client.Client {
|
||||
config := GetConfig()
|
||||
file, err := os.Open(filepath.Join(config.WorkDir, config.KubeconfigFile))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open file: %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
kubeconfig, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read file: %s", err)
|
||||
}
|
||||
opts := &helm_client.KubeConfClientOptions{
|
||||
Options: &helm_client.Options{
|
||||
Namespace: "default", // Change this to the namespace you wish to install the chart in.
|
||||
RepositoryCache: "/tmp/.helmcache",
|
||||
RepositoryConfig: "/tmp/.helmrepo",
|
||||
Debug: true,
|
||||
Linting: true, // Change this to false if you don't want linting.
|
||||
DebugLog: func(format string, v ...interface{}) {
|
||||
// Change this to your own logger. Default is 'log.Printf(format, v...)'.
|
||||
},
|
||||
},
|
||||
KubeContext: "",
|
||||
KubeConfig: kubeconfig,
|
||||
}
|
||||
client, err := helm_client.NewClientFromKubeConf(opts)
|
||||
if err != nil {
|
||||
log.Fatalf("error while creating helm client: %s", err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func GetHelmClient() *helm_client.Client {
|
||||
return client
|
||||
}
|
||||
@@ -11,7 +11,7 @@ var kubernetesConfig *rest.Config
|
||||
|
||||
func GetKubernetesConfig() *rest.Config {
|
||||
appConfig := GetConfig()
|
||||
kubeconfigPath := filepath.Join(appConfig.WorkDir, "k8s-admin.conf")
|
||||
kubeconfigPath := filepath.Join(appConfig.WorkDir, appConfig.KubeconfigFile)
|
||||
|
||||
kubernetesConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
|
||||
if err != nil {
|
||||
|
||||
@@ -7,10 +7,11 @@ import (
|
||||
)
|
||||
|
||||
func InstallCluster(tags string) {
|
||||
appConfig := config.GetConfig()
|
||||
runPlaybook("kubespray/project/cluster.yml", tags)
|
||||
CopyK8SAdminConfig("k8s-admin.conf")
|
||||
config := config.GetConfig()
|
||||
if config.Modules.SecretsStorage.Enabled {
|
||||
CopyK8SAdminConfig(appConfig.KubeconfigFile)
|
||||
config.CreateHelmClient()
|
||||
if appConfig.Modules.SecretsStorage.Enabled {
|
||||
fmt.Println("## Additional Vault Configuration")
|
||||
secrets_storage.InitVault()
|
||||
secrets_storage.UnsealVault()
|
||||
@@ -19,11 +20,13 @@ func InstallCluster(tags string) {
|
||||
}
|
||||
|
||||
func UpgradeCluster(tags string) {
|
||||
appConfig := config.GetConfig()
|
||||
runPlaybook("kubespray/project/upgrade_cluster.yml", tags)
|
||||
CopyK8SAdminConfig("k8s-admin.conf")
|
||||
CopyK8SAdminConfig(appConfig.KubeconfigFile)
|
||||
}
|
||||
|
||||
func ScaleCluster() {
|
||||
runPlaybook("kubespray/project/scale.yml", "")
|
||||
CopyK8SAdminConfig("k8s-admin.conf")
|
||||
appConfig := config.GetConfig()
|
||||
CopyK8SAdminConfig(appConfig.KubeconfigFile)
|
||||
}
|
||||
|
||||
5
internal/registry/charts.go
Normal file
5
internal/registry/charts.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package registry
|
||||
|
||||
func InstallRegistryCharts() {
|
||||
|
||||
}
|
||||
@@ -80,6 +80,7 @@
|
||||
action: keep
|
||||
regex: kube-system;.*dns.*;metrics
|
||||
|
||||
{{- if .Modules.Observability.Monitoring.Blackbox.Enabled }}
|
||||
- job_name: 'ingress-endpoints'
|
||||
metrics_path: /probe
|
||||
params:
|
||||
@@ -98,13 +99,14 @@
|
||||
__meta_kubernetes_ingress_path,
|
||||
]
|
||||
regex: (.+);(.+);(.+)
|
||||
replacement: https://${2}${3}
|
||||
replacement: https://${2}${3}/
|
||||
target_label: __param_target
|
||||
- target_label: __address__
|
||||
replacement: observability-blackbox-exporter:9115
|
||||
{{- end }}
|
||||
|
||||
alertManager:
|
||||
enabled: {{ .Modules.Observability.Monitoring.AlertManager.Enabled }}
|
||||
enabled: {{ and .Modules.Observability.Monitoring.Enabled .Modules.Observability.Monitoring.AlertManager.Enabled }}
|
||||
serviceMonitor: {{ .Modules.Observability.Monitoring.Enabled }}
|
||||
enableDefaultRules: true
|
||||
image:
|
||||
@@ -129,7 +131,7 @@
|
||||
{{- end }}
|
||||
|
||||
blackboxExporter:
|
||||
enabled: {{ .Modules.Observability.Monitoring.Blackbox.Enabled }}
|
||||
enabled: {{ and .Modules.Observability.Monitoring.Enabled .Modules.Observability.Monitoring.Blackbox.Enabled }}
|
||||
serviceMonitor: {{ .Modules.Observability.Monitoring.Enabled }}
|
||||
image:
|
||||
repository: {{ .Modules.Observability.Monitoring.Blackbox.Image }}
|
||||
@@ -143,7 +145,7 @@
|
||||
|
||||
|
||||
kubeStateMetrics:
|
||||
enabled: {{ .Modules.Observability.Monitoring.KubeState.Enabled }}
|
||||
enabled: {{ and .Modules.Observability.Monitoring.Enabled .Modules.Observability.Monitoring.KubeState.Enabled }}
|
||||
image:
|
||||
repository: {{ .Modules.Observability.Monitoring.KubeState.Image }}
|
||||
tag: "{{ .Modules.Observability.Monitoring.KubeState.Tag }}"
|
||||
@@ -176,7 +178,7 @@
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
nodeExporter:
|
||||
enabled: {{ .Modules.Observability.Monitoring.Node.Enabled }}
|
||||
enabled: {{ and .Modules.Observability.Monitoring.Enabled .Modules.Observability.Monitoring.Node.Enabled }}
|
||||
image:
|
||||
repository: {{ .Modules.Observability.Monitoring.Node.Image }}
|
||||
tag: {{ .Modules.Observability.Monitoring.Node.Tag }}
|
||||
|
||||
Reference in New Issue
Block a user