1
0
mirror of https://github.com/rancher/rke.git synced 2025-05-11 09:55:38 +00:00

updates for prefix path

This commit is contained in:
Luther Monson 2020-08-05 15:39:25 -07:00
parent 7d6181a290
commit 23d2341172
5 changed files with 47 additions and 8 deletions

View File

@ -1186,5 +1186,6 @@ func (c *Cluster) getWindowsEnv(host *hosts.Host) []string {
fmt.Sprintf("%s=%s", NodeAddressEnv, host.Address),
fmt.Sprintf("%s=%s", NodeInternalAddressEnv, host.InternalAddress),
fmt.Sprintf("%s=%s", CloudProviderNameEnv, c.CloudProvider.Name),
fmt.Sprintf("%s=%s", NodePrefixPath, host.PrefixPath),
}
}

View File

@ -36,8 +36,20 @@ func (c *Cluster) DeployRestoreCerts(ctx context.Context, clusterCerts map[strin
errgrp.Go(func() error {
var errList []error
for host := range hostsQueue {
err := pki.DeployCertificatesOnPlaneHost(ctx, host.(*hosts.Host), c.RancherKubernetesEngineConfig, restoreCerts, c.SystemImages.CertDownloader, c.PrivateRegistriesMap, false)
if err != nil {
h := host.(*hosts.Host)
var env []string
if h.IsWindows() {
env = c.getWindowsEnv(h)
}
if err := pki.DeployCertificatesOnPlaneHost(
ctx,
h,
c.RancherKubernetesEngineConfig,
restoreCerts,
c.SystemImages.CertDownloader,
c.PrivateRegistriesMap,
false,
env); err != nil {
errList = append(errList, err)
}
}

View File

@ -219,8 +219,20 @@ func (c *Cluster) SetUpHosts(ctx context.Context, flags ExternalFlags) error {
errgrp.Go(func() error {
var errList []error
for host := range hostsQueue {
err := pki.DeployCertificatesOnPlaneHost(ctx, host.(*hosts.Host), c.RancherKubernetesEngineConfig, c.Certificates, c.SystemImages.CertDownloader, c.PrivateRegistriesMap, c.ForceDeployCerts)
if err != nil {
h := host.(*hosts.Host)
var env []string
if h.IsWindows() {
env = c.getWindowsEnv(h)
}
if err := pki.DeployCertificatesOnPlaneHost(
ctx,
h,
c.RancherKubernetesEngineConfig,
c.Certificates,
c.SystemImages.CertDownloader,
c.PrivateRegistriesMap,
c.ForceDeployCerts,
env); err != nil {
errList = append(errList, err)
}
}

View File

@ -32,6 +32,7 @@ const (
NodeAddressEnv = "RKE_NODE_ADDRESS"
NodeInternalAddressEnv = "RKE_NODE_INTERNAL_ADDRESS"
NodeNameOverrideEnv = "RKE_NODE_NAME_OVERRIDE"
NodePrefixPath = "RKE_NODE_PREFIX_PATH"
NetworkConfigurationEnv = "RKE_NETWORK_CONFIGURATION"
@ -652,6 +653,9 @@ func (c *Cluster) BuildProxyProcess(host *hosts.Host) v3.Process {
}
}
Env := []string{fmt.Sprintf("%s=%s", services.NginxProxyEnvName, nginxProxyEnv)}
if host.IsWindows() {
Env = append(Env, c.getWindowsEnv(host)...) // mostly need prefix path
}
VolumesFrom := []string{}
if host.IsWindows() { // compatible withe Windows
@ -772,6 +776,8 @@ func (c *Cluster) BuildSidecarProcess(host *hosts.Host) v3.Process {
Binds = []string{
// put the execution binaries and the cni binaries to the host
fmt.Sprintf("%s:c:/host/opt", path.Join(host.PrefixPath, "/opt")),
// access to the etc dir for k8s certs to make a copy for flannel
fmt.Sprintf("%s:c:/host/etc", path.Join(host.PrefixPath, "/etc")),
// put the cni configuration to the host
fmt.Sprintf("%s:c:/host/etc/cni/net.d", path.Join(host.PrefixPath, "/etc/cni/net.d")),
// put the cni network component configuration to the host

View File

@ -24,9 +24,16 @@ const (
StateDeployerContainerName = "cluster-state-deployer"
)
func DeployCertificatesOnPlaneHost(ctx context.Context, host *hosts.Host, rkeConfig v3.RancherKubernetesEngineConfig, crtMap map[string]CertificatePKI, certDownloaderImage string, prsMap map[string]v3.PrivateRegistry, forceDeploy bool) error {
func DeployCertificatesOnPlaneHost(
ctx context.Context,
host *hosts.Host,
rkeConfig v3.RancherKubernetesEngineConfig,
crtMap map[string]CertificatePKI,
certDownloaderImage string,
prsMap map[string]v3.PrivateRegistry,
forceDeploy bool,
env []string) error {
crtBundle := GenerateRKENodeCerts(ctx, rkeConfig, host.Address, crtMap)
env := []string{}
// Strip CA key as its sensitive and unneeded on nodes without controlplane role
if !host.IsControl {
@ -119,12 +126,13 @@ func doRunDeployer(ctx context.Context, host *hosts.Host, containerEnv []string,
if err := docker.UseLocalOrPull(ctx, host.DClient, host.Address, certDownloaderImage, CertificatesServiceName, prsMap); err != nil {
return err
}
imageCfg := &container.Config{
Image: certDownloaderImage,
Cmd: []string{"cert-deployer"},
Env: containerEnv,
}
if host.DockerInfo.OSType == "windows" { // compatible with Windows
if host.IsWindows() { // compatible with Windows
imageCfg = &container.Config{
Image: certDownloaderImage,
Cmd: []string{
@ -139,7 +147,7 @@ func doRunDeployer(ctx context.Context, host *hosts.Host, containerEnv []string,
},
Privileged: true,
}
if host.DockerInfo.OSType == "windows" { // compatible with Windows
if host.IsWindows() { // compatible with Windows
hostCfg = &container.HostConfig{
Binds: []string{
fmt.Sprintf("%s:c:/etc/kubernetes", path.Join(host.PrefixPath, "/etc/kubernetes")),