Closed windsource closed 11 months ago
As agreed in the team, we need to check what parts of the pod specification we would like to support (and what is supported by Podman). We also need to check if we would like to also support deployments, configMaps and persistent volume claims.
Podman supports Kubernetes manifests via the podman play kube
command. Currently the following K8s resources are supported (according to the documentation liked above):
Although deployments do not bring a lot of benefit, we should support them to ease up the transition from K8s. Regarding multiple resources in a manifest, it makes sense to allow ConfigMaps, PVCs and Secrets to be added beside Pod and Deployment. Still there are a couple of questions here:
podman play kube
specific options?
We could have them in the runtime config, e.g.:
runtimeConfig: |
force-remove: true
userns: host
manifest: |
apiVersion: v1
kind: Secret
metadata:
name: foo
data:
foo: YmFy # base64 for bar
Besides workloads Ankaios knows also other resource types like configs and cronJobs which just have not been implemented yet. Maybe we could use another resource type besides workload if a PVC or a secret is created? But that would mean that existing YAML with several resources like pod, PVC and secret need to be split up when passing to Ankaios which is also not optimal.
Yes, splitting would not be optimal. Another issue I see is that configs should be runtime agnostic. If we start making runtime specific config items, the complexity will rise very quickly and adding new runtimes could get very hard.
As for cron jobs, they are currently though of as a reference to a workload with an interval specifying the execution frequency.
Podman's documentation does not specify that the delete method for play/kube accepts a yaml/json file that specifies the resources that shall be deleted (I'll create a ticket for that). Because of the issue in the podman documentation, the podman-api crate that we use does not accept arguments specifying the yaml file or the options when tearing down the kube manifest. I'll create a ticket for that too. In my opinion the method also has a misleading name as it also deals with other typed of K8s resources, e.g. Secrets. Maybe the play_kubernetes_yaml method can be used for both creation and deletion (--down) as in the CLI and the REST API, although I personally don't like that interface of the Podman CLI either. The other option would be a delete_kubernetes_yaml method.
As for our implementation, I would suggest to directly send http calls to the Podman socket. It is not high effort for play kube and we don't have to wait for the changes suggested above. We can also call the Podman CLI.
Podman issue: https://github.com/containers/podman/issues/19945 Podman-api issue: https://github.com/vv9k/podman-api-rs/issues/168
As the podman-api rust crate does not support what we need, we have to go for the REST API or the CLI of Podman. We had a short discussion with @windsource and came to the conclusion to go for the CLI. It seems like play kube is either ways not really trimmed for speed for now see https://github.com/containers/podman/issues/19716, so the latency of loading Podman in memory should not play a major role in this case.
If we are already switching to usage of the Podman CLI instead of the Rest API, we could think about changing the config for the Porman runtime to accept strings for create container
and start container
and pass them 1-to-1 to the Podman CLI. This way we support all features of Podman and don't need special documentation of our Podman runtime config.
Most of the changes for the structure needed to support your second runtime are now done. All functionality should already be there including creating the control interface for each workload and passing it to the runtimes. Continuing with the generic state checker.
We were discussing how to implement new version of the "podman runtime" (for the containers). We came to the question whether to use podman run
or the combination podman create
+ podman start
. If I compare podman create
and podman run
, I can see following differences in command options:
podman create
has additionally following arguments (comparing to the podman run
):
--init-ctr string Make this a pod init container.
podman run
has additionally following arguments (comparing to the podman create
):
-d, --detach Run container in background and print container ID
--detach-keys [a-Z] Override the key sequence for detaching a container. Format is a single character [a-Z] or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-cf`, `@`, `^`, `[`, `\`, `]`, `^` or `_` (default "ctrl-p,ctrl-q")
--passwd add entries to /etc/passwd and /etc/group (default true)
--preserve-fds uint Pass a number of additional file descriptors into the container
--rmi Remove container image unless used by other containers
--sig-proxy Proxy received signals to the process (default true)
Now the question is what we want to use in the podman_runtime.rs
.
NOTE: the new implementation is also qood chance to change/improve configuration in the startConfig.yaml. We have an idea to pass the podman runtime configuration transparently (as much as possible) to the podman. Current approach is not transparent at all. If we want Ankaios to support new podman runtime configuration item, we have to extend the Ankaios. If we make the runtime configuration transparent (from the Ankaios point of view), we will make the situation simpler and more flexible.
One more note: podman create
and podman run
have the logic to pull the image in case the image is not available. It means we can call podman create
or podman run
directly. We do not need to pull images manually.
The new structure is working fine, although there are some places that need polishing. The requirements tracing should also be almost fine now. What remains is to update the podman runtime requirements and to update the diagrams with the new structure and workflow.
I am nearly finished with the implementation of "create workload" in the podman_runtime.rs. It uses podman run
instead of podman create
+ podman start
. I have discussed it with @krucod3 and we do not see any necessity to call create + start. The latest commit ba9a33f2d21e7e1b97a5ae153bcf359b61cf49aa also contains new format of the PodmanRuntimeConfig
. We have reviewed it (quickly) and it seems to be okay. The new runtime config is called PodmanRuntimeConfigCli
. The old config remains as it is for now. We will remove the old config later on (as soon as we finish the implementation here).
I'm currently working on the unit tests for the RuntimeFacade, but have trouble using mackall. It seems we will need to write our own mock runtime in order to porerly unit test the Runtimefacade and the Workload object.
RuntimeFacade utests done, started with the workload object now.
Last task is completed.
Description
For the acceptance of Ankaios some compatibility to Kubernetes is important. For that reason the CLI shall be extended to also support (a subset of the) Kubernetes pod spec.
Goals
Final result
Summary
In the course of work we decided to not only change the CLI, but directly add a new runtime - "podman-kube". The new runtime will instrument Podman to handle K8s manifests via the
podman play kube
command.Special CLI commands will not be needed as a simple
ank run --runtime podman-kube --agent X --config <k8s manifest content>
can be used.Tasks
podman play kube
features (there are different options for the command; in case we don't support all, we need to specify which)