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

feat(storage): retain file permission and owner when adding via confi… #589

Merged
merged 10 commits into from
Dec 6, 2024
3 changes: 3 additions & 0 deletions pkg/instance/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (s *storage) AddFileBytes(bytes []byte, dest string, chown string) error {
if _, err := tmpfile.Write(bytes); err != nil {
return err
}
if err := tmpfile.Chmod(0644); err != nil {
smuu marked this conversation as resolved.
Show resolved Hide resolved
return err
}
if err := tmpfile.Close(); err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/k8s/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
podFilesConfigmapNameSuffix = "-config"

initContainerNameSuffix = "-init"
initContainerImage = "nicolaka/netshoot"
defaultContainerUser = 0
)

Expand Down Expand Up @@ -594,7 +595,7 @@ func (c *Client) prepareInitContainers(config ContainerConfig, init bool) []v1.C
return []v1.Container{
{
Name: config.Name + initContainerNameSuffix,
Image: config.Image,
Image: initContainerImage,
mojtaba-esk marked this conversation as resolved.
Show resolved Hide resolved
SecurityContext: &v1.SecurityContext{
RunAsUser: ptr.To[int64](defaultContainerUser),
},
Expand All @@ -619,9 +620,11 @@ func (c *Client) preparePodSpec(spec PodConfig, init bool) v1.PodSpec {

// Prepare sidecar containers and append to the pod spec
for _, sidecarConfig := range spec.SidecarConfigs {
sidecarInitContainer := c.prepareInitContainers(sidecarConfig, true)
mojtaba-esk marked this conversation as resolved.
Show resolved Hide resolved
sidecarContainer := prepareContainer(sidecarConfig)
sidecarVolumes := preparePodVolumes(sidecarConfig)

podSpec.InitContainers = append(podSpec.InitContainers, sidecarInitContainer...)
podSpec.Containers = append(podSpec.Containers, sidecarContainer)
podSpec.Volumes = append(podSpec.Volumes, sidecarVolumes...)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sidecars/observability/obsy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
otelAgentName = "otel-agent"
// %s will be replaced with the otelCollectorVersion
otelAgentConfigFile = "/etc/otel-agent.yaml"
otelAgentConfigFilePermissions = "0:0"
otelAgentConfigFilePermissions = "10001:10001"

otelCollectorCommand = "/otelcol-contrib"
otelCollectorConfigArg = "--config=/etc/otel-agent.yaml"
Expand Down
Loading