2017-11-15 01:12:33 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
2018-01-09 22:10:56 +00:00
|
|
|
"context"
|
2017-11-15 01:12:33 +00:00
|
|
|
|
|
|
|
"github.com/rancher/rke/docker"
|
|
|
|
"github.com/rancher/rke/hosts"
|
2020-07-11 16:24:19 +00:00
|
|
|
v3 "github.com/rancher/rke/types"
|
2017-11-15 01:12:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2017-11-29 01:35:18 +00:00
|
|
|
NginxProxyImage = "rancher/rke-nginx-proxy:0.1.0"
|
2017-11-15 01:12:33 +00:00
|
|
|
NginxProxyEnvName = "CP_HOSTS"
|
|
|
|
)
|
|
|
|
|
2018-03-21 17:20:58 +00:00
|
|
|
func runNginxProxy(ctx context.Context, host *hosts.Host, prsMap map[string]v3.PrivateRegistry, proxyProcess v3.Process, alpineImage string) error {
|
2019-08-14 10:53:32 +00:00
|
|
|
imageCfg, hostCfg, _ := GetProcessConfig(proxyProcess, host)
|
2018-03-21 17:20:58 +00: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 01:12:33 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 22:10:56 +00:00
|
|
|
func removeNginxProxy(ctx context.Context, host *hosts.Host) error {
|
|
|
|
return docker.DoRemoveContainer(ctx, host.DClient, NginxProxyContainerName, host.Address)
|
2017-11-20 18:08:50 +00:00
|
|
|
}
|
2018-08-20 04:37:04 +00:00
|
|
|
|
2019-01-14 17:51:20 +00:00
|
|
|
func RestartNginxProxy(ctx context.Context, host *hosts.Host) error {
|
2018-08-20 04:37:04 +00:00
|
|
|
return docker.DoRestartContainer(ctx, host.DClient, NginxProxyContainerName, host.Address)
|
|
|
|
}
|