Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(monitor): support to monitor vm and expose influxdb svc as nodeport type #2116

Merged
merged 7 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(monitor): support to visit influxdb with vip
  • Loading branch information
willzgli committed Nov 11, 2022
commit 8c2b6fdddc418643f2673ea9cb14ffb9e664c63e
21 changes: 16 additions & 5 deletions cmd/tke-installer/app/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ func (t *TKE) getTKEPlatformControllerOptions(ctx context.Context) map[string]in
if t.Para.Config.Monitor.InfluxDBMonitor != nil {
options["monitorStorageType"] = "influxdb"
if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil {
options["monitorStorageAddresses"] = "https://influxdb.tke.svc.cluster.local:8086"
options["monitorStorageAddresses"] = t.getLocalInfluxdbAddress()
} else if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor != nil {
address := t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.URL
if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username != "" {
Expand Down Expand Up @@ -1945,7 +1945,9 @@ func (t *TKE) getInfluxDBOptions(ctx context.Context) (map[string]interface{}, e
}
options["nodeName"] = node.Name
}

if t.Para.Config.HA != nil && len(t.Para.Config.HA.VIP()) > 0 {
options["HA"] = true //for HA mode, enable NodePort
}
return options, nil
}

Expand Down Expand Up @@ -2022,7 +2024,7 @@ func (t *TKE) installTKEMonitorAPI(ctx context.Context) error {
options["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password)
} else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil {
// todo
options["StorageAddress"] = "https://influxdb.tke.svc.cluster.local:8086"
options["StorageAddress"] = t.getLocalInfluxdbAddress()
}
} else if t.Para.Config.Monitor.ThanosMonitor != nil {
options["StorageType"] = "thanos"
Expand Down Expand Up @@ -2085,8 +2087,8 @@ func (t *TKE) installTKEMonitorController(ctx context.Context) error {
}
params["MonitorStorageAddresses"] = address
} else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil {
params["StorageAddress"] = "https://influxdb.tke.svc.cluster.local:8086"
params["MonitorStorageAddresses"] = "https://influxdb.tke.svc.cluster.local:8086"
params["StorageAddress"] = t.getLocalInfluxdbAddress()
params["MonitorStorageAddresses"] = t.getLocalInfluxdbAddress()
}
} else if t.Para.Config.Monitor.ThanosMonitor != nil {
params["StorageType"] = "thanos"
Expand Down Expand Up @@ -2873,3 +2875,12 @@ func (t *TKE) patchClusterInfo(ctx context.Context, patchData interface{}) error
_, err = t.globalClient.CoreV1().ConfigMaps("kube-public").Patch(ctx, "cluster-info", k8stypes.MergePatchType, patchByte, metav1.PatchOptions{})
return err
}

func (t *TKE) getLocalInfluxdbAddress() string {
var influxdbAddress string = "https://influxdb.tke.svc.cluster.local:8086"
if t.Para.Config.HA != nil && len(t.Para.Config.HA.VIP()) > 0 {
vip := t.Para.Config.HA.VIP()
influxdbAddress = fmt.Sprintf("https://%s:30086", vip) // influxdb svc must be set as NodePort type, and the nodePort is 30086
}
return influxdbAddress
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ spec:
{{- if .Values.baremetalStorage }}
nodeName: {{ .Values.nodeName }}
{{- end }}
hostNetwork: true
volumes:
- name: data
{{- if .Values.baremetalStorage }}
Expand Down Expand Up @@ -97,5 +96,9 @@ spec:
port: 8086
targetPort: 8086
protocol: TCP
{{- if .Values.HA }}
nodePort: 30086
type: NodePort
{{- end }}
selector:
app: influxdb
16 changes: 13 additions & 3 deletions cmd/tke-upgrade/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package options

import (
"encoding/json"
"fmt"
"io/ioutil"

platformv1 "tkestack.io/tke/api/platform/v1"
Expand Down Expand Up @@ -158,7 +159,7 @@ func (t *TKE) TKEPlatformController() (option Options) {
if t.Para.Config.Monitor.InfluxDBMonitor != nil {
option["MonitorStorageType"] = "influxdb"
if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil {
option["MonitorStorageAddresses"] = "https://influxdb.tke.svc.cluster.local:8086"
option["MonitorStorageAddresses"] = t.getLocalInfluxdbAddress()
} else if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor != nil {
address := t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.URL
if t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username != "" {
Expand Down Expand Up @@ -246,7 +247,7 @@ func (t *TKE) TKEMonitorAPI() (option Options) {
option["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password)
} else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil {
// todo
option["StorageAddress"] = "https://influxdb.tke.svc.cluster.local:8086"
option["StorageAddress"] = t.getLocalInfluxdbAddress()
}
}
}
Expand Down Expand Up @@ -274,7 +275,7 @@ func (t *TKE) TKEMonitorController() (option Options) {
option["StorageUsername"] = t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Username
option["StoragePassword"] = string(t.Para.Config.Monitor.InfluxDBMonitor.ExternalInfluxDBMonitor.Password)
} else if t.Para.Config.Monitor.InfluxDBMonitor.LocalInfluxDBMonitor != nil {
option["StorageAddress"] = "https://influxdb.tke.svc.cluster.local:8086"
option["StorageAddress"] = t.getLocalInfluxdbAddress()
}
}
}
Expand Down Expand Up @@ -320,3 +321,12 @@ func (t *TKE) TKERegistryAPI() (option Options) {
}
return
}

func (t *TKE) getLocalInfluxdbAddress() string {
var influxdbAddress string = "https://influxdb.tke.svc.cluster.local:8086"
if t.Para.Config.HA != nil && len(t.Para.Config.HA.VIP()) > 0 {
vip := t.Para.Config.HA.VIP()
influxdbAddress = fmt.Sprintf("https://%s:30086", vip) // influxdb svc must be set as NodePort type, and the nodePort is 30086
}
return influxdbAddress
}