mirror of
https://github.com/rancher/os.git
synced 2025-08-10 11:03:16 +00:00
Build docker-sys bridge via system-docker args and remove cni-glue
This commit is contained in:
parent
da8d5ed027
commit
ba388b6bc6
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bridge",
|
|
||||||
"type": "bridge",
|
|
||||||
"bridge": "docker-sys",
|
|
||||||
"isDefaultGateway": true,
|
|
||||||
"ipMasq": true,
|
|
||||||
"hairpinMode": true,
|
|
||||||
"ipam": {
|
|
||||||
"type": "host-local",
|
|
||||||
"subnet": "172.18.42.1/16"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
bridge.d/
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"path": "/usr/bin/ros",
|
|
||||||
"args": [
|
|
||||||
"cni-glue",
|
|
||||||
"poststop"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"path": "/usr/bin/ros",
|
|
||||||
"args": [
|
|
||||||
"cni-glue"
|
|
||||||
]
|
|
||||||
}
|
|
@ -25,7 +25,6 @@ import (
|
|||||||
"github.com/rancher/os/config/cloudinit/datasource/metadata"
|
"github.com/rancher/os/config/cloudinit/datasource/metadata"
|
||||||
"github.com/rancher/os/config/cloudinit/pkg"
|
"github.com/rancher/os/config/cloudinit/pkg"
|
||||||
"github.com/rancher/os/log"
|
"github.com/rancher/os/log"
|
||||||
"github.com/vishvananda/netlink"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -44,14 +43,10 @@ func NewDatasource(root string) []*MetadataService {
|
|||||||
roots := make([]string, 0, 5)
|
roots := make([]string, 0, 5)
|
||||||
|
|
||||||
if root == "" {
|
if root == "" {
|
||||||
if links, err := netlink.LinkList(); err == nil {
|
if links, err := netconf.GetValidLinkList(); err == nil {
|
||||||
log.Infof("Checking to see if a cloudstack server-identifier is available")
|
log.Infof("Checking to see if a cloudstack server-identifier is available")
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
linkName := link.Attrs().Name
|
linkName := link.Attrs().Name
|
||||||
if linkName == "lo" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("searching for cloudstack server %s on %s", serverIdentifier, linkName)
|
log.Infof("searching for cloudstack server %s on %s", serverIdentifier, linkName)
|
||||||
lease := netconf.GetDhcpLease(linkName)
|
lease := netconf.GetDhcpLease(linkName)
|
||||||
if server, ok := lease[serverIdentifier]; ok {
|
if server, ok := lease[serverIdentifier]; ok {
|
||||||
|
@ -122,6 +122,7 @@ var schema = `{
|
|||||||
"storage_context": {"type": "string"},
|
"storage_context": {"type": "string"},
|
||||||
"exec": {"type": ["boolean", "null"]},
|
"exec": {"type": ["boolean", "null"]},
|
||||||
"bridge": {"type": "string"},
|
"bridge": {"type": "string"},
|
||||||
|
"bip": {"type": "string"},
|
||||||
"config_file": {"type": "string"},
|
"config_file": {"type": "string"},
|
||||||
"containerd": {"type": "string"},
|
"containerd": {"type": "string"},
|
||||||
"debug": {"type": ["boolean", "null"]},
|
"debug": {"type": ["boolean", "null"]},
|
||||||
|
@ -148,6 +148,7 @@ type UpgradeConfig struct {
|
|||||||
|
|
||||||
type EngineOpts struct {
|
type EngineOpts struct {
|
||||||
Bridge string `yaml:"bridge,omitempty" opt:"bridge"`
|
Bridge string `yaml:"bridge,omitempty" opt:"bridge"`
|
||||||
|
BIP string `yaml:"bip,omitempty" opt:"bip"`
|
||||||
ConfigFile string `yaml:"config_file,omitempty" opt:"config-file"`
|
ConfigFile string `yaml:"config_file,omitempty" opt:"config-file"`
|
||||||
Containerd string `yaml:"containerd,omitempty" opt:"containerd"`
|
Containerd string `yaml:"containerd,omitempty" opt:"containerd"`
|
||||||
Debug *bool `yaml:"debug,omitempty" opt:"debug"`
|
Debug *bool `yaml:"debug,omitempty" opt:"debug"`
|
||||||
|
6
main.go
6
main.go
@ -4,11 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/containernetworking/cni/plugins/ipam/host-local"
|
|
||||||
"github.com/containernetworking/cni/plugins/main/bridge"
|
|
||||||
"github.com/docker/docker/docker"
|
"github.com/docker/docker/docker"
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/rancher/cniglue"
|
|
||||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||||
"github.com/rancher/os/cmd/cloudinitsave"
|
"github.com/rancher/os/cmd/cloudinitsave"
|
||||||
"github.com/rancher/os/cmd/control"
|
"github.com/rancher/os/cmd/control"
|
||||||
@ -35,9 +32,6 @@ var entrypoints = map[string]func(){
|
|||||||
"ros-bootstrap": control.BootstrapMain,
|
"ros-bootstrap": control.BootstrapMain,
|
||||||
"ros-sysinit": sysinit.Main,
|
"ros-sysinit": sysinit.Main,
|
||||||
"wait-for-docker": wait.Main,
|
"wait-for-docker": wait.Main,
|
||||||
"cni-glue": glue.Main,
|
|
||||||
"bridge": bridge.Main,
|
|
||||||
"host-local": hostlocal.Main,
|
|
||||||
"respawn": respawn.Main,
|
"respawn": respawn.Main,
|
||||||
|
|
||||||
// Power commands
|
// Power commands
|
||||||
|
@ -66,7 +66,7 @@ func createInterfaces(netCfg *NetworkConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createSlaveInterfaces(netCfg *NetworkConfig) {
|
func createSlaveInterfaces(netCfg *NetworkConfig) {
|
||||||
links, err := netlink.LinkList()
|
links, err := GetValidLinkList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to list links: %v", err)
|
log.Errorf("Failed to list links: %v", err)
|
||||||
return
|
return
|
||||||
@ -167,7 +167,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
|||||||
createInterfaces(netCfg)
|
createInterfaces(netCfg)
|
||||||
createSlaveInterfaces(netCfg)
|
createSlaveInterfaces(netCfg)
|
||||||
|
|
||||||
links, err := netlink.LinkList()
|
links, err := GetValidLinkList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("error getting LinkList: %s", err)
|
log.Errorf("error getting LinkList: %s", err)
|
||||||
return false, err
|
return false, err
|
||||||
@ -177,11 +177,8 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
|||||||
|
|
||||||
//apply network config
|
//apply network config
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
linkName := link.Attrs().Name
|
|
||||||
if linkName != "lo" {
|
|
||||||
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
|
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
// make sure there was a DHCP set dns - or tell ros to write 8.8.8.8,8.8.8.4
|
// make sure there was a DHCP set dns - or tell ros to write 8.8.8.8,8.8.8.4
|
||||||
@ -189,7 +186,6 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
|||||||
dnsSet := false
|
dnsSet := false
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
linkName := link.Attrs().Name
|
linkName := link.Attrs().Name
|
||||||
if linkName != "lo" {
|
|
||||||
log.Infof("dns testing %s", linkName)
|
log.Infof("dns testing %s", linkName)
|
||||||
lease := GetDhcpLease(linkName)
|
lease := GetDhcpLease(linkName)
|
||||||
if _, ok := lease["domain_name_servers"]; ok {
|
if _, ok := lease["domain_name_servers"]; ok {
|
||||||
@ -197,7 +193,6 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
|||||||
dnsSet = true
|
dnsSet = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return dnsSet, nil
|
return dnsSet, nil
|
||||||
}
|
}
|
||||||
@ -510,3 +505,22 @@ func runCmds(cmds []string, iface string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetValidLinkList() ([]netlink.Link, error) {
|
||||||
|
var validLinkList []netlink.Link
|
||||||
|
links, err := netlink.LinkList()
|
||||||
|
if err != nil {
|
||||||
|
return validLinkList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, l := range links {
|
||||||
|
linkName := l.Attrs().Name
|
||||||
|
if linkName == "lo" || linkName == "docker-sys" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
validLinkList = append(validLinkList, l)
|
||||||
|
}
|
||||||
|
|
||||||
|
return validLinkList, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -368,7 +368,7 @@ rancher:
|
|||||||
system_docker:
|
system_docker:
|
||||||
exec: true
|
exec: true
|
||||||
storage_driver: overlay2
|
storage_driver: overlay2
|
||||||
bridge: none
|
bip: 172.18.42.1/16
|
||||||
restart: false
|
restart: false
|
||||||
graph: /var/lib/system-docker
|
graph: /var/lib/system-docker
|
||||||
group: root
|
group: root
|
||||||
|
Loading…
Reference in New Issue
Block a user