Skip to content

Commit d38a64d

Browse files
committed
Add SSH Gateway to ws-proxy
1 parent f1c0b8f commit d38a64d

File tree

27 files changed

+2216
-47
lines changed

27 files changed

+2216
-47
lines changed

.werft/build.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,21 @@ export async function deployToDevWithInstaller(deploymentConfig: DeploymentConfi
502502
werft.fail('authProviders', err);
503503
}
504504

505+
werft.log("SSH gateway hostkey", "copy host-key from secret")
506+
try {
507+
exec(`kubectl --namespace keys get secret host-key -o yaml \
508+
| yq w - metadata.namespace ${namespace} \
509+
| yq d - metadata.uid \
510+
| yq d - metadata.resourceVersion \
511+
| yq d - metadata.creationTimestamp \
512+
| kubectl apply -f -`, { silent: true })
513+
exec(`yq w -i ./config.yaml sshGatewayHostKey.kind "secret"`)
514+
exec(`yq w -i ./config.yaml sshGatewayHostKey.name "host-key"`)
515+
werft.done('SSH gateway hostkey');
516+
} catch (err) {
517+
werft.fail('SSH gateway hostkey', err);
518+
}
519+
505520
// validate the config and cluster
506521
exec(`/tmp/installer validate config -c config.yaml`, {slice: installerSlices.INSTALLER_RENDER});
507522

.werft/post-process.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ while [ "$i" -le "$DOCS" ]; do
213213
yq m -x -i k8s.yaml -d "$i" /tmp/"$NAME"overrides.yaml
214214
fi
215215

216+
if [[ "ws-proxy" == "$NAME" ]] && [[ "$KIND" == "Service" ]]; then
217+
WORK="overrides for $NAME $KIND"
218+
echo "$WORK"
219+
yq w -i k8s.yaml -d "$i" "metadata.annotations[cloud.google.com/neg]" '{"exposed_ports": {"22":{}}}'
220+
yq w -i k8s.yaml -d "$i" spec.type LoadBalancer
221+
fi
222+
216223
# update workspace-templates configmap to set affinity for workspace, ghosts, image builders, etc.
217224
# if this is not done, and they start on a node other than workspace, they won't be able to talk to registry-facade or ws-daemon
218225
if [[ "workspace-templates" == "$NAME" ]] && [[ "$KIND" == "ConfigMap" ]]; then

chart/templates/ws-proxy-deployment.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ spec:
5151
- name: config-certificates
5252
secret:
5353
secretName: {{ $.Values.certificatesSecret.secretName }}
54+
{{- end }}
55+
{{- if $.comp.hostKeySecretName }}
56+
- name: host-key
57+
secret:
58+
secretName: {{ $.comp.hostKeySecretName }}
5459
{{- end }}
5560
enableServiceLinks: false
5661
containers:
@@ -84,6 +89,10 @@ spec:
8489
{{- if $.Values.certificatesSecret.secretName }}
8590
- name: config-certificates
8691
mountPath: "/mnt/certificates"
92+
{{- end }}
93+
{{- if $.comp.hostKeySecretName }}
94+
- name: host-key
95+
mountPath: "/mnt/host-key"
8796
{{- end }}
8897
securityContext:
8998
privileged: false

chart/templates/ws-proxy-networkpolicy.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ spec:
2020
policyTypes:
2121
- Ingress
2222
ingress:
23-
# Allow access to HTTP/HTTPS proxy ports from everywhere
23+
# Allow access to HTTP/HTTPS/SSH proxy ports from everywhere
2424
- ports:
2525
- protocol: TCP
2626
port: {{ $comp.ports.httpProxy.containerPort }}
2727
- protocol: TCP
2828
port: {{ $comp.ports.httpsProxy.containerPort }}
29+
- protocol: TCP
30+
port: {{ $comp.ports.ssh.containerPort }}
2931
{{ end }}

chart/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ components:
563563
memory: 64Mi
564564
replicas: 1
565565
hostHeader: "x-wsproxy-host"
566+
# hostKeySecretName: "host-key"
566567
ports:
567568
httpProxy:
568569
expose: true
@@ -573,6 +574,10 @@ components:
573574
metrics:
574575
expose: false
575576
containerPort: 9500
577+
ssh:
578+
expose: false
579+
containerPort: 2200
580+
servicePort: 22
576581

577582
docker-registry:
578583
enabled: true

components/supervisor-api/control.proto

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ service ControlService {
1414

1515
// ExposePort exposes a port
1616
rpc ExposePort(ExposePortRequest) returns (ExposePortResponse) {}
17+
18+
// CreateSSHKeyPair Create a pair of SSH Keys and put them in ~/.ssh/authorized_keys, this will only be generated once in the entire workspace lifecycle
19+
rpc CreateSSHKeyPair(CreateSSHKeyPairRequest) returns (CreateSSHKeyPairResponse) {}
1720
}
1821

1922
message ExposePortRequest {
@@ -22,4 +25,10 @@ message ExposePortRequest {
2225
// external port if missing the the same as port
2326
reserved 2;
2427
}
25-
message ExposePortResponse {}
28+
message ExposePortResponse {}
29+
30+
message CreateSSHKeyPairRequest {}
31+
message CreateSSHKeyPairResponse {
32+
// Return privateKey for ws-proxy
33+
string private_key = 1;
34+
}

components/supervisor-api/go/control.pb.go

Lines changed: 144 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)