in internal/node/pods.go [61:87]
func getStaticPodsOnNode() ([]string, error) {
var staticPodNames []string
files, err := os.ReadDir(defaultStaticPodManifestPath)
if err != nil {
// If manifest directory doesn't exist, there are no static pods.
if errors.Is(err, fs.ErrNotExist) {
return []string{}, nil
}
return nil, errors.Wrap(err, "failed to read static manifest directory")
}
for _, file := range files {
extension := filepath.Ext(file.Name())
if extension == ".yaml" || extension == ".yml" {
fileData, err := os.ReadFile(filepath.Join(defaultStaticPodManifestPath, file.Name()))
if err != nil {
return nil, err
}
var obj metav1.ObjectMeta
if err := yaml.Unmarshal(fileData, &obj); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal static pod manifest file: %s", file.Name())
}
staticPodNames = append(staticPodNames, obj.Name)
}
}
return staticPodNames, nil
}