-
Notifications
You must be signed in to change notification settings - Fork 24
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
Implement files mounted to a workload #393
Comments
The config and binary files must be mounted as read only inside the container. When the binary file has executable permissions on the host system then it is also executable inside the container and can be mounted as read only as well. |
@krucod3: Like discussed the Ankaios agent shall create the files under |
@krucod3: After moving the control interface fifo files into the |
@inf17101, the solution makes sense. Only the Ankaios run folder ( |
Thinking about it further, starting an agent with same name twice one after the other under different users will also lead to problems and is probably the reason why the agent folder were also accessible by all. Even if we delete the folder when the agent stops, it could be that an unordered stop leaves the Ankaios run folder dirty. I see two options here how the agent can behave to avoid this:
I would go with the second approach as the use-case in more like a developer one. |
After I have expressed my concerns about using the std::fs (standard library filesystem blocking IO methods) to @krucod3 and @christoph-hamm, we analyzed together the need for using the async tokio implementation instead. We came to the conclusion to use the async implementation for writing a file, but keeping the standard library methods for creating the config files directories recursively on the host file system. This is because a filesystem might support async writes but for directory creation there is no performance impact to expect. |
I found out that handlebars-rs lib does escaping of special sequences like double quotes by default leading to problems when rendering YAML strings of config files including such sequences. There is an option I have found out in the utests of the handlebars-rs crate to disable this behavior. Now it works without escaping. |
@krucod3:
However, currently I have tried to template at least the content of the ConfigMap inside the |
Wouldn't the problem with the line breaks occur also for the file mounts if the content of the file is templated and is rendered from an Ankaios config? |
With a config file mount the whole field is replaced by the file content and the file is written to the host file system before it is mounted into the container. The problem is if the template is a sub string. Then indentation is lost when replacing the template with a string containing multiple newlines. A custom handlebars-rs helper function can be implemented allowing to specify the indentation level by the user when putting in the template string. |
@krucod3: I have tried out some possibilities to enable handlebars-rs to consider the indent level when replacing a template with a multi-line string. Example: For now we are not able to use the workloads:
kube_workload_with_mounted_text_file:
agent: agent_B
runtime: podman-kube
configs:
nginx_conf: file_data
runtimeConfig: |
manifest: |
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
{{nginx_conf.web_server_config}}
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
restartPolicy: Never
containers:
- name: nginx-container
image: ghcr.io/eclipse-ankaios/tests/nginx:alpine-slim
ports:
- containerPort: 80
hostPort: 8080
volumeMounts:
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
volumes:
- name: nginx-config-volume
configMap:
name: nginx-config
configs:
file_data:
web_server_config: |
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name custom_nginx;
location /custom {
default_type text/plain;
return 200 "The mounted custom nginx.conf is being used!\n";
}
}
} This would lead to a substitution in with wrong indentation: Partial view to the rendered output: manifest: |
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name custom_nginx;
location /custom {
default_type text/plain;
return 200 "The mounted custom nginx.conf is being used!\n";
}
}
}
---
apiVersion: v1
kind: Pod
... When trying out to resolve this with a custom helper in handlebars-rs, which is basically a method you register that can do custom rendering, then the problem is that you need to define a new helper but the indentation level must be specified by the user as argument which is ugly. It looks like the following in the runtimeConfig: I have found out another solution now which might be a little bit better. You can register a partial and pass in the content dynamically. ...
handlebars
.register_partial("indent", "{{content}}")
.unwrap();
... Partials keep indentation level but must be registered at compile time in handlebars-rs. The user input to keep indentation looks like level the following: ...
data:
nginx.conf: |
{{> indent content=nginx_conf.web_server_config}}
... Now, without any further code, the indentation is kept and the rendered output looks correct: apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name custom_nginx;
location /custom {
default_type text/plain;
return 200 "The mounted custom nginx.conf is being used!\n";
}
}
}
... Still the user has to use an extra "indent" call in the template, but now at least this workload I trying to deploy is running now and works. |
@inf17101, the second solution is definitely better then having to specify the exact number of white spaces, but it's still something the uses must enter. It would be great if we can somehow avoid this, as probably not everybody will read the complete documentation ... |
We agreed on the partial implementation solution. It is added within an extra PR as it has nothing to do with this issue directly. It was just detected within this issue: #445 |
For adapting the SDK, the issue eclipse-ankaios/ank-sdk-python#54 was created. |
Implement the objects in the interface (external + internal) to allow files mounted to a workload at a certain mount point. The file counted shall be taken from the
desiredState.configs
field were configs for workloads can be defined. Ankaios must render the files content.This is a sub task of #267, please have a look for the detailed prototype for configs and the current implementation.
To solve this issue the template rendering functionality of #267 must be already ready and working.
Example workload supporting files:
I have already introduced and experimented with my current configs implementation branch how to bring in this new layout of the
files
field in proto format. I achieved that CLI + Server accepts the new format. It's still in draft and contains only the necessary new objects and conversion functions, the rest is draft code. It is commit to separate branch: https://github.com/eclipse-ankaios/ankaios/tree/267_config_files_implTasks:
The text was updated successfully, but these errors were encountered: