Switched to overlay network transport.
This commit is contained in:
@@ -57,7 +57,7 @@ func cleanup(w http.ResponseWriter, r *http.Request){
|
||||
if err != nil {
|
||||
panic("Failed to remove helper service."+ err.Error());
|
||||
}
|
||||
time.Sleep(15*time.Second);
|
||||
time.Sleep(7*time.Second);
|
||||
|
||||
fmt.Fprint(w, bodyDecoded.ServiceId);
|
||||
}
|
||||
|
||||
@@ -45,14 +45,16 @@ func prepare(w http.ResponseWriter, r *http.Request){
|
||||
|
||||
maxConcurrent := uint64(1);
|
||||
totalCompletions := uint64(1);
|
||||
stopGracePeriod := time.Second * 5;
|
||||
targetNode := labels["blazena.node"];
|
||||
helperCommand := `ssh-keygen -t ed25519 -f /host_key && \
|
||||
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIByYbl8vu946LPycSO5pBohq3vMvvl+wX7snu1Bqpd7p test" > /root/.ssh/authorized_keys && \
|
||||
/usr/sbin/sshd -h /host_key -p 22 -D`;
|
||||
/usr/sbin/sshd -h /host_key -p 2222 -D`;
|
||||
|
||||
|
||||
_, err = ApiClient.ServiceCreate(context.Background(), swarm.ServiceSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: "BlazenaHelper",
|
||||
Labels: map[string]string{"blazena.helper": "true"},
|
||||
},
|
||||
Mode: swarm.ServiceMode{
|
||||
@@ -72,20 +74,14 @@ func prepare(w http.ResponseWriter, r *http.Request){
|
||||
Type: "volume",
|
||||
},
|
||||
},
|
||||
StopGracePeriod: &stopGracePeriod,
|
||||
},
|
||||
Placement: &swarm.Placement{
|
||||
Constraints: []string{"node.hostname=="+targetNode},
|
||||
},
|
||||
},
|
||||
EndpointSpec: &swarm.EndpointSpec{
|
||||
Ports: []swarm.PortConfig{
|
||||
swarm.PortConfig{
|
||||
Protocol: swarm.PortConfigProtocolTCP,
|
||||
TargetPort: uint32(22),
|
||||
PublishedPort: uint32(2222),
|
||||
PublishMode: swarm.PortConfigPublishModeHost,
|
||||
},
|
||||
},
|
||||
Networks: []swarm.NetworkAttachmentConfig{swarm.NetworkAttachmentConfig{
|
||||
Target: "blazenaPohar",
|
||||
}},
|
||||
},
|
||||
}, swarm.ServiceCreateOptions{});
|
||||
|
||||
@@ -93,7 +89,7 @@ func prepare(w http.ResponseWriter, r *http.Request){
|
||||
panic("Failed to create helper service."+ err.Error());
|
||||
}
|
||||
|
||||
time.Sleep(15*time.Second);
|
||||
time.Sleep(7*time.Second);
|
||||
fmt.Fprint(w, bodyDecoded.ServiceId);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,11 @@ func Run(Config cfg.Config) {
|
||||
fmt.Println("Done!");
|
||||
|
||||
command := `apk add --no-cache rsync openssh-client && \
|
||||
echo "It Works Under Water!"`;
|
||||
ping -c 10 BlazenaHelper`;
|
||||
//rsync -avz --delete -e "ssh -i /ssh-key -p 2222 -o StrictHostKeyChecking=no" \
|
||||
//root@`+Config.Nodes[service.Node].Ip+`:/volume/ /tmp`
|
||||
|
||||
|
||||
time.Sleep(15*time.Second);
|
||||
exec, err := DockerClient.ContainerExecCreate(context.Background(), "BlazenaStorage", container.ExecOptions{
|
||||
Cmd: []string{"sh", "-c", command},
|
||||
AttachStdout: true,
|
||||
@@ -72,8 +71,9 @@ func Run(Config cfg.Config) {
|
||||
resp, err := DockerClient.ContainerExecAttach(context.Background(), exec.ID, container.ExecStartOptions{});
|
||||
defer resp.Close();
|
||||
|
||||
//io.Copy(os.Stdout, resp.Reader)
|
||||
io.Copy(os.Stdout, resp.Reader)
|
||||
|
||||
time.Sleep(30*time.Second);
|
||||
fmt.Println("Cleaning Up: " + service.ServiceId);
|
||||
cleanupService(Config, service);
|
||||
fmt.Println("Done!");
|
||||
@@ -83,7 +83,6 @@ func Run(Config cfg.Config) {
|
||||
fmt.Println("Done!");
|
||||
}
|
||||
|
||||
time.Sleep(15*time.Second);
|
||||
DockerClient.ContainerRemove(context.Background(), "BlazenaStorage", container.RemoveOptions{
|
||||
Force: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user