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

[self-hosted] Gitpod local preview install method #10532

Merged
merged 1 commit into from
Jun 15, 2022
Merged

Conversation

Pothulapati
Copy link
Contributor

@Pothulapati Pothulapati commented Jun 8, 2022

Description

This PR adds a new install method called preview under the
install directory. This includes a sh script i.e entrypoint.sh
that gets loaded into a docker container in the Dockerfile.

This entrypoint.sh does the following:

  • Checks for minimum system requirements
  • Generates a root certificate using mkcerts, and loads into the
    host's /tmp/gitpod/gitpod-ca.crt.
  • Renders cert-manager resources, self-signed Gitpod into
    /var/lib/rancher/k3s/server/manifests.
  • Initialises k3s inside the container.

This is the first iteration of this method, a number of planned
improvements have been noted
and will be added in the
coming days.

Signed-off-by: Tarun Pothulapati tarun@gitpod.io

Related Issue(s)

Fixes #9075

How to test

Run the following on a linux machine

docker run --privileged --name gitpod --rm -it -v /tmp/gitpod:/var/gitpod eu.gcr.io/gitpod-core-dev/build/preview-install:tar-preview-install.4

Switch to a different tag and interact with the cluster by running

docker exec gitpod kubectl get pods -A

Once you see all the pods running, Retrieve the gitpod URL by runnning

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' gitpod |  sed -r 's/[.]+/-/g' | sed 's/$/.nip.io/g'

Load the SSL cert at /tmp/gitpod/gitpod-ca.crt into your browser, and access the retrieved URL.

Release Notes

[self-hosted] Add new local preview installation method

Documentation

@@ -0,0 +1,21 @@
FROM eu.gcr.io/gitpod-core-dev/build/installer:release-2022.05.0.5 AS installer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, I pinned to the latest installer release but this means that we have to update this in each release which isn't a great way. Any ideas? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Once this is part of gitpod-io/gitpod, we can build this image on main by default, and add an annotation to build from branches.

install/preview/README.md Outdated Show resolved Hide resolved
@Pothulapati Pothulapati force-pushed the tar/preview-install branch 5 times, most recently from 6155f06 to 8a68ace Compare June 13, 2022 13:44
## Installation

