Skip to content

Commit

Permalink
[installer]: initial commit
Browse files Browse the repository at this point in the history
This commit of the installer contains the converted Helm charts for the main Gitpod
application (in an unstable state)
  • Loading branch information
Simon Emms committed Oct 1, 2021
1 parent 4c331e9 commit 77965da
Show file tree
Hide file tree
Showing 121 changed files with 9,055 additions and 0 deletions.
16 changes: 16 additions & 0 deletions installer/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
packages:
- name: app
type: go
srcs:
- go.mod
- go.sum
- "**/*.go"
deps:
- components/common-go:lib
- components/ws-daemon:lib
- components/ws-manager-api/go:lib
- components/content-service:lib
env:
- CGO_ENABLED=0
config:
packaging: app
56 changes: 56 additions & 0 deletions installer/ToDo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ToDo
- [x] Integrate version manifest (@MrSimonEmms, @csweichel)
- Wrap up component templates (@MrSimonEmms)
- workspace
- [ ] ws-daemon
- [ ] ws-manager
- [ ] ws-proxy
- [ ] ws-scheduler
- [ ] registry-facade
- [ ] blobserve
- [ ] agent-smith
- [ ] docker-registry
- meta
- [ ] server
- [ ] ws-manager-bridge
- [ ] proxy
- [ ] dashboard
- [ ] image-builder-mk3
- [ ] content-service

- Integrate existing helm charts (@aledbf)
- [ ] mysql: db
- [ ] rabbitmq: messagebus
- [ ] jaeger
- [ ] minio

- Database
- [ ] Integrate DB initialization as Kubernetes job with log forwarding support
- [ ] Integrate DB migrations as a Kubernetes job with log forwarding support

- Check cluster pre-requisites
- [ ] Kubernetes version
- [ ] container runtime and version
- [ ] Kernel version
- [ ] database version and defaults for CloudSQL and RDS
- [ ] CNI provider (Calico with eBPF does not support host ports)

# Milestones
- [ ] Install either the GCP or EKS guide using the installer
- [ ] Produce a core-dev installation using the installer
- [ ] Produce a staging installation using the installer

## Dragons ahead

### Env vars removed from default env
- ws-daemon needs KUBE_STAGE
- integration tests need HOST_URL
- agent-smith needs GITPOD_REGION

### Deleting no longer needed objects
We maintain a list of all object kinds any version of the installer ever created.
All objects we ever create get a label so that we can identify them as created by the installer.
To delete unused objects we iterate over all objects using the obj kind list above and delete all objects the current installer version no longer produces.

### Storing the currently installed version of Gitpod
We could create a configMap and store the current Gitpod version in there.
38 changes: 38 additions & 0 deletions installer/cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package cmd

import (
"fmt"

config "github.com/gitpod-io/gitpod/installer/pkg/config/v1"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
)

// initCmd represents the init command
var initCmd = &cobra.Command{
Use: "init",
Short: "Create a base config file",
Long: `Create a base config file
This file contains all the credentials to install a Gitpod instance and
be saved to a repository.`,
Example: ` # Save config to config.yaml.
gitpod-installer init > config.yaml`,
Run: func(cmd *cobra.Command, args []string) {
var cfg config.Config
fc, err := yaml.Marshal(cfg)
if err != nil {
panic(err)
}

fmt.Print(string(fc))
},
}

func init() {
rootCmd.AddCommand(initCmd)
}
97 changes: 97 additions & 0 deletions installer/cmd/render.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package cmd

import (
"fmt"
"os"

_ "embed"

"github.com/gitpod-io/gitpod/installer/pkg/common"
"github.com/gitpod-io/gitpod/installer/pkg/components"
config "github.com/gitpod-io/gitpod/installer/pkg/config/v1"
"github.com/gitpod-io/gitpod/installer/pkg/config/versions"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
)

var renderOpts struct {
ConfigFN string
Namespace string
}

//go:embed versions.yaml
var versionManifest []byte

