Skip to content

control-service: Container read-only file system#1291

Merged
gabrielgeorgiev1 merged 40 commits intomainfrom
person/gageorgiev/ephemeral-storage
Nov 16, 2022
Merged

control-service: Container read-only file system#1291
gabrielgeorgiev1 merged 40 commits intomainfrom
person/gageorgiev/ephemeral-storage

Conversation

@gabrielgeorgiev1
Copy link
Copy Markdown
Contributor

@gabrielgeorgiev1 gabrielgeorgiev1 commented Nov 3, 2022

To reduce the attack surface of jobs containers, jobs
should run with the root file system set to read-only.
However, this means that job pods cannot write to the
file system, so we need to create an ephemeral file
system that jobs can use instead.

The test job contains one step with the following code:

import logging

import time

from vdk.api.job_input  import IJobInput

log = logging.getLogger(__name__)


def run(job_input: IJobInput):
    log.info("Testing we can still write to the ephemeral filesystem.")

    with open("test-file.txt", 'w') as f:
        f.write("Testing sentence.")

    with open("test-file.txt", 'r') as f:
        if str(f.read()) != 'Testing sentence.':
            raise Exception("File write was unsuccessful.")

    log.info("Testing we cannot write to the root filesystem.")

    try:
        with open("/test-file.txt", 'w') as f:
            f.write("Testing sentence.")
    except OSError:
        log.info("Root filesystem is read-only, as it should.")
    else:
        raise Exception("Root filesystem is not read-only")

Testing done: integration test

Signed-off-by: Gabriel Georgiev gageorgiev@vmware.com

To reduce the attack surface of jobs containers, jobs
should run with the root file system set to read-only.
However, this means that job pods cannot write to the
file system, so we need to create an ephemeral file
system that jobs can use instead.

Testing done: TBD

Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
gabrielgeorgiev1 and others added 6 commits November 10, 2022 15:47
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage

Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
@antoniivanov
Copy link
Copy Markdown
Contributor

This is setting root file system for the builder jobs. And it looks ok.

What happens for the data jobs themselves ? Are you planning to do it? It make sense to me to be a separate PR but I just wondered because initially it seems we are changing the data job .
You need to fix the title if this PR is to be for builder jobs

@mivanov1988 mivanov1988 self-requested a review November 11, 2022 10:18
gabrielgeorgiev1 and others added 7 commits November 14, 2022 11:21
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage
@mivanov1988 mivanov1988 marked this pull request as ready for review November 14, 2022 15:30
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
gabrielgeorgiev1 and others added 3 commits November 15, 2022 10:26
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage
github-actions and others added 7 commits November 15, 2022 09:47
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage

Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage
@mivanov1988
Copy link
Copy Markdown
Contributor

Probably you are going to expose this option through the Helm chart in a separate PR, right?

Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
@gabrielgeorgiev1
Copy link
Copy Markdown
Contributor Author

Probably you are going to expose this option through the Helm chart in a separate PR, right?

I don't follow. My understanding was that this will be configured through values.yml.

Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
@mivanov1988
Copy link
Copy Markdown
Contributor

Probably you are going to expose this option through the Helm chart in a separate PR, right?

I don't follow. My understanding was that this will be configured through values.yml.

Yes, but now it is not possible, since this property is not exposed yet, right?

gabrielgeorgiev1 and others added 4 commits November 15, 2022 19:06
Signed-off-by: Gabriel Georgiev <gageorgiev@vmware.com>
…re/versatile-data-kit into person/gageorgiev/ephemeral-storage
@gabrielgeorgiev1 gabrielgeorgiev1 merged commit fbc9b02 into main Nov 16, 2022
@gabrielgeorgiev1 gabrielgeorgiev1 deleted the person/gageorgiev/ephemeral-storage branch November 16, 2022 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants