|
|
@ -24,6 +24,7 @@ package docker |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
docker "github.com/docker/docker/api/types/container" |
|
|
|
docker "github.com/docker/docker/api/types/container" |
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/network" |
|
|
|
"github.com/docker/go-connections/nat" |
|
|
|
"github.com/docker/go-connections/nat" |
|
|
|
k3d "github.com/rancher/k3d/pkg/types" |
|
|
|
k3d "github.com/rancher/k3d/pkg/types" |
|
|
|
) |
|
|
|
) |
|
|
@ -33,12 +34,42 @@ func TranslateNodeToContainer(node *k3d.Node) (docker.Config, error) { |
|
|
|
container := docker.Config{} |
|
|
|
container := docker.Config{} |
|
|
|
container.Hostname = node.Name |
|
|
|
container.Hostname = node.Name |
|
|
|
container.Image = node.Image |
|
|
|
container.Image = node.Image |
|
|
|
//container.Ports = // TODO: translate from what we have to []docker.Port
|
|
|
|
container.Labels = node.Labels // has to include the role
|
|
|
|
container.Labels = node.Labels |
|
|
|
container.Env = []string{} // TODO:
|
|
|
|
container.ExposedPorts = nat.PortSet{} // TODO:
|
|
|
|
container.Cmd = []string{} // TODO: dependent on role and extra args
|
|
|
|
container.Env = []string{} // TODO:
|
|
|
|
hostConfig := docker.HostConfig{} |
|
|
|
container.Cmd = []string{} // TODO: dependent on role and extra args
|
|
|
|
|
|
|
|
container.Volumes = map[string]struct{}{} // TODO:
|
|
|
|
/* Auto-Restart */ |
|
|
|
|
|
|
|
if node.Restart { |
|
|
|
|
|
|
|
hostConfig.RestartPolicy = docker.RestartPolicy{ |
|
|
|
|
|
|
|
Name: "unless-stopped", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: do we need this or can the default be a map with empty values already?
|
|
|
|
|
|
|
|
hostConfig.Tmpfs = make(map[string]string) |
|
|
|
|
|
|
|
for _, mnt := range k3d.DefaultTmpfsMounts { |
|
|
|
|
|
|
|
hostConfig.Tmpfs[mnt] = "" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hostConfig.Privileged = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Volumes */ |
|
|
|
|
|
|
|
// TODO: image volume
|
|
|
|
|
|
|
|
hostConfig.Binds = []string{} |
|
|
|
|
|
|
|
container.Volumes = map[string]struct{}{} // TODO: which one do we use?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Ports */ |
|
|
|
|
|
|
|
container.ExposedPorts = nat.PortSet{} // TODO:
|
|
|
|
|
|
|
|
hostConfig.PortBindings = nat.PortMap{} // TODO: this and exposedPorts required?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Network */ |
|
|
|
|
|
|
|
networkingConfig := &network.NetworkingConfig{} |
|
|
|
|
|
|
|
networkingConfig.EndpointsConfig = map[string]*network.EndpointSettings{ |
|
|
|
|
|
|
|
"<network-name>": { // TODO: fill
|
|
|
|
|
|
|
|
Aliases: []string{"<container-alias>"}, // TODO: fill
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return container, nil |
|
|
|
return container, nil |
|
|
|
} |
|
|
|
} |
|
|
|