// renderCmd represents the render command
var renderCmd = &cobra.Command{
Use: "render",
Short: "Renders the Kubernetes manifests required to install Gitpod",
Long: `Renders the Kubernetes manifests required to install Gitpod
A config file is required which can be generated with the init command.`,
Example: ` # Default install.
gitpod-installer render --config config.yaml | kubectl apply -f -
# Install Gitpod into a non-default namespace.
gitpod-installer render --config config.yaml --namespace gitpod | kubectl apply -f -`,
RunE: func(cmd *cobra.Command, args []string) error {
cfgFN, _ := cmd.PersistentFlags().GetString("config")
cfg, err := config.Load(cfgFN)
if err != nil {
return fmt.Errorf("error loading config: %w", err)
}

var versionMF versions.Manifest
err = yaml.Unmarshal(versionManifest, &versionMF)
if err != nil {
return err
}

namespace, _ := cmd.PersistentFlags().GetString("namespace")

ctx := &common.RenderContext{
Config: *cfg,
VersionManifest: versionMF,
Namespace: namespace,
}

var renderable common.RenderFunc
switch cfg.Kind {
case config.InstallationFull:
renderable = components.FullObjects
case config.InstallationMeta:
renderable = components.MetaObjects
case config.InstallationWorkspace:
renderable = components.WorkspaceObjects
default:
return fmt.Errorf("unsupported installation kind: %s", cfg.Kind)
}

objs, err := renderable(ctx)
if err != nil {
return err
}

for _, o := range objs {
fc, err := yaml.Marshal(o)
if err != nil {
return err
}

fmt.Printf("---\n%s\n", string(fc))
}

return nil
},
}

func init() {
rootCmd.AddCommand(renderCmd)

renderCmd.PersistentFlags().StringVarP(&renderOpts.ConfigFN, "config", "c", os.Getenv("GITPOD_INSTALLER_CONFIG"), "path to the config file")
renderCmd.PersistentFlags().StringVarP(&renderOpts.Namespace, "namespace", "n", "default", "namespace to deploy to")
}
23 changes: 23 additions & 0 deletions installer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package cmd

import (
"github.com/spf13/cobra"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "gitpod-installer",
Short: "Installs Gitpod",
}

func Execute() {
cobra.CheckErr(rootCmd.Execute())
}

func init() {
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
88 changes: 88 additions & 0 deletions installer/cmd/versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
version: not-a-valid-version
components:
agentSmith:
version: not-a-valid-version

blobserve:
version: not-a-valid-version

contentService:
version: not-a-valid-version

dashboard:
version: not-a-valid-version

dbMigrations:
version: not-a-valid-version

dbSync:
version: not-a-valid-version

imageBuilder:
version: not-a-valid-version

imageBuilderMk3:
builderImage:
version: not-a-valid-version

version: not-a-valid-version

integrationTest:
version: not-a-valid-version

kedge:
version: not-a-valid-version

paymentEndpoint:
version: not-a-valid-version

proxy:
version: not-a-valid-version

registryFacade:
version: not-a-valid-version

server:
version: not-a-valid-version

serviceWaiter:
version: not-a-valid-version

workspace:
codeImage:
version: not-a-valid-version

codeImageStable:
version: not-a-valid-version

dockerUp:
version: not-a-valid-version

supervisor:
version: not-a-valid-version

theiaImage:
version: not-a-valid-version

wsDaemon:
userNamespaces:
seccompProfileInstaller:
version: not-a-valid-version

shiftfsModuleLoader:
version: not-a-valid-version

version: not-a-valid-version

wsManager:
version: not-a-valid-version

wsManagerBridge:
version: not-a-valid-version

wsProxy:
version: not-a-valid-version

wsScheduler:
version: not-a-valid-version

53 changes: 53 additions & 0 deletions installer/example-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
analytics: null
authProviders: null
blockNewUsers:
enabled: false
passlist: null
certificate:
kind: ""
name: ""
containerRegistry:
external: null
inCluster: null
database:
cloudSQL: null
rds: null
domain: "gitpod.io"
imagePullSecrets: null
installNetworkPolicies: false
kind: Full
messageBus: { }
metadata:
region: "eu-west1"
objectStorage:
cloudStorage:
certificate:
name: "gcp-sa"
s3: null
observability:
logLevel: ""
tracing: null
repository: "eu.gcr.io/gitpod-core-dev/build/"
workspace:
resources:
DynamicLimits:
CPU: null
Limits:
CPU: ""
EphemeralStorage: ""
Memory: ""
Storage: ""
Requests:
CPU: ""
EphemeralStorage: ""
Memory: ""
Storage: ""
runtime:
containerdRuntimeDir: ""
fsShiftMethod: "fuse"
templates:
default: null
ghost: null
image_build: null
prebuild: null
regular: null
Loading

0 comments on commit 77965da

Please sign in to comment.