revert static IP
parent
dd48dab036
commit
22b40e215a
|
@ -81,14 +81,6 @@ func (d *Driver) Create() error {
|
|||
APIServerPort: d.NodeConfig.APIServerPort,
|
||||
}
|
||||
|
||||
defaultNetwork := d.MachineName
|
||||
if err := oci.CreateNetwork(defaultNetwork, oci.DefaultIPRange, oci.DefaultGateway); err != nil {
|
||||
glog.Warningf("unable to create docker network; node ip may not be stable: %v", err)
|
||||
} else {
|
||||
params.Network = defaultNetwork
|
||||
params.IP = oci.DefaultIP
|
||||
}
|
||||
|
||||
// control plane specific options
|
||||
params.PortMappings = append(params.PortMappings, oci.PortMapping{
|
||||
ListenAddress: oci.DefaultBindIPV4,
|
||||
|
|
|
@ -72,11 +72,6 @@ func profileInContainers(profile string, containers []string) bool {
|
|||
// gets the ip from user's host docker
|
||||
func dockerGatewayIP(profile string) (net.IP, error) {
|
||||
var bridgeID string
|
||||
// check if using custom network first
|
||||
if networkExists(profile) {
|
||||
ip := net.ParseIP(DefaultGateway)
|
||||
return ip, nil
|
||||
}
|
||||
rr, err := runCmd(exec.Command(Docker, "network", "ls", "--filter", "name=bridge", "--format", "{{.ID}}"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "get network bridge")
|
||||
|
@ -195,43 +190,3 @@ func dockerContainerIP(name string) (string, string, error) {
|
|||
|
||||
return ips[0], ips[1], nil
|
||||
}
|
||||
|
||||
// CreateNetwork creates a network
|
||||
func CreateNetwork(name, ipRange, gateway string) error {
|
||||
// check if the network already exists
|
||||
if networkExists(name) {
|
||||
return nil
|
||||
}
|
||||
|
||||
subnet := fmt.Sprintf("--subnet=%s", ipRange)
|
||||
_, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", subnet, "--gateway", gateway, name))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error creating network")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// removeNetwork removes a network
|
||||
func removeNetwork(name string) error {
|
||||
if !networkExists(name) {
|
||||
return nil
|
||||
}
|
||||
_, err := runCmd(exec.Command(Docker, "network", "remove", name))
|
||||
return err
|
||||
}
|
||||
|
||||
func networkExists(name string) bool {
|
||||
rr, err := runCmd(exec.Command(Docker, "network", "ls", "--format", "{{.Name}}"))
|
||||
if err != nil {
|
||||
glog.Warningf("error listing networks: %v", err)
|
||||
return false
|
||||
}
|
||||
networks := strings.Split(rr.Output(), "\n")
|
||||
for _, n := range networks {
|
||||
if strings.Trim(n, "\n") == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -66,8 +66,9 @@ func DeleteContainersByLabel(ociBin string, label string) []error {
|
|||
}
|
||||
|
||||
if _, err := runCmd(exec.Command(ociBin, "rm", "-f", "-v", c)); err != nil {
|
||||
deleteErrs = append(deleteErrs, errors.Wrapf(err, "delete container %s", c))
|
||||
deleteErrs = append(deleteErrs, errors.Wrapf(err, "delete container %s: output %s", c, err))
|
||||
}
|
||||
|
||||
}
|
||||
return deleteErrs
|
||||
}
|
||||
|
@ -88,9 +89,6 @@ func DeleteContainer(ociBin string, name string) error {
|
|||
if _, err := runCmd(exec.Command(ociBin, "rm", "-f", "-v", name)); err != nil {
|
||||
return errors.Wrapf(err, "delete %s", name)
|
||||
}
|
||||
if err := removeNetwork(name); err != nil {
|
||||
return errors.Wrap(err, "removing network")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -153,12 +151,6 @@ func CreateContainerNode(p CreateParams) error {
|
|||
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var:exec", p.Name))
|
||||
}
|
||||
if p.OCIBinary == Docker {
|
||||
// on linux, we can provide a static IP for docker
|
||||
if runtime.GOOS == "linux" && p.Network != "" && p.IP != "" {
|
||||
runArgs = append(runArgs, "--network", p.Network)
|
||||
runArgs = append(runArgs, "--ip", p.IP)
|
||||
}
|
||||
|
||||
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var", p.Name))
|
||||
// ignore apparmore github actions docker: https://github.com/kubernetes/minikube/issues/7624
|
||||
runArgs = append(runArgs, "--security-opt", "apparmor=unconfined")
|
||||
|
|
|
@ -38,12 +38,6 @@ const (
|
|||
nodeRoleLabelKey = "role.minikube.sigs.k8s.io"
|
||||
// CreatedByLabelKey is applied to any container/volume that is created by minikube created_by.minikube.sigs.k8s.io=true
|
||||
CreatedByLabelKey = "created_by.minikube.sigs.k8s.io"
|
||||
// DefaultGateway is the default gateway for the docker network created by the kic driver on linux
|
||||
DefaultGateway = "192.168.39.1"
|
||||
// DefaultIPRange is the default IP range for the docker network created by the kic driver on linux
|
||||
DefaultIPRange = "192.168.39.0/24"
|
||||
// DefaultIP is the default IP for the docker network created by the kic driver on linux
|
||||
DefaultIP = "192.168.39.2"
|
||||
)
|
||||
|
||||
// CreateParams are parameters needed to create a container
|
||||
|
@ -61,8 +55,6 @@ type CreateParams struct {
|
|||
Envs map[string]string // environment variables to pass to the container
|
||||
ExtraArgs []string // a list of any extra option to pass to oci binary during creation time, for example --expose 8080...
|
||||
OCIBinary string // docker or podman
|
||||
Network string // network used by the container
|
||||
IP string // container ip address
|
||||
}
|
||||
|
||||
// createOpt is an option for Create
|
||||
|
|
Loading…
Reference in New Issue