-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement injecting ssh key and password to init container * adjust git init script to work with any user id
- Loading branch information
1 parent
6d368df
commit c547548
Showing
9 changed files
with
137 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,8 @@ docker run --env GIT_PROMPT1=$SSH_PASSWORD -v ~/tmp/ssh/:/etc/theia-cloud-ssh -- | |
|
||
### Create Kubernetes Resources | ||
|
||
#### Secret for HTTP(S) auth | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Secret | ||
|
@@ -74,6 +76,8 @@ stringData: | |
password: pat | ||
``` | ||
#### Example Session for HTTP(S) auth | ||
```yaml | ||
apiVersion: theia.cloud/v5beta | ||
kind: Session | ||
|
@@ -96,3 +100,48 @@ spec: | |
- maintenance_1_1_x | ||
- foo-theiacloud-io-basic-auth | ||
``` | ||
#### Secrets for SSH auth | ||
```yaml | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: foo-theiacloud-io-ssh-auth | ||
namespace: theiacloud | ||
labels: | ||
theiaCloudInit: git | ||
annotations: | ||
theiaCloudUser: [email protected] | ||
type: kubernetes.io/ssh-auth | ||
stringData: | ||
ssh-privatekey: | | ||
-----BEGIN OPENSSH PRIVATE KEY----- | ||
b3B... | ||
password: sshpw | ||
``` | ||
#### Example Session for SSH auth | ||
```yaml | ||
apiVersion: theia.cloud/v5beta | ||
kind: Session | ||
metadata: | ||
name: ws-asdfghjkl-theia-cloud-demo-foo-theia-cloud-io-session | ||
namespace: theiacloud | ||
spec: | ||
appDefinition: theia-cloud-demo | ||
envVars: {} | ||
envVarsFromConfigMaps: [] | ||
envVarsFromSecrets: [] | ||
name: ws-asdfghjkl-theia-cloud-demo-foo-theia-cloud-io-session | ||
user: [email protected] | ||
workspace: ws-asdfghjkl-theia-cloud-demo-foo-theia-cloud-io | ||
sessionSecret: 3e68605f-0c6d-4ae5-9816-738f15d34fc9 | ||
initOperations: | ||
- id: git | ||
arguments: | ||
- [email protected]:username/my.repository.git | ||
- maintenance_1_1_x | ||
- foo-theiacloud-io-ssh-auth | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
#!/bin/bash | ||
USERID=$(id -u) | ||
|
||
if id "$USERID" &>/dev/null; then | ||
echo 'Existing user' | ||
else | ||
echo 'Setup user for id' | ||
# add an entry to /etc/passwd for the user | ||
echo user:x:$USERID:$USERID:user:/user:/bin/bash >> /etc/passwd | ||
export HOME=/user | ||
fi | ||
|
||
# start SSH agent | ||
eval `ssh-agent` | ||
mkdir $HOME/.ssh | ||
|
||
# prepare required directories and import ssh key, if available | ||
mkdir -p $HOME/.ssh | ||
touch $HOME/.ssh/known_hosts | ||
[ -e /etc/theia-cloud-ssh/id_theiacloud ] && { sleep 1; echo $GIT_PROMPT1; } | script -q /dev/null -c 'ssh-add /etc/theia-cloud-ssh/id_theiacloud' | ||
|
||
# hand over to clone script | ||
python git-init.py "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
ssh-keyscan -H $@ >> /root/.ssh/known_hosts | ||
ssh-keyscan -H $@ >> $HOME/.ssh/known_hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters