mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
feat: Edit hostNetwork through the k8s property (#1772)
* feat:Specify the server of the rbd-node component on the edge * feat:Modify hostNetwork through k8s properties * fix:debug * fix:debug * fix:debug * fix:debug * fix:debug * fix:debug * fix:debug EventLogServer * feat:add flags * feat:add flags * feat:rbd-eventlog-edge * feat:rbd-eventlog-edge * feat:rbd-eventlog-edge * feat:rbd-eventlog-edge * feat:createHostNetwork * feat:createHostNetwork * fix:IsHostNetwork * fix:IsHostNetwork * fix:add NodeIP in K8sPodInfo struct * fix:add NodeIP in K8sPodInfo struct * fix:add NodeIP in K8sPodInfo struct * fix:debug * fix:createHostNetwork * fix:Update service.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update conf.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update conf.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update option.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update manager.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update streamlog.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update streamlog.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update streamlog.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update version.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update version.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update component.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update version.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> * Update manager.go Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> --------- Signed-off-by: banghao <46078945+zxwsclcmxbh@users.noreply.github.com> Co-authored-by: banghao-BYR <banghao@bupt.edu.cn>
This commit is contained in:
parent
bc37f891c4
commit
9294a17366
@ -133,6 +133,11 @@ type Conf struct {
|
||||
ImageRepositoryHost string
|
||||
GatewayVIP string
|
||||
HostsFile string
|
||||
|
||||
// The following variables are all the service name of
|
||||
// rbd-eventlog plus a different port.
|
||||
EventServer string
|
||||
LogAddress string
|
||||
}
|
||||
|
||||
//StatsdConfig StatsdConfig
|
||||
@ -159,7 +164,7 @@ func (a *Conf) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&a.HostID, "nodeid", "", "the unique ID for this node. Just specify, don't modify")
|
||||
fs.StringVar(&a.HostIP, "hostIP", "", "the host ip you can define. default get ip from eth0")
|
||||
fs.StringVar(&a.PodIP, "podIP", "", "The pod ip of node.")
|
||||
fs.StringSliceVar(&a.EventLogServer, "event-log-server", []string{"127.0.0.1:6366"}, "host:port slice of event log server")
|
||||
fs.StringSliceVar(&a.EventLogServer, "event-log-server", []string{"127.0.0.1:6366"}, "host:port slice of event log server.And if rbd-node is on an edge node, it must be configured.eg: rbd-eventlog-edge:6366.")
|
||||
fs.StringVar(&a.ConfigStoragePath, "config-path", "/rainbond/acp_configs", "the path of config to store(new)")
|
||||
fs.StringVar(&a.Service, "servicePath", "/traefik/backends", "the path of service info to store")
|
||||
fs.StringSliceVar(&a.EtcdEndpoints, "etcd", []string{"http://127.0.0.1:2379"}, "the path of node in etcd")
|
||||
@ -199,6 +204,9 @@ func (a *Conf) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&a.HostsFile, "hostsfile", "/newetc/hosts", "/etc/hosts mapped path in the container. eg. /etc/hosts:/tmp/hosts. Do not set hostsfile to /etc/hosts")
|
||||
fs.StringVar(&a.ContainerRuntime, "container-runtime", sources.ContainerRuntimeContainerd, "container runtime, support docker and containerd")
|
||||
fs.StringVar(&a.RuntimeEndpoint, "runtime-endpoint", sources.RuntimeEndpointContainerd, "container runtime endpoint")
|
||||
// rbd-eventlog service
|
||||
fs.StringVar(&a.EventServer, "event-server", "", "If rbd-node is on an edge node, it must be configured.eg: rbd-eventlog-edge:6363.")
|
||||
fs.StringVar(&a.LogAddress, "log-address", "", "If rbd-node is on an edge node, it must be configured.eg: rbd-eventlog-edge:6362.")
|
||||
}
|
||||
|
||||
//SetLog 设置log
|
||||
|
@ -49,6 +49,8 @@ const (
|
||||
K8sAttributeNameResources = "resources"
|
||||
//K8sAttributeNameHostIPC -
|
||||
K8sAttributeNameHostIPC = "hostIPC"
|
||||
// K8sAttributeNameHostHostNetwork -
|
||||
K8sAttributeNameHostHostNetwork = "hostNetwork"
|
||||
//K8sAttributeNameLifecycle -
|
||||
K8sAttributeNameLifecycle = "lifecycle"
|
||||
//K8sAttributeNameVolumeClaimTemplate -
|
||||
|
@ -156,6 +156,9 @@ func (m *manager) UpdateEndpoints(endpoints ...*config.Endpoint) {
|
||||
manager: m,
|
||||
ctx: m.ctx,
|
||||
}
|
||||
if len(m.config.EventLogServers) != 0 && m.config.EventLogServers[0] != "127.0.0.1:6366" {
|
||||
h.server = m.config.EventLogServers[0]
|
||||
}
|
||||
m.handles[end.URL] = h
|
||||
logrus.Infof("Add event server endpoint,%s", end.URL)
|
||||
go h.HandleLog()
|
||||
|
@ -17,10 +17,10 @@ import (
|
||||
|
||||
"strconv"
|
||||
|
||||
"sync"
|
||||
|
||||
"github.com/goodrain/rainbond/cmd/node/option"
|
||||
"github.com/goodrain/rainbond/node/nodem/logger"
|
||||
"github.com/sirupsen/logrus"
|
||||
"sync"
|
||||
)
|
||||
|
||||
//STREAMLOGNAME driver name
|
||||
@ -51,6 +51,10 @@ func (c *Dis) discoverEventServer() {
|
||||
var servers []string
|
||||
for _, en := range re.List {
|
||||
if en.URL != "" {
|
||||
// 如果配置了service参数,则不使用pod ip
|
||||
if option.Config.EventServer != "" {
|
||||
en.URL = option.Config.EventServer
|
||||
}
|
||||
if strings.HasPrefix(en.URL, "http") {
|
||||
servers = append(servers, en.URL+"/docker-instance")
|
||||
} else {
|
||||
@ -377,6 +381,10 @@ func GetLogAddress(serviceID string) string {
|
||||
cluster = append(cluster, a+"?service_id="+serviceID+"&mode=stream")
|
||||
}
|
||||
}
|
||||
// 如果配置了service参数,则不使用pod ip
|
||||
if option.Config.LogAddress != "" {
|
||||
return option.Config.LogAddress
|
||||
}
|
||||
return getLogAddress(cluster)
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/goodrain/rainbond/builder/sources"
|
||||
|
||||
"github.com/goodrain/rainbond/builder"
|
||||
"github.com/goodrain/rainbond/builder/sources"
|
||||
"github.com/goodrain/rainbond/db"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
dbmodel "github.com/goodrain/rainbond/db/model"
|
||||
@ -155,6 +154,11 @@ func TenantServiceVersion(as *v1.AppService, dbmanager db.Manager) error {
|
||||
HostIPC: createHostIPC(as, dbmanager),
|
||||
},
|
||||
}
|
||||
// 使用k8s属性去修改
|
||||
HostNetwork, _ := dbmanager.ComponentK8sAttributeDao().GetByComponentIDAndName(as.ServiceID, model.K8sAttributeNameHostHostNetwork)
|
||||
if HostNetwork != nil {
|
||||
podtmpSpec.Spec.HostNetwork = createHostNetwork(HostNetwork)
|
||||
}
|
||||
if dnsPolicy == "None" {
|
||||
dnsConfig, err := createDNSConfig(as, dbmanager)
|
||||
if err != nil {
|
||||
@ -1185,6 +1189,15 @@ func createHostIPC(as *v1.AppService, dbmanager db.Manager) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func createHostNetwork(HostNetwork *model.ComponentK8sAttributes) bool {
|
||||
value, err := strconv.ParseBool(HostNetwork.AttributeValue)
|
||||
if err != nil {
|
||||
logrus.Debug("HostNetwork ParseBool error", err)
|
||||
return false
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func createLifecycle(as *v1.AppService, dbmanager db.Manager) (*corev1.Lifecycle, error) {
|
||||
var lifecycle corev1.Lifecycle
|
||||
life, err := dbmanager.ComponentK8sAttributeDao().GetByComponentIDAndName(as.ServiceID, model.K8sAttributeNameLifecycle)
|
||||
|
Loading…
Reference in New Issue
Block a user