|
| 1 | +# Installer |
| 2 | + |
| 3 | +The best way to get started with Gitpod self-hosted |
| 4 | + |
| 5 | +> This guide assumes that a compatible infrastructure is in place. Please |
| 6 | +> refer to the [Gitpod docs](https://www.gitpod.io/docs/self-hosted/latest/installation) |
| 7 | +> for instructions on how to create the infrastructure. |
| 8 | +
|
| 9 | +# Key Concepts |
| 10 | + |
| 11 | +The Installer is a complete replacement for our Helm charts. Over time, |
| 12 | +this had grown to be too complex to effectively support and was a barrier |
| 13 | +to entry for new users - the base config was many hundreds of lines long |
| 14 | +and did not have effective validation on it. By contrast, the Installer's |
| 15 | +config is < 50 lines long and can be fully validated before running. |
| 16 | + |
| 17 | +Conceptually, the process is now: |
| 18 | +1. generate a base config |
| 19 | +2. amend the config for your own use-case |
| 20 | +3. validate |
| 21 | +4. render the Kubernetes YAML |
| 22 | +5. `kubectl apply` |
| 23 | + |
| 24 | +# Quickstart |
| 25 | + |
| 26 | +## Create a gitpod-installer script |
| 27 | + |
| 28 | +```shell |
| 29 | +#!/bin/bash |
| 30 | + |
| 31 | +VERSION="${VERSION:-main.1844}" # Build ID taken from https://werft.gitpod-dev.com/ |
| 32 | + |
| 33 | +docker run -it --rm \ |
| 34 | + -v $PWD:/gitpod \ |
| 35 | + -v $HOME/.kube:/root/.kube \ |
| 36 | + eu.gcr.io/gitpod-core-dev/build/installer:${VERSION} \ |
| 37 | + $@ |
| 38 | +``` |
| 39 | + |
| 40 | +Save this in your `$PATH` as `gitpod-installer` and make executable |
| 41 | + |
| 42 | +## Generate the base config |
| 43 | + |
| 44 | +```shell |
| 45 | +gitpod-installer init > config.yaml |
| 46 | +``` |
| 47 | + |
| 48 | +## Validate |
| 49 | + |
| 50 | +```shell |
| 51 | +# Checks the validity of the configuration YAML |
| 52 | +gitpod-installer validate config --config /gitpod/config.yaml |
| 53 | + |
| 54 | +# Checks that your cluster is ready to install Gitpod |
| 55 | +gitpod-installer validate cluster --kubeconfig /root/.kube/config --config /gitpod/config.yaml |
| 56 | +``` |
| 57 | + |
| 58 | +Any errors here must be fixed before deploying. See [Cluster Dependencies](#cluster-dependencies) |
| 59 | +and [Config](#config) for more details. |
| 60 | + |
| 61 | +## Render the YAML |
| 62 | + |
| 63 | +```shell |
| 64 | +gitpod-installer render --config /gitpod/config.yaml > gitpod.yaml |
| 65 | +``` |
| 66 | + |
| 67 | +## Deploy |
| 68 | + |
| 69 | +```shell |
| 70 | +kubectl apply -f gitpod.yaml |
| 71 | +``` |
| 72 | + |
| 73 | +After a few minutes, your Gitpod installation will be available on the |
| 74 | +specified `domain`. |
| 75 | + |
| 76 | +# What is installed |
| 77 | + |
| 78 | +- All Gitpod components |
| 79 | +- Container registry* |
| 80 | +- MySQL database* |
| 81 | +- Jaeger operator* |
| 82 | +- RabbitMQ |
| 83 | +- Minio object storage* |
| 84 | + |
| 85 | +\* By default, these dependencies are installed if the `inCluster` setting |
| 86 | +is `true`. External dependencies can be used in their place |
| 87 | + |
| 88 | +# Config |
| 89 | + |
| 90 | +> Not every parameter is discussed in this table, just ones that are likely |
| 91 | +> to need changing. The full config structure is available in [config.go](/installer/pkg/config/v1/config.go). |
| 92 | +
|
| 93 | +| Property | Required | Description | Notes | |
| 94 | +| --- | --- | --- | --- | |
| 95 | +| `domain` | Y | The domain to deploy to | This will need to be changed on every deployment | |
| 96 | +| `kind` | Y | Installation type to run - for most users, this will be `Full` | Can be `Full`, `Meta` or `Workspace` | |
| 97 | +| `metadata.region` | Y | Location for your `objectStorage` provider | If using Minio, set to `local` | |
| 98 | +| `workspace.runtime.containerdRuntimeDir` | Y | The location of containerd on host machine | Common values are: <ul><li>`/run/containerd/io.containerd.runtime.v2.task/k8s.io` (K3s)</li><li>`/var/lib/containerd/io.containerd.runtime.v2.task/k8s.io` (AWS/GCP)</li><li>`/run/containerd/io.containerd.runtime.v1.linux/k8s.io` (Azure)</li><li>`/run/containerd/io.containerd.runtime.v1.linux/moby`</li></ul> | |
| 99 | +| `workspace.runtime.containerdSocket` | Y | The location of containerd socket on the host machine | |
| 100 | +| `workspace.runtime.fsShiftMethod` | Y | File system | Can be either `fuse` (fuse-overlayfs) or `shiftfs`. This depending upon your host OS/distribution. | |
| 101 | + |
| 102 | +## Auth Providers |
| 103 | + |
| 104 | +Gitpod must be connected to a Git provider. This can be done via the |
| 105 | +dashboard on first load, or by providing `authProviders` configuration. |
| 106 | + |
| 107 | +```yaml |
| 108 | +authProviders: |
| 109 | + - id: Public-GitHub |
| 110 | + host: github.com |
| 111 | + type: GitHub |
| 112 | + oauth: |
| 113 | + clientId: xxx |
| 114 | + clientSecret: xxx |
| 115 | + callBackUrl: https://$DOMAIN/auth/github.com/callback |
| 116 | + settingsUrl: xxx |
| 117 | +``` |
| 118 | +
|
| 119 | +## In-cluster vs External Dependencies |
| 120 | +
|
| 121 | +Gitpod requires certain services for it to function correctly. The Installer |
| 122 | +provides all of these in-cluster, but they can be configured to use services |
| 123 | +external to the cluster. |
| 124 | +
|
| 125 | +To use the in-cluster dependency, set `inCluster` to be `true`. |
| 126 | + |
| 127 | +## Container Registry |
| 128 | + |
| 129 | +```yaml |
| 130 | +containerRegistry: |
| 131 | + inCluster: false |
| 132 | + external: |
| 133 | + url: <url of registry> |
| 134 | + certificate: |
| 135 | + kind: secret |
| 136 | + name: container-registry-token |
| 137 | +``` |
| 138 | + |
| 139 | +The `container-registry-token` secret must contain a `.dockerconfigjson` |
| 140 | +key - this can be created by using the `kubectl create secret docker-registry` |
| 141 | +[command](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line). |
| 142 | + |
| 143 | +## Database |
| 144 | + |
| 145 | +Gitpod requires an instance of MySQL 5.7 for data storage. |
| 146 | + |
| 147 | +The default encryption keys are `[{"name":"general","version":1,"primary":true,"material":"4uGh1q8y2DYryJwrVMHs0kWXJlqvHWWt/KJuNi04edI="}]` |
| 148 | + |
| 149 | +### Google Cloud SQL Proxy |
| 150 | + |
| 151 | +If using a GCP SQL instance, a [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/sql-proxy) |
| 152 | +connection can be used. |
| 153 | + |
| 154 | +```yaml |
| 155 | +database: |
| 156 | + inCluster: false |
| 157 | + cloudSQL: |
| 158 | + instance: <PROJECT_ID>:<REGION>:<INSTANCE> |
| 159 | + serviceAccount: |
| 160 | + kind: secret |
| 161 | + name: cloudsql-token |
| 162 | +``` |
| 163 | + |
| 164 | +The `cloudsql-token` secret must contain the following key/value pairs: |
| 165 | + - `credentials.json` - GCP Service Account key with `roles/cloudsql.client` role |
| 166 | + - `encryptionKeys` - database encryption key. Use default value as above if unsure |
| 167 | + - `password` - database password |
| 168 | + - `username` - database username |
| 169 | + |
| 170 | +### External Database |
| 171 | + |
| 172 | +For all other connections, use an external database configuration. |
| 173 | + |
| 174 | +```yaml |
| 175 | +database: |
| 176 | + inCluster: false |
| 177 | + external: |
| 178 | + certificate: |
| 179 | + kind: secret |
| 180 | + name: database-token |
| 181 | +``` |
| 182 | + |
| 183 | +The `database-token` secret must contain the following key/value pairs: |
| 184 | +- `encryptionKeys` - database encryption key. Use default value as above if unsure |
| 185 | +- `host` - IP or URL of the database |
| 186 | +- `password` - database password |
| 187 | +- `port` - database port, usually `3306` |
| 188 | +- `username` - database username |
| 189 | + |
| 190 | +## Object Storage |
| 191 | + |
| 192 | +Gitpod supports the following object storage providers: |
| 193 | + |
| 194 | +### GCP |
| 195 | + |
| 196 | +```yaml |
| 197 | +objectStorage: |
| 198 | + inCluster: false |
| 199 | + cloudStorage: |
| 200 | + project: <PROJECT_ID> |
| 201 | + serviceAccount: |
| 202 | + kind: secret |
| 203 | + name: gcp-storage-token |
| 204 | +``` |
| 205 | + |
| 206 | +The `gcp-storage-token` secret must contain the following key/value pairs: |
| 207 | +- `service-account.json` - GCP Service Account key with `roles/storage.admin` and `roles/storage.objectAdmin` roles |
| 208 | + |
| 209 | +### Azure |
| 210 | + |
| 211 | +> Azure Blob Storage is not S3 compatible. This uses Minio Gateway to |
| 212 | +> provide an S3 interface |
| 213 | + |
| 214 | +```yaml |
| 215 | +objectStorage: |
| 216 | + inCluster: true |
| 217 | + azure: |
| 218 | + certificate: |
| 219 | + kind: secret |
| 220 | + name: az-storage-token |
| 221 | +``` |
| 222 | + |
| 223 | +The `az-storage-token` secret must contain the following key/value pairs: |
| 224 | +- `accountName` - the globally-unique storage account name |
| 225 | +- `accountKey` - access key for the storage account |
| 226 | + |
| 227 | +### S3 |
| 228 | + |
| 229 | +> Documentation coming soon [#6772](https://github.com/gitpod-io/gitpod/issues/6772) |
| 230 | + |
| 231 | +# Cluster Dependencies |
| 232 | + |
| 233 | +In order for the deployment to work successfully, there are certain |
| 234 | +dependencies that need to be installed. |
| 235 | + |
| 236 | +## Kernel and Runtime |
| 237 | + |
| 238 | +Your Kubernetes nodes must have the Linux kernel v5.4.0 or above and |
| 239 | +have a containerd runtime. |
| 240 | + |
| 241 | +## Affinity Labels |
| 242 | + |
| 243 | +Your Kubernetes nodes must have the following labels applied to them: |
| 244 | +- `gitpod.io/workload_meta` |
| 245 | +- `gitpod.io/workload_ide` |
| 246 | +- `gitpod.io/workload_workspace_services` |
| 247 | +- `gitpod.io/workload_workspace_regular` |
| 248 | +- `gitpod.io/workload_workspace_headless` |
| 249 | + |
| 250 | +It is recommended to have a minimum of two node pools, grouping the `meta` |
| 251 | +and `ide` nodes together and the `workspace` nodes together. |
| 252 | + |
| 253 | +## TLS certificates |
| 254 | + |
| 255 | +It is a requirement that a certificate secret exists, named as per |
| 256 | +`certificate.name` in your config YAML with `tls.crt` and `tls.key` |
| 257 | +in the secret data. How this certificate is generated is entirely your |
| 258 | +choice - we suggest [Cert Manager](https://cert-manager.io/) for |
| 259 | +simplicity, however any certificate authority can be used by creating a |
| 260 | +Kubernetes secret. |
| 261 | + |
| 262 | +The certificate must be associated with the following domains (where |
| 263 | +`$DOMAIN` is the value in config `domain`): |
| 264 | + - `$DOMAIN` |
| 265 | + - `*.$DOMAIN` |
| 266 | + - `*.ws.$DOMAIN` |
| 267 | + |
| 268 | +### Cert Manager |
| 269 | + |
| 270 | +Cert Manager **MUST** be installed to your cluster. In order to secure |
| 271 | +communication between the various components, the application creates |
| 272 | +internally which are created using the Cert Manager `Certificate` and |
| 273 | +`Issuer` Custom Resource Definitions. |
| 274 | + |
| 275 | +```shell |
| 276 | +helm repo add jetstack https://charts.jetstack.io |
| 277 | +helm repo update |
| 278 | +helm upgrade \ |
| 279 | + --atomic \ |
| 280 | + --cleanup-on-fail \ |
| 281 | + --create-namespace \ |
| 282 | + --install \ |
| 283 | + --namespace='cert-manager' \ |
| 284 | + --reset-values \ |
| 285 | + --set installCRDs=true \ |
| 286 | + --set 'extraArgs={--dns01-recursive-nameservers-only=true,--dns01-recursive-nameservers=8.8.8.8:53\,1.1.1.1:53}' \ |
| 287 | + --wait \ |
| 288 | + cert-manager \ |
| 289 | + jetstack/cert-manager |
| 290 | +``` |
| 291 | + |
| 292 | +# Todo |
| 293 | + |
| 294 | +PRs/comments welcome |
| 295 | + |
| 296 | +- [ ] [Improve distribution of gitpod-installer binaries](https://github.com/gitpod-io/gitpod/issues/6766) |
| 297 | +- [ ] [Configure and document S3 object storage](https://github.com/gitpod-io/gitpod/issues/6772) |
0 commit comments