```bash
docker run --privileged --name gitpod --rm -it -v /tmp/gitpod:/var/gitpod eu.gcr.io/gitpod-core-dev/build/installer:tar-preview-install.4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update the image tag, in a separate PR to be a release tag

@Pothulapati
Copy link
Contributor Author

Marking this PR ready for review, and expect the following changes in separate PR's:

@Pothulapati Pothulapati marked this pull request as ready for review June 13, 2022 13:47
@Pothulapati Pothulapati requested a review from a team June 13, 2022 13:47
@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label Jun 13, 2022
@adrienthebo
Copy link
Contributor

adrienthebo commented Jun 14, 2022

I've tested this on a Mac running Docker for Desktop, and get the following result:

❯ docker run --privileged --name gitpod --rm -it -v /tmp/gitpod:/var/gitpod eu.gcr.io/gitpod-core-dev/build/installer:tar-preview-install.4

Installs Gitpod

Usage:
  gitpod-installer [command]

Available Commands:
  completion  generate the autocompletion script for the specified shell
  help        Help about any command
  init        Create a base config file
  mirror      Performs mirroring tasks
  render      Renders the Kubernetes manifests required to install Gitpod
  validate    Performs validation tasks
  version     Display the version information

Flags:
      --debug-version-file string   path to a version manifest - not intended for production use
  -h, --help                        help for gitpod-installer
      --strict-parse                toggle strict configuration parsing (default true)

Use "gitpod-installer [command] --help" for more information about a command.

The testing notes indicate that this requires Linux, and I'm not sure how this is interacting with Mac.


I just tested this on a GCP image and I got the same results:

❯ gcloud compute instances create gitpod-preview-$RANDOM \
  --machine-type=n2-standard-4 \
  --image="$(gcloud compute images list --filter='ubuntu-os-cloud AND family:ubuntu-2004-lts' --format='get(name)')" \
  --image-project=ubuntu-os-cloud \
  --zone="$(gcloud config list --format='get(compute.region)')-b" \
  --metadata=startup-script='
    apt-get update
    apt-get install -y docker.io
    '
 gcloud compute ssh root@gitpod-preview-22198 -- 'docker run --privileged --name gitpod --rm -it -v /tmp/gitpod:/var/gitpod eu.gcr.io/gitpod-core-dev/build/installer:tar-preview-install.4'
Updating project ssh metadata...⠼Updated [https://www.googleapis.com/compute/v1/projects/adrien-self-hosted-testing-5k4].
Updating project ssh metadata...done.
Waiting for SSH key to propagate.
Installs Gitpod

Usage:
  gitpod-installer [command]

Available Commands:
  completion  generate the autocompletion script for the specified shell
  help        Help about any command
  init        Create a base config file
  mirror      Performs mirroring tasks
  render      Renders the Kubernetes manifests required to install Gitpod
  validate    Performs validation tasks
  version     Display the version information

Flags:
      --debug-version-file string   path to a version manifest - not intended for production use
  -h, --help                        help for gitpod-installer
      --strict-parse                toggle strict configuration parsing (default true)

Use "gitpod-installer [command] --help" for more information about a command.

Is this user error on my part?

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-tar-preview-install.6 because the annotations in the pull request description changed
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-tar-preview-install.7 because the annotations in the pull request description changed
(with .werft/ from main)

@Pothulapati
Copy link
Contributor Author

@adrienthebo My bad, I put the wrong image tag. It should instead be eu.gcr.io/gitpod-core-dev/build/preview-install. Updated the testing instructions in the PR comment accordingly. :/

Fixes #9075

This PR adds a new install method called `preview` under the
`install` directory. This includes a sh script i.e `entrypoint.sh`
that gets loaded into a docker container in the `Dockerfile`.

This `entrypoint.sh` does the following:
- Checks for minimum system requirements
- Generates a root certificate using `mkcerts`, and loads into the
  host's `/tmp/gitpod/gitpod-ca.crt`.
- Renders `cert-manager` resources, self-signed Gitpod into
  `/var/lib/rancher/k3s/server/manifests`.
- Initialises `k3s` inside the container.

Signed-off-by: Tarun Pothulapati <tarun@gitpod.io>
@adrienthebo
Copy link
Contributor

adrienthebo commented Jun 15, 2022

Test cases:

  • Docker Desktop for Mac: app ran correctly but Docker Desktop for Mac doesn't expose the bridge interface as it's inside the Docker Desktop VM. That's out of scope for this PR.
  • GCP instance: app ran correctly, ran into issues with name resolution and port forwarding. Again, my error
  • Linux laptop: everything spun up correctly.

LGTM! 👍

@roboquat roboquat merged commit 6b387de into main Jun 15, 2022
@roboquat roboquat deleted the tar/preview-install branch June 15, 2022 16:14
Copy link
Contributor

@corneliusludmann corneliusludmann left a comment

Choose a reason for hiding this comment

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

@Pothulapati I know, I'm late to the party. Good work! 🚀

I have just 2 smaller comments probably for follow-up improvements.

Comment on lines +103 to +109
echo "extracting images to download ahead..."
/gitpod-installer render --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt
echo "downloading images..."
while read -r image "$(cat /gitpod-images.txt)"; do
# shellcheck disable=SC2154
ctr images pull "$image" >/dev/null &
done
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the rationale behind pulling the images ahead?

Copy link
Contributor Author

@Pothulapati Pothulapati Jun 16, 2022

Choose a reason for hiding this comment

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

To make the pods startup faster? 🤔

There's not a lot of gain here (as our main painpoint is the workspace image build) but I was able to see around 2-3 minutes when I added this 🤔

Comment on lines +113 to +121
/gitpod-installer render --config config.yaml --output-split-files /var/lib/rancher/k3s/server/manifests/gitpod
for f in /var/lib/rancher/k3s/server/manifests/gitpod/*.yaml; do (cat "$f"; echo) >> /var/lib/rancher/k3s/server/gitpod.debug; done
rm /var/lib/rancher/k3s/server/manifests/gitpod/*NetworkPolicy*
for f in /var/lib/rancher/k3s/server/manifests/gitpod/*PersistentVolumeClaim*.yaml; do yq e -i '.spec.storageClassName="local-path"' "$f"; done
yq eval-all -i ". as \$item ireduce ({}; . *+ \$item)" /var/lib/rancher/k3s/server/manifests/gitpod/*_StatefulSet_messagebus.yaml /app/manifests/messagebus.yaml
for f in /var/lib/rancher/k3s/server/manifests/gitpod/*StatefulSet*.yaml; do yq e -i '.spec.volumeClaimTemplates[0].spec.storageClassName="local-path"' "$f"; done

# removing init container from ws-daemon (systemd and Ubuntu)
yq eval-all -i 'del(.spec.template.spec.initContainers[0])' /var/lib/rancher/k3s/server/manifests/gitpod/*_DaemonSet_ws-daemon.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

This a quite a lot of pre-processing. Could you add comments on why they are actually needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added them in #10695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/L team: delivery Issue belongs to the self-hosted team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Epic: Local preview "installation" method
5 participants