Skip to content

Commit

Permalink
Merge pull request #12 from knawd/microk8s
Browse files Browse the repository at this point in the history
Microk8s
  • Loading branch information
No9 authored Feb 18, 2023
2 parents 1a7ffb4 + d622d03 commit 67b2d7b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ The deployment is performed copying files to 3 locations on each node:

## Supported Versions

|Release|WASMEdge|WASMtime|node-wasm|crun|Ubuntu|OpenShift|
|---|---|---|---|---|---|---|
|v1.0.0|0.11.2|5.0.0|[experiment](https://github.com/mhdawson/crun/commit/23f346e3bc15ec7e6188b405df895aef5a5cbcdd)|[1.8](https://github.com/containers/crun/releases/tag/1.8)|18.04, 20.04|4.10, 4.11|
|Release|WASMEdge|WASMtime|node-wasm|crun|Ubuntu|OpenShift|microk8s|
|---|---|---|---|---|---|---|---|
|v1.0.0|0.11.2|5.0.0|[experiment](https://github.com/mhdawson/crun/commit/23f346e3bc15ec7e6188b405df895aef5a5cbcdd)|[1.8](https://github.com/containers/crun/releases/tag/1.8)|18.04, 20.04|4.10, 4.11|1.26.1|

N.B. Red Hat Core OS based instances have still to be tested and we expect some issues modifying the crio config and copying the WASM libs to the host.

Expand Down
12 changes: 6 additions & 6 deletions charts/knawd-deployer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ sources:

type: application

version: v1.0.0
version: v1.1.0

appVersion: "v1.0.0"
appVersion: "v1.1.0"

# icon: https://raw.githubusercontent.com/No9/core-dump-handler/master/assets/handle-with-care-svgrepo-com.svg
icon: https://raw.githubusercontent.com/knawd/documentation/main/icons/cookie-6116766.svg

maintainers:
- name: No9
Expand All @@ -25,13 +25,13 @@ maintainers:
annotations:
artifacthub.io/changes: |
- kind: added
description: Schema alignment
description: Support for microk8s
links:
- name: GitHub PR
url: https://github.com/knawd/deployer/pull/10
url: https://github.com/knawd/deployer/pull/12
artifacthub.io/images: |
- name: knawd-deployer
image: quay.io/knawd/deployer:v1.0.0
image: quay.io/knawd/deployer:v1.1.0
artifacthub.io/license: MIT
artifacthub.io/signKey: |
fingerprint: BED079E67FD431E45301B1C9949E671B46AC8A34
Expand Down
9 changes: 7 additions & 2 deletions charts/knawd-deployer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ Calculate the location to mount the host route in the container
Calculate the location for configuration
*/}}
{{- define "knawd-deployer.configLocation" -}}
{{- if eq .Values.target "rhel8" }}"/etc/crio"{{- else }}"/etc/containerd"{{- end}}
{{- if eq .Values.target "rhel8" }}"/etc/crio"{{- else }}{{- if eq .Values.target "microk8s" }}"/var/snap/microk8s/current/args"{{- else}}"/etc/containerd"{{- end}}{{- end}}
{{- end }}

{{- define "knawd-deployer.isMicroK8s" -}}
{{- if eq .Values.target "microk8s" }}"true"{{- else }}"false"{{- end}}
{{- end }}


