Skip to content

Commit 709aed3

Browse files
committed
1
1 parent b8d201e commit 709aed3

File tree

14 files changed

+1086
-19
lines changed

14 files changed

+1086
-19
lines changed

components/registry-facade/cmd/setup.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616
)
1717

1818
var (
19-
hostname string
20-
hostfs string
21-
port int
19+
hostname string
20+
hostfs string
21+
port int
22+
containerdConfigDir string
2223
)
2324

2425
var setupCmd = &cobra.Command{
@@ -27,9 +28,9 @@ var setupCmd = &cobra.Command{
2728
Run: func(cmd *cobra.Command, args []string) {
2829
{
2930
log.Info("Creating containerd registry directory...")
30-
regDirectory := fmt.Sprintf("/etc/containerd/certs.d/%v:%v", hostname, port)
31+
regDirectory := fmt.Sprintf("/certs.d/%v:%v", hostname, port)
3132

32-
fakeRegPath := filepath.Join(hostfs, regDirectory)
33+
fakeRegPath := filepath.Join(hostfs, containerdConfigDir, regDirectory)
3334
err := os.MkdirAll(fakeRegPath, 0644)
3435
if err != nil {
3536
log.Fatalf("cannot create containerd cert directory: %v", err)
@@ -51,7 +52,7 @@ server = "https://%v:%v"
5152
ca = "%v"
5253
# skip verifications of the registry's certificate chain and host name when set to true
5354
#skip_verify = true
54-
`, hostname, port, hostname, port, filepath.Join(regDirectory, "ca.crt"))
55+
`, hostname, port, hostname, port, filepath.Join(containerdConfigDir, regDirectory, "ca.crt"))
5556

5657
err = os.WriteFile(filepath.Join(fakeRegPath, "hosts.toml"), []byte(hostsToml), 0644)
5758
if err != nil {
@@ -78,6 +79,7 @@ func init() {
7879
setupCmd.Flags().StringVar(&hostname, "hostname", "", "registry facade host <hostname:port>")
7980
setupCmd.Flags().StringVar(&hostfs, "hostfs", "", "Mount point path for the root filesystem")
8081
setupCmd.Flags().IntVar(&port, "port", 31750, "Listening port for the new registry hostname")
82+
setupCmd.Flags().StringVar(&containerdConfigDir, "containerd-config-dir", "/etc/containerd", "Containerd configuration directory")
8183

8284
_ = setupCmd.MarkFlagRequired("hostname")
8385
_ = setupCmd.MarkFlagRequired("hostfs")

dev/preview/infrastructure/preview.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "preview_gce" {
2-
count = 1
2+
count = 0
33
source = "./modules/gce"
44

55
preview_name = var.preview_name
@@ -21,9 +21,9 @@ module "dns" {
2121
preview_name = var.preview_name
2222

2323
# a bit of a hack to choose the correct ip for the dns records, based on whichever module gets created
24-
preview_ip = module.preview_gce[0].preview_ip
24+
preview_ip = "127.0.0.1"
2525

26-
workspace_ip = module.preview_gce[0].workspace_ip
26+
workspace_ip = "127.0.0.1"
2727

2828
cert_issuer = var.cert_issuer
2929
gcp_project_dns = var.gcp_project_dns

dev/preview/workflow/preview/deploy-gitpod.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,18 @@ if ! command -v installer;then
6666
fi
6767

6868
function copyCachedCertificate {
69+
PREVIEW_SORUCE_CERT_NAME="certificate-local"
70+
71+
GITPOD_PROXY_SECRET_NAME="proxy-config-certificates";
72+
PREVIEW_GCP_PROJECT="gitpod-dev-preview"
6973
DESTINATION_CERT_NAME="$GITPOD_PROXY_SECRET_NAME"
74+
PREVIEW_NAMESPACE=default
7075

7176
secret=$(gcloud secrets versions access latest --secret="${PREVIEW_SORUCE_CERT_NAME}" --project=${PREVIEW_GCP_PROJECT})
7277
kubectl \
7378
create secret generic "${DESTINATION_CERT_NAME}" --namespace="${PREVIEW_NAMESPACE}" --dry-run=client -oyaml \
7479
| yq4 eval-all ".data = $secret | .type = \"kubernetes.io/tls\"" \
7580
| kubectl \
76-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
77-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
7881
apply -f -
7982
}
8083

@@ -244,6 +247,9 @@ yq w -i "${INSTALLER_CONFIG_PATH}" experimental.ide.ideMetrics.enabledErrorRepor
244247

245248
if [[ "${GITPOD_WITH_DEDICATED_EMU}" != "true" ]]
246249
then
250+
PREVIEW_GCP_PROJECT="gitpod-dev-preview"
251+
PREVIEW_NAMESPACE="default"
252+
DOMAIN="local.preview.gitpod-dev.com"
247253
secret=$(gcloud secrets versions access latest --secret="preview-envs-authproviders" --project=${PREVIEW_GCP_PROJECT})
248254
for row in $(gcloud secrets versions access latest --secret="preview-envs-authproviders" --project=${PREVIEW_GCP_PROJECT} | yq r - "authProviders" \
249255
| base64 -d -w 0 \
@@ -260,11 +266,9 @@ then
260266

261267
kubectl create secret generic "$providerId" \
262268
--namespace "${PREVIEW_NAMESPACE}" \
263-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
264-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
265269
--from-literal=provider="$data" \
266270
--dry-run=client -o yaml | \
267-
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" replace --force -f -
271+
kubectl replace --force -f -
268272
done
269273
fi
270274

@@ -355,6 +359,7 @@ yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.stripe.teamUsagePriceIds[
355359
# configureConfigCat
356360
#
357361
# This key is not a secret, it is a unique identifier of our ConfigCat application
362+
export INSTALLER_CONFIG_PATH="/workspace/gitpod/gitpod.config.yaml"
358363
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.configcatKey "WBLaCPtkjkqKHlHedziE9g/LEAOCNkbuUKiqUZAcVg7dw"
359364
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.proxy.configcat.baseUrl "https://cdn-global.configcat.com"
360365
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.proxy.configcat.pollInterval "1m"
@@ -425,13 +430,13 @@ yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.spicedb.secretRef "spiced
425430
#
426431
# Configure spicedb secret
427432
#
433+
export PREVIEW_GCP_PROJECT="gitpod-dev-preview"
434+
export PREVIEW_NAMESPACE="default"
428435
secret=$(gcloud secrets versions access latest --secret="spicedb-secret" --project=${PREVIEW_GCP_PROJECT})
429436
kubectl \
430437
create secret generic "spicedb-secret" --namespace="${PREVIEW_NAMESPACE}" --dry-run=client -oyaml \
431438
| yq4 eval-all ".data = $secret" \
432439
| kubectl \
433-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
434-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
435440
apply -n ${PREVIEW_NAMESPACE} -f -
436441

437442
#

install/installer/pkg/components/registry-facade/daemonset.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
8989
}
9090

9191
var envvars []corev1.EnvVar
92+
containerdConfigDir := "/etc/containerd"
9293
err = ctx.WithExperimental(func(ucfg *experimental.Config) error {
9394
if ucfg.Workspace == nil {
9495
return nil
@@ -127,6 +128,9 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
127128
}
128129
}
129130

131+
if ucfg.Workspace.RegistryFacade.ContainerdConfigDir != "" {
132+
containerdConfigDir = ucfg.Workspace.RegistryFacade.ContainerdConfigDir
133+
}
130134
return nil
131135
})
132136
if err != nil {
@@ -142,6 +146,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
142146
"--hostfs=/mnt/dst",
143147
fmt.Sprintf("--hostname=reg.%s", ctx.Config.Domain),
144148
fmt.Sprintf("--port=%v", ServicePort),
149+
fmt.Sprintf("--containerd-config-dir=%s", containerdConfigDir),
145150
},
146151
SecurityContext: &corev1.SecurityContext{RunAsUser: pointer.Int64(0)},
147152
VolumeMounts: []corev1.VolumeMount{

install/installer/pkg/components/spicedb/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
141141
},
142142
Resources: common.ResourceRequirements(ctx, Component, ContainerName, corev1.ResourceRequirements{
143143
Requests: corev1.ResourceList{
144-
"cpu": resource.MustParse("1"),
144+
"cpu": resource.MustParse("10m"),
145145
"memory": resource.MustParse("500M"),
146146
},
147147
}),

install/installer/pkg/components/ws-daemon/daemonset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
231231
common.NodeNameEnv(ctx),
232232
)),
233233
Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{Requests: corev1.ResourceList{
234-
"cpu": resource.MustParse("500m"),
235-
"memory": resource.MustParse("4Gi"),
234+
"cpu": resource.MustParse("50m"),
235+
"memory": resource.MustParse("2Gi"),
236236
}}),
237237
VolumeMounts: volumeMounts,
238238
ImagePullPolicy: corev1.PullIfNotPresent,

install/installer/pkg/config/v1/experimental/experimental.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ type WorkspaceConfig struct {
9999
UseTLS bool `json:"useTLS"`
100100
InsecureSkipVerify bool `json:"insecureSkipVerify"`
101101
} `json:"redisCache"`
102+
ContainerdConfigDir string `json:"containerdConfigDir"`
102103
} `json:"registryFacade"`
103104

104105
WSDaemon struct {

local-preview/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# one time setup
2+
3+
## download k3d
4+
```bash
5+
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
6+
```
7+
8+
## create cluster
9+
10+
```bash
11+
k3d cluster create -c ./local-preview/k3d.yaml
12+
```
13+
14+
## install prereqs
15+
16+
```bash
17+
TF_VAR_preview_name=local leeway run dev/preview:create-preview
18+
cd ./local-preview/
19+
./setup.sh
20+
```
21+
22+
23+
# for dev loop
24+
25+
run `kubectl port-forward svc/proxy 8443:443` in your terminal
26+
27+
```bash
28+
cd ./local-preview/
29+
./update.sh
30+
```
31+
32+
33+
# mac local portforward setup
34+
35+
```bash
36+
echo "rdr pass on lo0 inet proto tcp from any to self port 443 -> 127.0.0.1 port 8443" | sudo tee /etc/pf.anchors/gitpod
37+
38+
sudo vi /etc/pf.conf
39+
40+
## manual add something
41+
# add `rdr-anchor "gitpod"` below `rdr-anchor "com.apple/*"`
42+
# add `load anchor "gitpod" from "/etc/pf.anchors/gitpod"` below `load anchor "com.apple" from "/etc/pf.anchors/com.apple"`
43+
44+
# config should looks like
45+
#
46+
# ....
47+
# rdr-anchor "com.apple/*"
48+
# rdr-anchor "gitpod"
49+
# ...
50+
# load anchor "com.apple" from "/etc/pf.anchors/com.apple"
51+
# load anchor "gitpod" from "/etc/pf.anchors/gitpod"
52+
53+
# apply changes
54+
sudo pfctl -ef /etc/pf.conf
55+
```
56+
57+
58+
you can view preview env at https://local.preview.gitpod-dev.com

local-preview/coredns-custom.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: coredns-custom
5+
namespace: kube-system
6+
data:
7+
rewrite.override: |
8+
rewrite name registry.local.preview.gitpod-dev.com proxy.default.svc.cluster.local

local-preview/gitpod.config.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apiVersion: v1
2+
authProviders:
3+
- kind: secret
4+
name: public-github
5+
- kind: secret
6+
name: public-gitlab
7+
- kind: secret
8+
name: public-bitbucket
9+
blockNewUsers:
10+
enabled: true
11+
passlist:
12+
- gitpod.io
13+
certificate:
14+
kind: secret
15+
name: proxy-config-certificates
16+
containerRegistry:
17+
enableAdditionalECRAuth: false
18+
inCluster: true
19+
privateBaseImageAllowList: []
20+
subassemblyBucket: ""
21+
database:
22+
inCluster: true
23+
disableDefinitelyGp: true
24+
domain: "local.preview.gitpod-dev.com"
25+
kind: Full
26+
metadata:
27+
region: local
28+
shortname: default
29+
objectStorage:
30+
inCluster: true
31+
resources:
32+
requests:
33+
memory: 2Gi
34+
observability:
35+
logLevel: info
36+
openVSX:
37+
url: https://open-vsx.org
38+
workspace:
39+
maxLifetime: 36h0m0s
40+
resources:
41+
requests:
42+
cpu: "1"
43+
memory: 2Gi
44+
runtime:
45+
containerdRuntimeDir: /var/lib/rancher/k3s/agent/containerd/io.containerd.runtime.v2.task/k8s.io
46+
containerdSocketDir: /run/k3s/containerd
47+
fsShiftMethod: shiftfs
48+
experimental:
49+
webapp:
50+
spicedb:
51+
enabled: true
52+
secretRef: spicedb-secret
53+
configcatKey: WBLaCPtkjkqKHlHedziE9g/LEAOCNkbuUKiqUZAcVg7dw
54+
proxy:
55+
configcat:
56+
baseUrl: https://cdn-global.configcat.com
57+
pollInterval: 1m
58+
workspace:
59+
registryFacade:
60+
containerdConfigDir: /var/lib/rancher/k3s/agent/etc/containerd

0 commit comments

Comments
 (0)