Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable apiserver to access updated encryption-config.json #5604

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/podexecutor/staticpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ func (s *StaticPodConfig) APIServer(_ context.Context, etcdReady <-chan struct{}
dirs = append(dirs, filepath.Dir(auditLogFile))
excludeFiles = append(excludeFiles, auditLogFile)
}
// encryption config is refreshed by the secrets-encryption controller
// so we mount the directory to allow the pod to see the updates
dirs = append(dirs, filepath.Join(s.DataDir, "server/cred"))
excludeFiles = append(excludeFiles, filepath.Join(s.DataDir, "server/cred/encryption-config.json"))

return after(etcdReady, func() error {
return staticpod.Run(s.ManifestsDir, staticpod.Args{
Expand Down
12 changes: 12 additions & 0 deletions pkg/staticpod/staticpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ func Run(dir string, args Args) error {
return err
}

// Check to make sure we aren't double mounting directories and the files in those directories
for _, dir := range args.Dirs {
for _, file := range files {
if strings.HasPrefix(file, dir) {
logrus.Warnf("file %s is being double mounted with directory %s", file, dir)
dereknola marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

args.Files = append(args.Files, files...)
pod, err := pod(args)
if err != nil {
Expand Down Expand Up @@ -375,6 +384,9 @@ func addExtraEnv(p *v1.Pod, extraEnv []string) {
}
}

// readFiles takes in the arguments passed to the static pod and returns a list of all files
// embedded in those arguments to be included in the pod manifest as volumes.
// excludeFiles are not included in the returned list.
func readFiles(args, excludeFiles []string) ([]string, error) {
files := map[string]bool{}
excludes := map[string]bool{}
Expand Down
Loading