1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-01 15:06:23 +00:00
Files
rke/services/kubeapi.go

50 lines
2.0 KiB
Go
Raw Normal View History

2017-10-29 11:45:21 +02:00
package services
import (
"context"
2017-11-14 20:11:21 +02:00
"github.com/rancher/rke/docker"
2017-10-29 11:45:21 +02:00
"github.com/rancher/rke/hosts"
2019-10-03 03:56:39 +02:00
"github.com/rancher/rke/log"
2018-05-01 02:25:52 +02:00
"github.com/rancher/rke/pki"
2020-07-11 09:24:19 -07:00
v3 "github.com/rancher/rke/types"
2019-10-03 03:56:39 +02:00
"github.com/sirupsen/logrus"
2017-10-29 11:45:21 +02:00
)
2018-05-01 02:25:52 +02:00
func runKubeAPI(ctx context.Context, host *hosts.Host, df hosts.DialerFactory, prsMap map[string]v3.PrivateRegistry, kubeAPIProcess v3.Process, alpineImage string, certMap map[string]pki.CertificatePKI) error {
imageCfg, hostCfg, healthCheckURL := GetProcessConfig(kubeAPIProcess, host)
if err := docker.DoRunContainer(ctx, host.DClient, imageCfg, hostCfg, KubeAPIContainerName, host.Address, ControlRole, prsMap); err != nil {
return err
}
2018-05-01 02:25:52 +02:00
if err := runHealthcheck(ctx, host, KubeAPIContainerName, df, healthCheckURL, certMap); err != nil {
return err
}
return createLogLink(ctx, host, KubeAPIContainerName, ControlRole, alpineImage, prsMap)
2017-10-29 11:45:21 +02:00
}
func removeKubeAPI(ctx context.Context, host *hosts.Host) error {
return docker.DoRemoveContainer(ctx, host.DClient, KubeAPIContainerName, host.Address)
}
2018-08-20 06:37:04 +02:00
2019-01-14 19:51:20 +02:00
func RestartKubeAPI(ctx context.Context, host *hosts.Host) error {
2018-08-20 06:37:04 +02:00
return docker.DoRestartContainer(ctx, host.DClient, KubeAPIContainerName, host.Address)
}
2019-10-03 03:56:39 +02:00
func RestartKubeAPIWithHealthcheck(ctx context.Context, hostList []*hosts.Host, df hosts.DialerFactory, certMap map[string]pki.CertificatePKI) error {
log.Infof(ctx, "[%s] Restarting %s on contorl plane nodes..", ControlRole, KubeAPIContainerName)
for _, runHost := range hostList {
logrus.Debugf("[%s] Restarting %s on node [%s]", ControlRole, KubeAPIContainerName, runHost.Address)
if err := RestartKubeAPI(ctx, runHost); err != nil {
return err
}
logrus.Debugf("[%s] Running healthcheck for %s on node [%s]", ControlRole, KubeAPIContainerName, runHost.Address)
if err := runHealthcheck(ctx, runHost, KubeAPIContainerName,
df, GetHealthCheckURL(true, KubeAPIPort),
certMap); err != nil {
return err
}
}
log.Infof(ctx, "[%s] Restarted %s on contorl plane nodes successfully", ControlRole, KubeAPIContainerName)
return nil
}