diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3657fd4afd..f4358ed6eed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,9 @@ jobs: - variant: aws-dev arch: x86_64 supported: false + - variant: vmware-dev + arch: x86_64 + supported: false fail-fast: false steps: - uses: actions/checkout@v2 diff --git a/packages/containerd/containerd-config-toml_vmware-dev b/packages/containerd/containerd-config-toml_vmware-dev new file mode 100644 index 00000000000..dbd68745aed --- /dev/null +++ b/packages/containerd/containerd-config-toml_vmware-dev @@ -0,0 +1,14 @@ +version = 2 +root = "/var/lib/containerd" +state = "/run/containerd" +disabled_plugins = [ + "io.containerd.internal.v1.opt", + "io.containerd.snapshotter.v1.aufs", + "io.containerd.snapshotter.v1.devmapper", + "io.containerd.snapshotter.v1.native", + "io.containerd.snapshotter.v1.zfs", + "io.containerd.grpc.v1.cri", +] + +[grpc] +address = "/run/containerd/containerd.sock" diff --git a/packages/containerd/containerd.spec b/packages/containerd/containerd.spec index 1a6caf08e70..9accdbdac60 100644 --- a/packages/containerd/containerd.spec +++ b/packages/containerd/containerd.spec @@ -20,6 +20,7 @@ Source2: containerd-config-toml_aws-k8s Source3: containerd-config-toml_aws-dev Source4: containerd-config-toml_aws-ecs-1 Source5: containerd-tmpfiles.conf +Source6: containerd-config-toml_vmware-dev Source1000: clarify.toml # Upstream patch; can drop when we move to v1.4.0. @@ -100,7 +101,7 @@ install -p -m 0644 %{S:1} %{buildroot}%{_cross_unitdir}/containerd.service install -d %{buildroot}%{_cross_templatedir} install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/containerd -install -p -m 0644 %{S:2} %{S:3} %{S:4} %{buildroot}%{_cross_templatedir} +install -p -m 0644 %{S:2} %{S:3} %{S:4} %{S:6} %{buildroot}%{_cross_templatedir} install -d %{buildroot}%{_cross_tmpfilesdir} install -p -m 0644 %{S:5} %{buildroot}%{_cross_tmpfilesdir}/containerd.conf diff --git a/sources/api/host-containers/src/main.rs b/sources/api/host-containers/src/main.rs index c054ff6d573..22cd7b0a945 100644 --- a/sources/api/host-containers/src/main.rs +++ b/sources/api/host-containers/src/main.rs @@ -76,9 +76,6 @@ mod error { source: serde_json::Error, }, - #[snafu(display("settings.host_containers missing in API response"))] - MissingSettings {}, - #[snafu(display("Host containers '{}' missing field '{}'", name, field))] MissingField { name: String, field: String }, @@ -157,7 +154,8 @@ where let settings: model::Settings = serde_json::from_str(&response_body).context(error::ResponseJson { method, uri })?; - settings.host_containers.context(error::MissingSettings) + // If host containers aren't defined, return an empty map + Ok(settings.host_containers.unwrap_or_default()) } /// SystemdUnit stores the systemd unit being manipulated diff --git a/sources/logdog/conf/logdog.vmware-dev.conf b/sources/logdog/conf/logdog.vmware-dev.conf new file mode 120000 index 00000000000..e7157eae1ea --- /dev/null +++ b/sources/logdog/conf/logdog.vmware-dev.conf @@ -0,0 +1 @@ +logdog.aws-dev.conf \ No newline at end of file diff --git a/sources/models/README.md b/sources/models/README.md index e4849e72125..6a0b29e134c 100644 --- a/sources/models/README.md +++ b/sources/models/README.md @@ -52,11 +52,16 @@ The `#[model]` attribute on Settings and its sub-structs reduces duplication and * [Model](src/aws-ecs-1/mod.rs) * [Default settings](src/aws-ecs-1/defaults.d/) -### aws-dev: Development build +### aws-dev: AWS development build * [Model](src/aws-dev/mod.rs) * [Default settings](src/aws-dev/defaults.d/) +### vmware-dev: VMWare development build + +* [Model](src/vmware-dev/mod.rs) +* [Default settings](src/vmware-dev/defaults.d/) + ## This directory We use `build.rs` to symlink the proper API model source code for Cargo to build. diff --git a/sources/models/src/lib.rs b/sources/models/src/lib.rs index d30b45f2a4b..84bdcda8f4c 100644 --- a/sources/models/src/lib.rs +++ b/sources/models/src/lib.rs @@ -49,11 +49,16 @@ The `#[model]` attribute on Settings and its sub-structs reduces duplication and * [Model](src/aws-ecs-1/mod.rs) * [Default settings](src/aws-ecs-1/defaults.d/) -## aws-dev: Development build +## aws-dev: AWS development build * [Model](src/aws-dev/mod.rs) * [Default settings](src/aws-dev/defaults.d/) +## vmware-dev: VMWare development build + +* [Model](src/vmware-dev/mod.rs) +* [Default settings](src/vmware-dev/defaults.d/) + # This directory We use `build.rs` to symlink the proper API model source code for Cargo to build. diff --git a/sources/models/src/vmware-dev/defaults.d/10-defaults.toml b/sources/models/src/vmware-dev/defaults.d/10-defaults.toml new file mode 120000 index 00000000000..a202ba61a4c --- /dev/null +++ b/sources/models/src/vmware-dev/defaults.d/10-defaults.toml @@ -0,0 +1 @@ +../../../shared-defaults/defaults.toml \ No newline at end of file diff --git a/sources/models/src/vmware-dev/defaults.d/50-vmware-dev.toml b/sources/models/src/vmware-dev/defaults.d/50-vmware-dev.toml new file mode 100644 index 00000000000..9c29adcb3cc --- /dev/null +++ b/sources/models/src/vmware-dev/defaults.d/50-vmware-dev.toml @@ -0,0 +1,18 @@ +[configuration-files.containerd-config-toml] +# No override to path +template-path = "/usr/share/templates/containerd-config-toml_vmware-dev" + +# Docker +[services.docker] +restart-commands = ["/bin/systemctl try-restart docker.service"] +configuration-files = ["proxy-env"] + +# Network +[metadata.settings.network] +affected-services = ["containerd", "docker", "host-containerd"] + +# NTP +# Use a public endpoint, don't assume any local ones. +[settings.ntp] +time-servers = ["2.amazon.pool.ntp.org"] + diff --git a/sources/models/src/vmware-dev/mod.rs b/sources/models/src/vmware-dev/mod.rs new file mode 100644 index 00000000000..6b472cb086a --- /dev/null +++ b/sources/models/src/vmware-dev/mod.rs @@ -0,0 +1,18 @@ +use model_derive::model; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +use crate::modeled_types::Identifier; +use crate::{ContainerImage, KernelSettings, NetworkSettings, NtpSettings, UpdatesSettings}; + +// Note: we have to use 'rename' here because the top-level Settings structure is the only one +// that uses its name in serialization; internal structures use the field name that points to it +#[model(rename = "settings", impl_default = true)] +struct Settings { + motd: String, + updates: UpdatesSettings, + host_containers: HashMap, + ntp: NtpSettings, + network: NetworkSettings, + kernel: KernelSettings, +} diff --git a/variants/README.md b/variants/README.md index f0ffd2bd1a6..7540f28396e 100644 --- a/variants/README.md +++ b/variants/README.md @@ -64,10 +64,17 @@ This variant is compatible with Kubernetes 1.19, 1.20, and 1.21 clusters. The [aws-ecs-1](aws-ecs-1/Cargo.toml) variant includes the packages needed to run an [Amazon ECS](https://ecs.aws) container instance in AWS. -### aws-dev: Development build +### aws-dev: AWS development build The [aws-dev](aws-dev/Cargo.toml) variant has useful packages for local development of the OS. It includes tools for troubleshooting as well as Docker for running containers. +User data will be read from IMDS. + +### vmware-dev: VMWare development build + +The [vmware-dev](vmware-dev/Cargo.toml) variant has useful packages for local development of the OS, and is intended to run as a VMWare guest. +It includes tools for troubleshooting as well as Docker for running containers. +User data will be read from a mounted CD-ROM, either from a file named "user-data" or from an OVF file. ## Development diff --git a/variants/vmware-dev/Cargo.lock b/variants/vmware-dev/Cargo.lock new file mode 100644 index 00000000000..1406da3d9f8 --- /dev/null +++ b/variants/vmware-dev/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "vmware-dev" +version = "0.1.0" diff --git a/variants/vmware-dev/Cargo.toml b/variants/vmware-dev/Cargo.toml new file mode 100644 index 00000000000..3ceb7f92350 --- /dev/null +++ b/variants/vmware-dev/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "vmware-dev" +version = "0.1.0" +edition = "2018" +publish = false +build = "build.rs" +# Don't rebuild crate just because of changes to README. +exclude = ["README.md"] + +[package.metadata.build-variant] +included-packages = [ +# core + "release", +# docker + "docker-cli", + "docker-engine", + "docker-init", + "docker-proxy", +# tools + "findutils", + "login", + "iputils", + "procps", + "strace", + "tcpdump", + "chrony-tools", +] + +[lib] +path = "lib.rs" diff --git a/variants/vmware-dev/build.rs b/variants/vmware-dev/build.rs new file mode 100644 index 00000000000..d6a90e4df44 --- /dev/null +++ b/variants/vmware-dev/build.rs @@ -0,0 +1,9 @@ +use std::process::{exit, Command}; + +fn main() -> Result<(), std::io::Error> { + let ret = Command::new("buildsys").arg("build-variant").status()?; + if !ret.success() { + exit(1); + } + Ok(()) +} diff --git a/variants/vmware-dev/lib.rs b/variants/vmware-dev/lib.rs new file mode 100644 index 00000000000..d799fb2d44c --- /dev/null +++ b/variants/vmware-dev/lib.rs @@ -0,0 +1 @@ +// not used