mirror of
https://github.com/rancher/rke.git
synced 2025-06-04 21:19:41 +00:00
Add auditlog checksum to trigger restart on update
This commit is contained in:
parent
5824366b06
commit
5e50b51b13
@ -21,6 +21,7 @@ import (
|
|||||||
v3 "github.com/rancher/rke/types"
|
v3 "github.com/rancher/rke/types"
|
||||||
"github.com/rancher/rke/util"
|
"github.com/rancher/rke/util"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -39,6 +40,7 @@ const (
|
|||||||
EtcdPathPrefix = "/registry"
|
EtcdPathPrefix = "/registry"
|
||||||
CloudConfigSumEnv = "RKE_CLOUD_CONFIG_CHECKSUM"
|
CloudConfigSumEnv = "RKE_CLOUD_CONFIG_CHECKSUM"
|
||||||
CloudProviderNameEnv = "RKE_CLOUD_PROVIDER_NAME"
|
CloudProviderNameEnv = "RKE_CLOUD_PROVIDER_NAME"
|
||||||
|
AuditLogConfigSumEnv = "RKE_AUDITLOG_CONFIG_CHECKSUM"
|
||||||
|
|
||||||
DefaultToolsEntrypoint = "/opt/rke-tools/entrypoint.sh"
|
DefaultToolsEntrypoint = "/opt/rke-tools/entrypoint.sh"
|
||||||
DefaultToolsEntrypointVersion = "0.1.13"
|
DefaultToolsEntrypointVersion = "0.1.13"
|
||||||
@ -191,7 +193,7 @@ func (c *Cluster) BuildKubeAPIProcess(host *hosts.Host, serviceOptions v3.Kubern
|
|||||||
if len(c.CloudProvider.Name) > 0 {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
c.Services.KubeAPI.ExtraEnv = append(
|
c.Services.KubeAPI.ExtraEnv = append(
|
||||||
c.Services.KubeAPI.ExtraEnv,
|
c.Services.KubeAPI.ExtraEnv,
|
||||||
fmt.Sprintf("%s=%s", CloudConfigSumEnv, getCloudConfigChecksum(c.CloudConfigFile)))
|
fmt.Sprintf("%s=%s", CloudConfigSumEnv, getStringChecksum(c.CloudConfigFile)))
|
||||||
}
|
}
|
||||||
if c.EncryptionConfig.EncryptionProviderFile != "" {
|
if c.EncryptionConfig.EncryptionProviderFile != "" {
|
||||||
CommandArgs[EncryptionProviderConfigArgument] = EncryptionProviderFilePath
|
CommandArgs[EncryptionProviderConfigArgument] = EncryptionProviderFilePath
|
||||||
@ -265,6 +267,14 @@ func (c *Cluster) BuildKubeAPIProcess(host *hosts.Host, serviceOptions v3.Kubern
|
|||||||
}
|
}
|
||||||
if c.Services.KubeAPI.AuditLog != nil && c.Services.KubeAPI.AuditLog.Enabled {
|
if c.Services.KubeAPI.AuditLog != nil && c.Services.KubeAPI.AuditLog.Enabled {
|
||||||
Binds = append(Binds, fmt.Sprintf("%s:/var/log/kube-audit:z", path.Join(host.PrefixPath, "/var/log/kube-audit")))
|
Binds = append(Binds, fmt.Sprintf("%s:/var/log/kube-audit:z", path.Join(host.PrefixPath, "/var/log/kube-audit")))
|
||||||
|
bytes, err := yaml.Marshal(c.Services.KubeAPI.AuditLog.Configuration.Policy)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Warnf("Error while marshalling auditlog policy: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Services.KubeAPI.ExtraEnv = append(
|
||||||
|
c.Services.KubeAPI.ExtraEnv,
|
||||||
|
fmt.Sprintf("%s=%s", AuditLogConfigSumEnv, getStringChecksum(string(bytes))))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override args if they exist, add additional args
|
// Override args if they exist, add additional args
|
||||||
@ -323,7 +333,7 @@ func (c *Cluster) BuildKubeControllerProcess(host *hosts.Host, serviceOptions v3
|
|||||||
if len(c.CloudProvider.Name) > 0 {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
c.Services.KubeController.ExtraEnv = append(
|
c.Services.KubeController.ExtraEnv = append(
|
||||||
c.Services.KubeController.ExtraEnv,
|
c.Services.KubeController.ExtraEnv,
|
||||||
fmt.Sprintf("%s=%s", CloudConfigSumEnv, getCloudConfigChecksum(c.CloudConfigFile)))
|
fmt.Sprintf("%s=%s", CloudConfigSumEnv, getStringChecksum(c.CloudConfigFile)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if serviceOptions.KubeController != nil {
|
if serviceOptions.KubeController != nil {
|
||||||
@ -499,7 +509,7 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, serviceOptions v3.Kubern
|
|||||||
|
|
||||||
if len(c.CloudProvider.Name) > 0 {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
Env = append(Env,
|
Env = append(Env,
|
||||||
fmt.Sprintf("%s=%s", CloudConfigSumEnv, getCloudConfigChecksum(c.CloudConfigFile)))
|
fmt.Sprintf("%s=%s", CloudConfigSumEnv, getStringChecksum(c.CloudConfigFile)))
|
||||||
}
|
}
|
||||||
if len(c.PrivateRegistriesMap) > 0 {
|
if len(c.PrivateRegistriesMap) > 0 {
|
||||||
kubeletDockerConfig, _ := docker.GetKubeletDockerConfig(c.PrivateRegistriesMap)
|
kubeletDockerConfig, _ := docker.GetKubeletDockerConfig(c.PrivateRegistriesMap)
|
||||||
@ -1046,7 +1056,7 @@ func (c *Cluster) getDefaultKubernetesServicesOptions(osType string) (v3.Kuberne
|
|||||||
return v3.KubernetesServicesOptions{}, fmt.Errorf("getDefaultKubernetesServicesOptions: No serviceOptions found for cluster version [%s] or cluster major version [%s]", c.Version, clusterMajorVersion)
|
return v3.KubernetesServicesOptions{}, fmt.Errorf("getDefaultKubernetesServicesOptions: No serviceOptions found for cluster version [%s] or cluster major version [%s]", c.Version, clusterMajorVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCloudConfigChecksum(config string) string {
|
func getStringChecksum(config string) string {
|
||||||
configByteSum := md5.Sum([]byte(config))
|
configByteSum := md5.Sum([]byte(config))
|
||||||
return fmt.Sprintf("%x", configByteSum)
|
return fmt.Sprintf("%x", configByteSum)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user