Skip to content
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

Unified installer for machine images #44

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

jdpleiness
Copy link
Contributor

@jdpleiness jdpleiness commented Jun 9, 2023

Overview

This PR introduces a new unified installer written in Go as outlined in PR-FAQ: Delivering Confidence.
This unified installer aims to replace the following install scripts:

Current project status

While the installer was initially scoped to address problems with the current machine image deployment pipeline, components could be easily changed to fit any new machine image deployment models that may arise in the future. New deployment models with new requirements may also result in being able to drastically simplify the installer code.

Objectives

Initial success at reducing project build times (see below) by roughly 43%. Build times could be reduced further if offline images were no longer needed.

Screenshot 2023-06-09 at 2 31 05 PM

Components

The installer is composed of the following components:

sginstall

The sginstall component is the main installation process. This will do the necessary system configuration (disk, kernel, user, images, containerd, k3s, etc...)

sourcegraphd

The sourcegraphd component is a system daemon that monitors the current version of sourcegraph and if an update is needed. This component could also serve a diagnostics page in the future rather than the current 404 if there is an issue booting the machine image.

sginit

The sginit component is is a systemd oneshot service that will finalize the system configuration and setup upon first boot of the image.

Progress

  • Develop initial libraries to support install process (disk, helm, k3s, containerd, etc...)
  • Integration tests of each library
  • CLI and basic install
  • Dynamic resource limits generated based on machine resources available at boot
  • Offline image deployment support
  • Initial Packer build
  • Test with AWS install
  • Test with GCP install
  • Test generic install
  • Build process automation
  • Feature flag tests that are integration tests only
  • Evaluate and align with new requirements around shifting deployment strategy
  • Evaluate if offline install is still a needed feature

Build

At current time, this project utilized Git LFS to handle large files that are embedded in the final Go binary to enable offline installation. Please make sure Git LFS is installed on your system before proceeding.

Building the Go binary:

To build the Go binary, run ./build.sh from the base of the project. This will output three files:

  • cmd/install/bin/sg-init
  • cmd/install/bin/sourcegraphd
  • bin/sginstall

These files will be used by Packer in the next step.

Building the AMI:

To create an AMI that will use the installer, run the following:
packer build -var "instance_version=5.0.4" ./packer/dev/dev-builder.pkr.hcl

This will produce an AMI using Amazon Linux 2023 that is ready to be run.

Note
The current version of the installer is pinned to Sourcegraph 5.0.4.

Methods available for determining if a distro is:
- Amazon Linux
- RHEL
- Fedora
- Debian
- Ubuntu
- if SELinux is enabled
Add pkg it manage the install of containerd
Add kernel package to set kernel parameters for Sourcegraph install.
Add package to install and configure K3s on a system using the K3s air gap install method.
K3s binaries, install.sh, and container images are embedded into the installer binary.
This allows for strict version pinning, faster deployment, and future air-gap installation considerations.
Add image package for pulling, saving, and loading images used for Sourcegraph deployments.
Add helm package for installing helm onto the system.
This package embeds the helm binary into the installer binary.
This allows for strict version pinning, faster deployment, and future air-gap installation considerations.
Add sourcegraph package for installing sourcegraph to a system.
This package embeds the ingress, configmap, and helm charts needed for sourcegraph.
Add .editorconfig to be inline with main sourcegraph repo style.
Add systemd oneshot service to run on first boot and complete sourcegraph setup.
Add daemon to handle sourcegraph updates and installation tasks.
Add functions to update sourcegraph helm install as well as check for upgrades
@jdpleiness jdpleiness self-assigned this Jun 9, 2023
cmd/init/main.go Outdated Show resolved Hide resolved
@jdpleiness jdpleiness requested a review from nelsonjr June 12, 2023 18:18
Add `integration` flag for run Go tests that have side effects like installing software. To run integration test run `go test -integration`.
}

// LinkDataVolumes will setup the k3s storage and persistent volume pod storage on our data disk.
func LinkDataVolumes() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe it is just me but it would be nice if these were logically grouped to make it easier to parse related statements
e.g.

func LinkDataVolumes() error {
  {  
    mkdir
    symlink
  }

  {
    mkdir
    mkdir
    symlink
  }
}

internal/system/distro/distro.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants