mirror of
https://github.com/rancher/rke.git
synced 2025-08-17 22:37:01 +00:00
updates for prefix path
This commit is contained in:
parent
7d6181a290
commit
23d2341172
@ -1186,5 +1186,6 @@ func (c *Cluster) getWindowsEnv(host *hosts.Host) []string {
|
|||||||
fmt.Sprintf("%s=%s", NodeAddressEnv, host.Address),
|
fmt.Sprintf("%s=%s", NodeAddressEnv, host.Address),
|
||||||
fmt.Sprintf("%s=%s", NodeInternalAddressEnv, host.InternalAddress),
|
fmt.Sprintf("%s=%s", NodeInternalAddressEnv, host.InternalAddress),
|
||||||
fmt.Sprintf("%s=%s", CloudProviderNameEnv, c.CloudProvider.Name),
|
fmt.Sprintf("%s=%s", CloudProviderNameEnv, c.CloudProvider.Name),
|
||||||
|
fmt.Sprintf("%s=%s", NodePrefixPath, host.PrefixPath),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,20 @@ func (c *Cluster) DeployRestoreCerts(ctx context.Context, clusterCerts map[strin
|
|||||||
errgrp.Go(func() error {
|
errgrp.Go(func() error {
|
||||||
var errList []error
|
var errList []error
|
||||||
for host := range hostsQueue {
|
for host := range hostsQueue {
|
||||||
err := pki.DeployCertificatesOnPlaneHost(ctx, host.(*hosts.Host), c.RancherKubernetesEngineConfig, restoreCerts, c.SystemImages.CertDownloader, c.PrivateRegistriesMap, false)
|
h := host.(*hosts.Host)
|
||||||
if err != nil {
|
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)
|
errList = append(errList, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,8 +219,20 @@ func (c *Cluster) SetUpHosts(ctx context.Context, flags ExternalFlags) error {
|
|||||||
errgrp.Go(func() error {
|
errgrp.Go(func() error {
|
||||||
var errList []error
|
var errList []error
|
||||||
for host := range hostsQueue {
|
for host := range hostsQueue {
|
||||||
err := pki.DeployCertificatesOnPlaneHost(ctx, host.(*hosts.Host), c.RancherKubernetesEngineConfig, c.Certificates, c.SystemImages.CertDownloader, c.PrivateRegistriesMap, c.ForceDeployCerts)
|
h := host.(*hosts.Host)
|
||||||
if err != nil {
|
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)
|
errList = append(errList, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ const (
|
|||||||
NodeAddressEnv = "RKE_NODE_ADDRESS"
|
NodeAddressEnv = "RKE_NODE_ADDRESS"
|
||||||
NodeInternalAddressEnv = "RKE_NODE_INTERNAL_ADDRESS"
|
NodeInternalAddressEnv = "RKE_NODE_INTERNAL_ADDRESS"
|
||||||
NodeNameOverrideEnv = "RKE_NODE_NAME_OVERRIDE"
|
NodeNameOverrideEnv = "RKE_NODE_NAME_OVERRIDE"
|
||||||
|
NodePrefixPath = "RKE_NODE_PREFIX_PATH"
|
||||||
|
|
||||||
NetworkConfigurationEnv = "RKE_NETWORK_CONFIGURATION"
|
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)}
|
Env := []string{fmt.Sprintf("%s=%s", services.NginxProxyEnvName, nginxProxyEnv)}
|
||||||
|
if host.IsWindows() {
|
||||||
|
Env = append(Env, c.getWindowsEnv(host)...) // mostly need prefix path
|
||||||
|
}
|
||||||
|
|
||||||
VolumesFrom := []string{}
|
VolumesFrom := []string{}
|
||||||
if host.IsWindows() { // compatible withe Windows
|
if host.IsWindows() { // compatible withe Windows
|
||||||
@ -772,6 +776,8 @@ func (c *Cluster) BuildSidecarProcess(host *hosts.Host) v3.Process {
|
|||||||
Binds = []string{
|
Binds = []string{
|
||||||
// put the execution binaries and the cni binaries to the host
|
// put the execution binaries and the cni binaries to the host
|
||||||
fmt.Sprintf("%s:c:/host/opt", path.Join(host.PrefixPath, "/opt")),
|
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
|
// put the cni configuration to the host
|
||||||
fmt.Sprintf("%s:c:/host/etc/cni/net.d", path.Join(host.PrefixPath, "/etc/cni/net.d")),
|
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
|
// put the cni network component configuration to the host
|
||||||
|
@ -24,9 +24,16 @@ const (
|
|||||||
StateDeployerContainerName = "cluster-state-deployer"
|
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)
|
crtBundle := GenerateRKENodeCerts(ctx, rkeConfig, host.Address, crtMap)
|
||||||
env := []string{}
|
|
||||||
|
|
||||||
// Strip CA key as its sensitive and unneeded on nodes without controlplane role
|
// Strip CA key as its sensitive and unneeded on nodes without controlplane role
|
||||||
if !host.IsControl {
|
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 {
|
if err := docker.UseLocalOrPull(ctx, host.DClient, host.Address, certDownloaderImage, CertificatesServiceName, prsMap); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
imageCfg := &container.Config{
|
imageCfg := &container.Config{
|
||||||
Image: certDownloaderImage,
|
Image: certDownloaderImage,
|
||||||
Cmd: []string{"cert-deployer"},
|
Cmd: []string{"cert-deployer"},
|
||||||
Env: containerEnv,
|
Env: containerEnv,
|
||||||
}
|
}
|
||||||
if host.DockerInfo.OSType == "windows" { // compatible with Windows
|
if host.IsWindows() { // compatible with Windows
|
||||||
imageCfg = &container.Config{
|
imageCfg = &container.Config{
|
||||||
Image: certDownloaderImage,
|
Image: certDownloaderImage,
|
||||||
Cmd: []string{
|
Cmd: []string{
|
||||||
@ -139,7 +147,7 @@ func doRunDeployer(ctx context.Context, host *hosts.Host, containerEnv []string,
|
|||||||
},
|
},
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
}
|
}
|
||||||
if host.DockerInfo.OSType == "windows" { // compatible with Windows
|
if host.IsWindows() { // compatible with Windows
|
||||||
hostCfg = &container.HostConfig{
|
hostCfg = &container.HostConfig{
|
||||||
Binds: []string{
|
Binds: []string{
|
||||||
fmt.Sprintf("%s:c:/etc/kubernetes", path.Join(host.PrefixPath, "/etc/kubernetes")),
|
fmt.Sprintf("%s:c:/etc/kubernetes", path.Join(host.PrefixPath, "/etc/kubernetes")),
|
||||||
|
Loading…
Reference in New Issue
Block a user