Giter Club home page Giter Club logo

bottlerocket's Introduction

Bottlerocket OS

Welcome to Bottlerocket!

Bottlerocket is a free and open-source Linux-based operating system meant for hosting containers.

To learn more about Bottlerocket, visit the official Bottlerocket website and documentation. Otherwise, if you’re ready to jump right in, read one of our setup guides for running Bottlerocket in Amazon EKS, Amazon ECS, or VMware. If you're interested in running Bottlerocket on bare metal servers, please refer to the provisioning guide to get started.

Bottlerocket focuses on security and maintainability, providing a reliable, consistent, and safe platform for container-based workloads. This is a reflection of what we've learned building operating systems and services at Amazon. You can read more about what drives us in our charter.

The base operating system has just what you need to run containers reliably, and is built with standard open-source components. Bottlerocket-specific additions focus on reliable updates and on the API. Instead of making configuration changes manually, you can change settings with an API call, and these changes are automatically migrated through updates.

Some notable features include:

Participate in the Community

There are many ways to take part in the Bottlerocket community:

  • Join us on Meetup to hear about the latest Bottlerocket (virtual/in-person) events and community meetings. Community meetings are typically every other week.

    Details can be found under the Events section on Meetup, and you will receive email notifications if you become a member of the Meetup group. (It's free to join!)

  • Start or join a discussion if you have questions about Bottlerocket.

  • If you're interested in contributing, thank you! Please see our contributor's guide.

Contact us

If you find a security issue, please contact our security team rather than opening an issue.

We use GitHub issues to track other bug reports and feature requests. You can look at existing issues to see whether your concern is already known.

If not, you can select from a few templates and get some guidance on the type of information that would be most helpful. Contact us with a new issue here.

We don't have other communication channels set up quite yet, but don't worry about making an issue or a discussion thread! You can let us know about things that seem difficult, or even ways you might like to help.

Variants

To start, we're focusing on the use of Bottlerocket as a host OS in AWS EKS Kubernetes clusters and Amazon ECS clusters. We’re excited to get early feedback and to continue working on more use cases!

Bottlerocket is architected such that different cloud environments and container orchestrators can be supported in the future. A build of Bottlerocket that supports different features or integration characteristics is known as a 'variant'. The artifacts of a build will include the architecture and variant name. For example, an x86_64 build of the aws-k8s-1.24 variant will produce an image named bottlerocket-aws-k8s-1.24-x86_64-<version>-<commit>.img.

The following variants support EKS, as described above:

  • aws-k8s-1.23
  • aws-k8s-1.24
  • aws-k8s-1.25
  • aws-k8s-1.26
  • aws-k8s-1.27
  • aws-k8s-1.28
  • aws-k8s-1.29
  • aws-k8s-1.23-nvidia
  • aws-k8s-1.24-nvidia
  • aws-k8s-1.25-nvidia
  • aws-k8s-1.26-nvidia
  • aws-k8s-1.27-nvidia
  • aws-k8s-1.28-nvidia
  • aws-k8s-1.29-nvidia

The following variants support ECS:

  • aws-ecs-1
  • aws-ecs-1-nvidia
  • aws-ecs-2
  • aws-ecs-2-nvidia

We also have variants that are designed to be Kubernetes worker nodes in VMware:

  • vmware-k8s-1.26
  • vmware-k8s-1.27
  • vmware-k8s-1.28
  • vmware-k8s-1.29

The following variants are designed to be Kubernetes worker nodes on bare metal:

  • metal-k8s-1.26
  • metal-k8s-1.27
  • metal-k8s-1.28
  • metal-k8s-1.29

The following variants are no longer supported:

  • All Kubernetes variants using Kubernetes 1.22 and earlier
  • Bare metal and VMware variants using Kubernetes 1.25 and earlier

We recommend users replace nodes running these variants with the latest variant compatible with their cluster.

Architectures

Our supported architectures include x86_64 and aarch64 (written as arm64 in some contexts).

Setup

🚶 🏃

Bottlerocket is best used with a container orchestrator. To get started with Kubernetes in Amazon EKS, please see QUICKSTART-EKS. To get started with Kubernetes in VMware, please see QUICKSTART-VMWARE. To get started with Amazon ECS, please see QUICKSTART-ECS. These guides describe:

  • how to set up a cluster with the orchestrator, so your Bottlerocket instance can run containers
  • how to launch a Bottlerocket instance in EC2 or VMware

To see how to provision Bottlerocket on bare metal, see PROVISIONING-METAL.

To build your own Bottlerocket images, please see BUILDING. It describes:

  • how to build an image
  • how to register an EC2 AMI from an image

To publish your built Bottlerocket images, please see PUBLISHING. It describes:

  • how to make TUF repos including your image
  • how to copy your AMI across regions
  • how to mark your AMIs public or grant access to specific accounts
  • how to make your AMIs discoverable using SSM parameters

Exploration

To improve security, there's no SSH server in a Bottlerocket image, and not even a shell.

Don't panic!

There are a couple out-of-band access methods you can use to explore Bottlerocket like you would a typical Linux system. Either option will give you a shell within Bottlerocket. From there, you can change settings, manually update Bottlerocket, debug problems, and generally explore.

Note: These methods require that your instance has permission to access the ECR repository where these containers live; the appropriate policy to add to your instance's IAM role is AmazonEC2ContainerRegistryReadOnly.

Control container

Bottlerocket has a "control" container, enabled by default, that runs outside of the orchestrator in a separate instance of containerd. This container runs the AWS SSM agent that lets you run commands, or start shell sessions, on Bottlerocket instances in EC2. (You can easily replace this control container with your own just by changing the URI; see Settings.)

In AWS, you need to give your instance the SSM role for this to work; see the setup guide. Outside of AWS, you can use AWS Systems Manager for hybrid environments. There's more detail about hybrid environments in the control container documentation.

Once the instance is started, you can start a session:

  • Go to AWS SSM's Session Manager
  • Select "Start session" and choose your Bottlerocket instance
  • Select "Start session" again to get a shell

If you prefer a command-line tool, you can start a session with a recent AWS CLI and the session-manager-plugin. Then you'd be able to start a session using only your instance ID, like this:

aws ssm start-session --target INSTANCE_ID

With the default control container, you can make API calls to configure and manage your Bottlerocket host. To do even more, read the next section about the admin container. You can access the admin container from the control container like this:

enter-admin-container

Admin container

Bottlerocket has an administrative container, disabled by default, that runs outside of the orchestrator in a separate instance of containerd. This container has an SSH server that lets you log in as ec2-user using your EC2-registered SSH key. Outside of AWS, you can pass in your own SSH keys. (You can easily replace this admin container with your own just by changing the URI; see Settings.

To enable the container, you can change the setting in user data when starting Bottlerocket, for example EC2 instance user data:

[settings.host-containers.admin]
enabled = true

If Bottlerocket is already running, you can enable the admin container from the default control container like this:

enable-admin-container

Or you can start an interactive session immediately like this:

enter-admin-container

If you're using a custom control container, or want to make the API calls directly, you can enable the admin container like this instead:

apiclient set host-containers.admin.enabled=true

Once you've enabled the admin container, you can either access it through SSH or execute commands from the control container like this:

apiclient exec admin bash

Once you're in the admin container, you can run sheltie to get a full root shell in the Bottlerocket host. Be careful; while you can inspect and change even more as root, Bottlerocket's filesystem and dm-verity setup will prevent most changes from persisting over a restart - see Security.

Updates

Rather than a package manager that updates individual pieces of software, Bottlerocket downloads a full filesystem image and reboots into it. It can automatically roll back if boot failures occur, and workload failures can trigger manual rollbacks.

The update process uses images secured by TUF. For more details, see the update system documentation.

Update methods

There are several ways of updating your Bottlerocket hosts. We provide tools for automatically updating hosts, as well as an API for direct control of updates.

Automated updates

For EKS variants of Bottlerocket, we recommend using the Bottlerocket update operator for automated updates.

For the ECS variant of Bottlerocket, we recommend using the Bottlerocket ECS updater for automated updates.

Update API

The Bottlerocket API includes methods for checking and starting system updates. You can read more about the update APIs in our update system documentation.

apiclient knows how to handle those update APIs for you, and you can run it from the control or admin containers.

To see what updates are available:

apiclient update check

If an update is available, it will show up in the chosen_update field. The available_updates field will show the full list of available versions, including older versions, because Bottlerocket supports safely rolling back.

To apply the latest update:

apiclient update apply

The next time you reboot, you'll start up in the new version, and system configuration will be automatically migrated. To reboot right away:

apiclient reboot

If you're confident about updating, the apiclient update apply command has --check and --reboot flags to combine the above actions, so you can accomplish all of the above steps like this:

apiclient update apply --check --reboot

See the apiclient documentation for more details.

Update rollback

The system will automatically roll back if it's unable to boot. If the update is not functional for a given container workload, you can do a manual rollback:

signpost rollback-to-inactive
reboot

This doesn't require any external communication, so it's quicker than apiclient, and it's made to be as reliable as possible.

Settings

Here we'll describe the settings you can configure on your Bottlerocket instance, and how to do it.

(API endpoints are defined in our OpenAPI spec if you want more detail.)

Interacting with settings

Using the API client

You can see the current settings with an API request:

apiclient get settings

This will return all of the current settings in JSON format. For example, here's an abbreviated response:

{"motd": "...", {"kubernetes": {}}}

You can change settings like this:

apiclient set motd="hi there" kubernetes.node-labels.environment=test

You can also use a JSON input mode to help change many related settings at once, and a "raw" mode if you want more control over how the settings are committed and applied to the system. See the apiclient README for details.

Using user data

If you know what settings you want to change when you start your Bottlerocket instance, you can send them in the user data.

In user data, we structure the settings in TOML form to make things a bit simpler. Here's the user data to change the message of the day setting, as we did in the last section:

[settings]
motd = "my own value!"

If your user data is over the size limit of the platform (e.g. 16KiB for EC2) you can compress the contents with gzip. (With aws-cli, you can use --user-data fileb:///path/to/gz-file to pass binary data.)

Description of settings

Here we'll describe each setting you can change.

Note: You can see the default values (for any settings that are not generated at runtime) by looking in the defaults.d directory for a variant, for example aws-ecs-2.

When you're sending settings to the API, or receiving settings from the API, they're in a structured JSON format. This allows modification of any number of keys at once. It also lets us ensure that they fit the definition of the Bottlerocket data model - requests with invalid settings won't even parse correctly, helping ensure safety.

Here, however, we'll use the shortcut "dotted key" syntax for referring to keys. This is used in some API endpoints with less-structured requests or responses. It's also more compact for our needs here.

In this format, "settings.kubernetes.cluster-name" refers to the same key as in the JSON {"settings": {"kubernetes": {"cluster-name": "value"}}}.

NOTE: bottlerocket.dev now contains a complete, versioned setting reference. This documents retains the headings below for existing link and bookmark compatability. Please update your bookmarks and check out bottlerocket.dev for future updates to the setting reference.

Top-level settings

See the settings.motd reference.

Kubernetes settings

See the settings.kubernetes.* reference.

Amazon ECS settings

See the settings.ecs.* reference.

CloudFormation signal helper settings

See the settings.cloudformation.* reference.

Auto Scaling group settings

See the settings.autoscaling.* reference.

OCI Hooks settings

See the settings.oci-hooks.* reference.

OCI Defaults settings

See the settings.oci-defaults.* reference.

OCI Defaults: Capabilities

See the "Capabilities Settings" section in the settings.oci-defaults.* reference.

OCI Defaults: Resource Limits

See the "Resource Limits Settings" section in the settings.oci-defaults.* reference.

Container image registry settings

See the settings.container-registry.* reference.

Container runtime settings

See the settings.container-runtime.* reference.

Updates settings

See the settings.updates.* reference.

Network settings

See the settings.network.* reference.

Proxy settings

See the "Proxy Settings" section in the settings.networks.* reference.

Metrics settings

See the settings.metrics.* reference.

Time settings

See the settings.ntp.* reference.

Kernel settings

See the settings.kernel.* reference.

Boot-related settings

See the settings.boot.* reference.

Custom CA certificates settings

See the settings.pki.* reference.

Host containers settings

See the settings.host-containers.* reference.

Custom host containers

See the Host Containers documentation.

Bootstrap containers settings

See the settings.bootstrap-containers.* reference as well as the Bootstrap Containers documentation

Mount propagations in bootstrap and superpowered containers

Both bootstrap and superpowered host containers are configured with the /.bottlerocket/rootfs/mnt bind mount that points to /mnt in the host, which itself is a bind mount of /local/mnt. This bind mount is set up with shared propagations, so any new mount point created underneath /.bottlerocket/rootfs/mnt in any bootstrap or superpowered host container will propagate across mount namespaces. You can use this feature to configure ephemeral disks attached to your hosts that you may want to use on your workloads.

Platform-specific settings

Platform-specific settings are automatically set at boot time by early-boot-config based on metadata available on the running platform. They can be overridden for testing purposes in the same way as other settings.

AWS-specific settings

See the settings.aws.* reference.

Logs

You can use logdog through the admin container to obtain an archive of log files from your Bottlerocket host. SSH to the Bottlerocket host or apiclient exec admin bash to access the admin container, then run:

sudo sheltie
logdog

This will write an archive of the logs to /var/log/support/bottlerocket-logs.tar.gz. This archive is accessible from host containers at /.bottlerocket/support. You can use SSH to retrieve the file. Once you have exited from the Bottlerocket host, run a command like:

ssh -i YOUR_KEY_FILE \
  ec2-user@YOUR_HOST \
  "cat /.bottlerocket/support/bottlerocket-logs.tar.gz" > bottlerocket-logs.tar.gz

(If your instance isn't accessible through SSH, you can use SSH over SSM.)

For a list of what is collected, see the logdog command list.

Kdump Support

Bottlerocket provides support to collect kernel crash dumps whenever the system kernel panics. Once this happens, both the dmesg log and vmcore dump are stored at /var/log/kdump, and the system reboots.

There are a few important caveats about the provided kdump support:

  • Currently, only vmware variants have kdump support enabled
  • The system kernel will reserve 256MB for the crash kernel, only when the host has at least 2GB of memory; the reserved space won't be available for processes running in the host
  • The crash kernel will only be loaded when the crashkernel parameter is present in the kernel's cmdline and if there is memory reserved for it

NVIDIA GPUs Support

Bottlerocket's nvidia variants include the required packages and configurations to leverage NVIDIA GPUs. Currently, the following NVIDIA driver versions are supported in Bottlerocket:

  • 470.X
  • 515.X

The official AMIs for these variants can be used with EC2 GPU-equipped instance types such as: p2, p3, p4, g3, g4dn, g5 and g5g. Note that older instance types, such as p2, are not supported by NVIDIA driver 515.X and above. You need to make sure you select the appropriate AMI depending on the instance type you are planning to use. Please see QUICKSTART-EKS for further details about Kubernetes variants, and QUICKSTART-ECS for ECS variants.

Details

Security

🛡️ 🦀

To learn more about security features in Bottlerocket, please see SECURITY FEATURES. It describes how we use features like dm-verity and SELinux to protect the system from security threats.

To learn more about security recommendations for Bottlerocket, please see SECURITY GUIDANCE. It documents additional steps you can take to secure the OS, and includes resources such as a Pod Security Policy for your reference.

In addition, almost all first-party components are written in Rust. Rust eliminates some classes of memory safety issues, and encourages design patterns that help security.

Packaging

Bottlerocket is built from source using a container toolchain. We use RPM package definitions to build and install individual packages into an image. RPM itself is not in the image - it's just a common and convenient package definition format.

We currently package the following major third-party components:

For further documentation or to see the rest of the packages, see the packaging directory.

Updates

The Bottlerocket image has two identical sets of partitions, A and B. When updating Bottlerocket, the partition table is updated to point from set A to set B, or vice versa.

We also track successful boots, and if there are failures it will automatically revert back to the prior working partition set.

The update process uses images secured by TUF. For more details, see the update system documentation.

API

There are two main ways you'd interact with a production Bottlerocket instance. (There are a couple more exploration methods above for test instances.)

The first method is through a container orchestrator, for when you want to run or manage containers. This uses the standard channel for your orchestrator, for example a tool like kubectl for Kubernetes.

The second method is through the Bottlerocket API, for example when you want to configure the system.

There's an HTTP API server that listens on a local Unix-domain socket. Remote access to the API requires an authenticated transport such as SSM's RunCommand or Session Manager, as described above. For more details, see the apiserver documentation.

The apiclient can be used to make requests. They're just HTTP requests, but the API client simplifies making requests with the Unix-domain socket.

To make configuration easier, we have early-boot-config, which can send an API request for you based on instance user data. If you start a virtual machine, like an EC2 instance, it will read TOML-formatted Bottlerocket configuration from user data and send it to the API server. This way, you can configure your Bottlerocket instance without having to make API calls after launch.

See Settings above for examples and to understand what you can configure.

You can also access host containers through the API using apiclient exec.

The server and client are the user-facing components of the API system, but there are a number of other components that work together to make sure your settings are applied, and that they survive upgrades of Bottlerocket.

For more details, see the API system documentation.

Default Volumes

Bottlerocket operates with two default storage volumes.

  • The root device, holds the active and passive partition sets. It also contains the bootloader, the dm-verity hash tree for verifying the immutable root filesystem, and the data store for the Bottlerocket API.
  • The data device is used as persistent storage for container images, container orchestration, host-containers, and bootstrap containers. The operating system does not typically make changes to this volume during regular updates, though changes to upstream software such as containerd or kubelet could result in changes to their stored data. This device (mounted to /local on the host) can be used for application storage for orchestrated workloads; however, we recommend using an additional volume if possible for such cases. See this section of the Security Guidance documentation for more information.

On boot Bottlerocket will increase the data partition size to use all of the data device. If you increase the size of the device, you can reboot Bottlerocket to extend the data partition. If you need to extend the data partition without rebooting, have a look at this discussion.

bottlerocket's People

Contributors

arnaldo2792 avatar bcressey avatar cbgbt avatar dependabot[bot] avatar ecpullen avatar etungsten avatar foersleo avatar gthao313 avatar iliana avatar jahkeup avatar jamieand avatar jmt-lab avatar jpculp avatar jpmcb avatar kschumy avatar larvacea avatar markusboehme avatar mchaker avatar mjsterckx avatar sam-aws avatar sam-berning avatar samuelkarp avatar sanu11 avatar stmcginnis avatar stockholmux avatar tjkirch avatar vyaghras avatar webern avatar yeazelm avatar zmrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bottlerocket's Issues

Migration runner

We need a tool to run the migrations created using #44. At a high level, it needs to:

  • Take the data store path to migrate, and the version to migrate to
  • Find appropriate migrations on disk (perhaps being told some potential locations)
  • Run the migrations on a copy of the data store
  • If successful, flip the data store link to the copy

tough: Implement "latest known time"

I'd recommend we actually implement the "latest known time" bit referenced in the spec; if we come up without NTP access and the system clock is behind, we'd be vulnerable to rollback attacks, unless we store the latest known time and take that into account.

Originally posted by @tjkirch in #38 (comment)

tough: Perhaps allow for long-running update processes

What's the intended usage pattern for Repository? It seems like it does all of the work for TUF's client application detailed workflow during its load, and then the primary interface is targets to see what's available and read_target to fetch something.

This seems OK for one-shot processes that know what they want, but not for long-running systems that want to check for updates in a known repository later.

Perhaps we should split creation? To me it seems like the phases are (1) load local root, (2) try updating remote root, (3) remote timestamp, (4) snapshot and targets, (5) goto 3 and do 2,4,5 as necessary? And convenience methods to do 1-5 and 3-5. The current workflow would be the 1-5 method. (Obviously the fixed expires would need to be dynamic, roles would need to be stored, etc. to make this work.)

Originally posted by @tjkirch in #38 (comment)

tough: Clean up error type

  • Split the error type into separate modules?
  • Clean up places where context is provided by string arguments and use enums instead

Migration: migration helper functions

As we start writing data store migrations, we should add more functions to the helper library so they become easier and easier to write.

One helper function I expect will be commonly used is defaults_for, which will return the default values for a given subtree of settings. This could be useful in a few cases:

  • when we're adding a new subtree, assuming the apiserver or another component don't populate new subtrees with defaults automatically
  • if we know the old values for a tree that's changing aren't useful and we just want to replace them with the new defauls
  • if the old values are useful but we still need the new defaults to fill everything in appropriately

Migration: update system integration

Before rebooting for an update:

  • Pull migration list from the TUF metadata
  • Select relevant migrations for this update based on incoming/outgoing versions of update
  • Download (to persistent storage) and verify relevant migrations from metadata-specified location if they are not already included in the image (with matching checksum)
  • Cache TUF metadata required to verify the migration from the root.json installed on the verity partition
    • Add functionality to record and retrieve older root.json versions in tough
  • Read the directory as a filesystem-based TUF repo when running migrations
  • Use pentacle to execute the trusted version as a sealed memfd

Unfriendly error on /settings/pending when there's nothing pending

This 500 error is not very friendly, making it sound like you've done something wrong when requesting pending settings, when in fact there just are no pending settings. We should return an empty Settings, e.g. {}

$ curl 'localhost:4242/settings/pending'
{"description":"Found no 'settings' in datastore"}

Handle k8s settings changes after boot

Our default settings are missing restart commands for kubernetes. We need to determine the effect of updating the kubernetes settings in terms of system services that need to restart, and then redesign the "services" layout in the default settings, adding restart-commands if needed.

Templates with helpers aren't parsed correctly

Configuration file templates are parsed for settings in thar-be-settings. These settings are used to query the API for their associated values. Following the update to Handlebars 2.x, this parsing is broken.

base64_decode is a helper in both examples below.

Current behavior
Parsing template {{base64_decode settings.hostname}} returns base64_decode

Expected behavior
Parsing template {{base64_decode settings.hostname}} should return setting settings.hostname.

Migration: build system integration

  • Figure out which migrations should be built and included in the image (could start with a hardcoded list we keep up to date?)
  • Build the relevant migrations during the build process, each of which will be a Cargo project in a directory under workspaces/api/migration/migrations/vX.Y
  • Rename the built binaries to include the version from the path (see above) to fit migration conventions. (The final name would be invalid to Cargo, so it must be a rename.)
  • Install the migrations to /var/lib/thar/datastore/migrations in the image.

'sources' filename isn't checked

I was working on updating Rust and I updated the checksums in the sources file but forgot to update the filenames. I had deleted the files matching those filenames. The package still built. I think it should fail to build if the filenames in sources don't exist or the checksums don't match what's given for an exact filename.

tough: Figure out how to make hash types forward compatible

Originally from this thread: #38 (comment)

Consider making sha256 an Option<Decoded<Hex>> and providing code for making that easy to use throughout the library.

This is harder than just changing the internals, because the pub Target struct currently provides the hash information. Maybe it doesn't need to in order to be useful, since this library provides hash checking.

Generate all API models using OpenAPI

As part of #26, we may think about forking/writing our own generator for the API client. As part of that effort, it may be a great idea to also write a slimmed-down generator specifically for our API models.

This generator would create a Models library crate that contains only the models that apiserver and thar-be-settings use.

This would have multiple benefits:

  • Separation of concerns: the apiserver shouldn't need to be coupled to what is in the datastore. It only needs to know how to serve it.
  • Adding new settings to the API is as simple as adding them to the OpenAPI yaml and re-generating.
  • Less mucking about in the apiserver Rust code (no need to create structs, etc.)

%.makepkg isn't regenerated when sources or Cargo.lock changes

Now that spec2pkg generates rules to automatically download files, including those dynamically referenced from a Cargo.lock, it should be re-run whenever a sources file or a Cargo.lock (if present) is updated.

cc @bcressey who might have some ideas about how to do this, since I don't want to make a sources or Cargo.lock file required for any given package (filesystem should continue to have neither).

Add a readme

We need an overall readme for the project that we can iterate on. We also need component specific documentation within each rust project and as part of the build system.

Design Admin container

This should include a narrative on how users will interact with the OS including how they will access host logs, communicate with the API server, debug currently running containers and otherwise introspect the running system.

Migration: OS integration

Integrate the migrations from #34 and migrator from #62 into the OS.

  • A service for the migrator to run early during boot: @tjk
  • Create the default data store with appropriate links, not just as a directory (in apiserver, or in service if done after #119): @zmrow
  • Data store format indicator in the image: @tjk
  • Update code to reference /current instead of /v1 for data store path
  • Automated cleanup of old data stores and migrations

tough: Be more forgiving if the cached root.json is corrupt

The caching is outside of the spec so we have to be careful.

  • What does happen if the cached root is corrupt? It doesn't mean the datastore.read would necessarily fail, but it still might not verify below, and we don't retry with the given root.
  • What if the user gave a new root on purpose because they know the old/cached one is bad/outdated? We're ignoring them.

What if we load and verify both and take the higher version number? If the user-supplied root doesn't validate itself, that seems like an Error regardless of the cache; if the cached root doesn't validate itself we should probably remove it and continue with the user-supplied root; if neither validates, obviously Error.

Originally posted by @tjkirch in #38 (comment)

Templating of service restart commands

Feedback from #7:

We need templating of restart commands in order to handle commands with arguments that are based on changed settings.

For example, instead of reading /etc/hostname, systemd's hostnamectl accepts the new hostname as an argument. To do this, we'd want to have a template command like hostnamectl set-hostname {{ settings.hostname }}

tbs: base64 helper should fail if multiple params are given

The base64 helper is built to decode a single parameter. This makes sense in the context of our templates because each parameter is a setting. If a user needs to decode multiple parameters (settings) it should be done in multiple blocks, i.e {{base64_decode setting1}} : {{base64_decode setting2}}.

Expected behavior
The helper should fail if multiple params are passed to it: {{base64_decode setting1 setting2}}.

Current behavior
The helper will decode the first param in the list and happily carry on with life

Integrate k8s and EKS related bits into Thar

After investigation / discussion by @bcressey , @tjkirch , and @zmrow we've come up with the action items to make this happen:

  • Investigate the minimum settings needed to make k8s run pods
  • Add k8s settings to models in apiserver
  • Build a tool to handle settings that need to be dynamically set at runtime (Sundog, implemented in #49 )
  • Build a "setting generator" program that knows how to fetch k8s related settings at runtime
  • Add base64 decode helper to template library to render decoded base64 text

Metadata kind as enum

Feedback from #7:

The md field of Metadata (in the apiserver model) could be an enum of known metadata variants (like "AffectedServices") instead of a string. This could help us type-check different kinds of metadata for safety.

Prototype: data store migration and helpers

  • create a migration trait
  • write a prototype data store migration that implements the trait
  • create a CLI shell for migrations
  • write migration helpers for running the migration against given data/metadata

Migration: handle data store format changes

i.e. "major" version changes, for example if we change from a filesystem data store to SQLite or LMDB.

  • the migrator has to run migrations for major-version transitions (because we need to finish any minor version migrations before the major, and there may be more minor after the major)
  • the migrator has to handle major version links
  • research other changes that need to be made

tbs: Templates with helpers that require params should not render if no params are supplied

Helpers with required params (base64_decode for example) should fail the template rendering process if no params are given. Currently (with Handlebars 1.1), templates render but don't include the value (because one wasn't supplied).

Helper base64_decode requires one param, i.e {{base64_decode param}}. A template containing {{base64_decode}}` will render, which is undesired behavior.

Single settings commit at boot

We should update moondog and sundog so they don't both commit their settings changes at boot, and instead introduce a tiny new service that commits settings. It will depend on moondog and sundog, and the new target from #77 will depend on it, so ordering will be preserved.

  • Come up with name for committer service
  • Move commit code from moondog/sundog to this service
  • Add service and make target from #77 depend on it

moondog: Only run at first boot

Moondog should be able to track the state of the current boot. If the current boot is not the first boot, exit and don't set settings from userdata.

Migration: API integration

Assuming the API will expose system update status, we will want to expose migration status as part of it - at least as a potential failure reason.

API server model: prevent serialization of nested empty structs

In this code:

https://github.com/amazonlinux/PRIVATE-thar/blob/8044c6cee5b170fe0a40f2c64088f696c830f49f/workspaces/api/apiserver/src/model.rs#L9-L34

and given this struct:

Settings {
    timezone: None,
    hostname: None,
    docker: Some(DockerSettings {
        bridge_ip: None,
    },
}

this would be serialized in JSON as {"docker": {}} when it seems like it should serialize as {}.

Some options I can think of:

  • Make Settings.docker a DockerSettings instead of an Option<DockerSettings>, and #[derive(Default)] (or a more specific impl) for DockerSettings so that it can be deserialized when the key isn't present
  • Keep the struct the same, but change #[serde(skip_serializing_if = "Option::is_none")] on Settings.docker to a new function, DockerSettings::is_all_none (or skip_serialize or whatever seems right) so that serialization is skipped.

I think I like the first option better; if every key in every settings struct is always an Option<T>, it's redundant for the substructs themselves to be optional as well.

Using Wants not Requires on configured.target

(See #96)

The kubelet, docker, and containerd service files have dependencies on configured.target that are expressed with Wants instead of Requires.

This means that if configured.target fails at boot, kubelet and friends will start, even though we know we haven't generated the configuration files they need.

(This was done to avoid an even worse problem - if we used Requires, then kubelet and friends would stop or restart if the configuration utilities stopped or restarted; the configuration utilities should definitely not have an impact on the runtime of kubelet and friends once started.)

We couldn't find a way to express what we want in systemd, but we should continue research to show that it doesn't actually exist, and then consider our possible approaches:

  • augment systemd
  • wrap kubelet (and friends) to add domain knowledge
  • your idea here?

Script to create AMI from built image

We need a script to build an AMI from a Thar image. This may just be for the short-term, depending on how we continue with build automation and what other tools become available.

thar-be-settings doesn't handle restart command status correctly (also logging output will be ugly)

https://github.com/amazonlinux/PRIVATE-thar/blob/ad9e9b1a9cc03dae0579d33ff9b32b4fa201a9bb/workspaces/api/thar-be-settings/src/service.rs#L115-L120
In the snippet above, we are correctly handling the case where a command simply fails to run (nonexistent command, etc), but we are not handling the case where the command runs but its status is nonzero.

https://github.com/amazonlinux/PRIVATE-thar/blob/ad9e9b1a9cc03dae0579d33ff9b32b4fa201a9bb/workspaces/api/thar-be-settings/src/service.rs#L121-L122
Also, the above lines log the stdout and stderr directly. As it turns out, both of them are type Vec<u8> which will log a giant ugly string of numbers.

tough: HTTP retries

On connection resets, the Reader needs to retry the HTTP connection for the rest of the range (similar to wget’s default behavior).

systemd target representing configured system

We need a systemd target representing the point at which all userdata (moondog) and dynamic (sundog) configuration is complete. This is what services like k8s and EKS will depend on, because they need the user's cluster settings to be fully applied to the system before starting.

  • Create target
  • Update k8s/EKS service units to depend on it, in addition to network or other existing dependencies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.