2017-11-15 03:12:33 +02:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
2018-01-09 15:10:56 -07:00
|
|
|
"context"
|
2017-11-15 03:12:33 +02:00
|
|
|
|
|
|
|
"github.com/rancher/rke/docker"
|
|
|
|
"github.com/rancher/rke/hosts"
|
2018-01-31 19:50:55 +02:00
|
|
|
"github.com/rancher/types/apis/management.cattle.io/v3"
|
2017-11-15 03:12:33 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2017-11-29 03:35:18 +02:00
|
|
|
NginxProxyImage = "rancher/rke-nginx-proxy:0.1.0"
|
2017-11-15 03:12:33 +02:00
|
|
|
NginxProxyEnvName = "CP_HOSTS"
|
|
|
|
)
|
|
|
|
|
2018-03-21 19:20:58 +02:00
|
|
|
func runNginxProxy(ctx context.Context, host *hosts.Host, prsMap map[string]v3.PrivateRegistry, proxyProcess v3.Process, alpineImage string) error {
|
2019-08-14 12:53:32 +02:00
|
|
|
imageCfg, hostCfg, _ := GetProcessConfig(proxyProcess, host)
|
2018-03-21 19:20:58 +02:00
|
|
|
if err := docker.DoRunContainer(ctx, host.DClient, imageCfg, hostCfg, NginxProxyContainerName, host.Address, WorkerRole, prsMap); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return createLogLink(ctx, host, NginxProxyContainerName, WorkerRole, alpineImage, prsMap)
|
2017-11-15 03:12:33 +02:00
|
|
|
}
|
|
|
|
|
2018-01-09 15:10:56 -07:00
|
|
|
func removeNginxProxy(ctx context.Context, host *hosts.Host) error {
|
|
|
|
return docker.DoRemoveContainer(ctx, host.DClient, NginxProxyContainerName, host.Address)
|
2017-11-20 20:08:50 +02:00
|
|
|
}
|
2018-08-20 06:37:04 +02:00
|
|
|
|
2019-01-14 19:51:20 +02:00
|
|
|
func RestartNginxProxy(ctx context.Context, host *hosts.Host) error {
|
2018-08-20 06:37:04 +02:00
|
|
|
return docker.DoRestartContainer(ctx, host.DClient, NginxProxyContainerName, host.Address)
|
|
|
|
}
|