Merge pull request #8251 from baude/networkaliases

network aliases for container creation
This commit is contained in:
OpenShift Merge Robot
2020-11-10 19:10:59 +01:00
committed by GitHub
19 changed files with 255 additions and 66 deletions

View File

@ -131,8 +131,9 @@ func (f FirewallConfig) Bytes() ([]byte, error) {
// DNSNameConfig describes the dns container name resolution plugin config
type DNSNameConfig struct {
PluginType string `json:"type"`
DomainName string `json:"domainName"`
PluginType string `json:"type"`
DomainName string `json:"domainName"`
Capabilities map[string]bool `json:"capabilities"`
}
// Bytes outputs the configuration as []byte

View File

@ -122,9 +122,12 @@ func NewFirewallPlugin() FirewallConfig {
// NewDNSNamePlugin creates the dnsname config with a given
// domainname
func NewDNSNamePlugin(domainName string) DNSNameConfig {
caps := make(map[string]bool, 1)
caps["aliases"] = true
return DNSNameConfig{
PluginType: "dnsname",
DomainName: domainName,
PluginType: "dnsname",
DomainName: domainName,
Capabilities: caps,
}
}

View File

@ -105,6 +105,13 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) ([]*cnitypes.Re
podName := getCNIPodName(ctr)
podNetwork := r.getPodNetwork(ctr.ID(), podName, ctrNS.Path(), ctr.config.Networks, ctr.config.PortMappings, requestedIP, requestedMAC)
aliases, err := ctr.runtime.state.GetAllNetworkAliases(ctr)
if err != nil {
return nil, err
}
if len(aliases) > 0 {
podNetwork.Aliases = aliases
}
results, err := r.netPlugin.SetUpPod(podNetwork)
if err != nil {