{{/*
Calculate the vendor
*/}}
{{- define "knawd-deployer.calculated-vendor" -}}
{{- if eq .Values.target "microk8s" }}"ubuntu_20_04"{{- else }}{{.Values.target}}{{- end}}
{{- end }}
2 changes: 1 addition & 1 deletion charts/knawd-deployer/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
name: deploy
env:
- name: VENDOR
value: {{ .Values.target }}
value: {{ include "knawd-deployer.calculated-vendor" . }}
- name: LIB_LOCATION
value: {{ include "knawd-deployer.libLocation" . }}
- name: LOG_LEVEL
Expand Down
2 changes: 1 addition & 1 deletion charts/knawd-deployer/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"tag": {
"description": "The tag in the repository where the image is located used to specifiy a custom image.",
"type": "string",
"default": "v1.0.0"
"default": "v1.1.0"
},
"autoRestart": {
"description": "Flag for the deployer to automatically restart the CRI service. Required for the config to be applied",
Expand Down
2 changes: 1 addition & 1 deletion charts/knawd-deployer/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target: rhel8
tag: v1.0.0
tag: v1.1.0
autoRestart: true
logLevel: "info"
ociType: "crun-wasmedge"
Expand Down
24 changes: 21 additions & 3 deletions manager/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,21 @@ async fn main() -> Result<(), std::io::Error> {
let deployed_file = format!("{lib_location}/{file_name}");
manager::delete_file(&deployed_file)?;
}
let toml_file = format!("{config_location}/config.toml");
let toml_file = if is_micro_k8s {
format!("{config_location}/containerd-template.toml")
} else {
format!("{config_location}/config.toml")
};

manager::restore_containerd_config(toml_file.as_str())?;
let oci_file = format!("{oci_location}/crun");
manager::delete_file(&oci_file)?;
let oci_bak = format!("{config_location}/config.toml.bak");
let oci_bak = if is_micro_k8s {
format!("{config_location}/containerd-template.toml.bak")
} else {
format!("{config_location}/config.toml.bak")
};

manager::delete_file(&oci_bak)?;

if auto_restart {
Expand Down Expand Up @@ -143,7 +153,9 @@ async fn main() -> Result<(), std::io::Error> {
for file_name in &lib_files {
manager::copy_to(VENDOR_BASE, lib_location.as_str(), &vendor, file_name)?;
}

let crio_file = format!("{config_location}/crio.conf");
info!("Editing CRI config: {crio_file}");
manager::update_crio_config(crio_file.as_str(), host_oci_location.as_str())?;
if auto_restart {
manager::restart_oci_runtime(node_root, is_micro_k8s, "crio".to_string())?;
Expand All @@ -153,7 +165,13 @@ async fn main() -> Result<(), std::io::Error> {
for file_name in &lib_files {
manager::copy_to(VENDOR_BASE, lib_location.as_str(), &vendor, file_name)?
}
let toml_file = format!("{config_location}/config.toml");

let toml_file = if is_micro_k8s {
format!("{config_location}/containerd-template.toml")
} else {
format!("{config_location}/config.toml")
};
info!("Editing CRI config: {toml_file}");
manager::update_containerd_config(toml_file.as_str(), host_oci_location.as_str())?;
if auto_restart {
manager::restart_oci_runtime(node_root, is_micro_k8s, "containerd".to_string())?;
Expand Down
5 changes: 4 additions & 1 deletion manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn update_containerd_config(
full_oci_location: &str,
) -> Result<toml_edit::Document, std::io::Error> {
let conf = generate_containerd_config(path, full_oci_location)?;
info!("Successfully generated CRI config for containerd");
let value: toml_edit::easy::Value =
toml_edit::easy::from_str(conf.to_string().as_str()).unwrap();
let result = toml_edit::easy::to_string_pretty(&value).unwrap();
Expand All @@ -53,6 +54,7 @@ pub fn update_containerd_config(
.open(path)?;
f.write_all(result.as_bytes())?;
f.flush()?;
info!("Wrote CRI config for containerd");
Ok(conf)
}

Expand All @@ -62,7 +64,7 @@ pub fn update_crio_config(
) -> Result<toml_edit::Document, std::io::Error> {
info!("Generating crio config");
let conf = generate_crio_config(path, full_oci_location)?;

info!("Successfully generated CRI config for crio");
let value: toml_edit::easy::Value =
toml_edit::easy::from_str(conf.to_string().as_str()).unwrap();
let result = toml_edit::easy::to_string_pretty(&value).unwrap();
Expand All @@ -76,6 +78,7 @@ pub fn update_crio_config(
.open(path)?;
f.write_all(result.as_bytes())?;
f.flush()?;
info!("Wrote CRI config for crio");
Ok(conf)
}

Expand Down

0 comments on commit 67b2d7b

Please sign in to comment.