-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple fs authorize azure cli with service-principal
- Loading branch information
Showing
3 changed files
with
233 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{% raw %}{% include './common.j2' %}{% endraw %} | ||
fs: | ||
# root | ||
"/": | ||
readdir: | ||
sh: ls /accounts | ||
getattr: | ||
sh: *dir | ||
# /<id> | ||
"/[0-9]+": | ||
name: id | ||
readdir: | ||
list: | ||
- vm | ||
getattr: | ||
sh: *dir | ||
# /<id>/.init.lua | ||
"/.init.lua": | ||
getattr: | ||
sh: *file | ||
read_file: | ||
sh: | | ||
cat <<EOF | ||
{% filter indent(15, first=True) -%} | ||
{% include '.init.lua'%} | ||
{%- endfilter %} | ||
EOF | ||
|
||
# /<id>/vm | ||
"/vm": | ||
readdir: | ||
list: | ||
- list | ||
getattr: | ||
sh: *dir | ||
# /<id>/vm/list | ||
"/list": | ||
cache: 360 | ||
readdir: | ||
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r '.[].name' | ||
getattr: | ||
sh: *dir | ||
# /<id>/vm/list/<instance> | ||
"/[a-z0-9_-]+": | ||
name: instancename | ||
getattr: | ||
sh: *dir | ||
readdir: | ||
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\")" | jq -r "keys[]" | ||
# /<id>/vm/list/<instance>/<parameter> | ||
"/[a-zA-Z0-9_-]+": | ||
name: parameter | ||
getattr: | ||
sh: *file | ||
read_file: | ||
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\") .\"$parameter\"" |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
image: | ||
repository: 9mine/9mine-azure-cloud-fs | ||
tag: "main" | ||
pullPolicy: Always | ||
|
||
initContainerImage: | ||
repository: 9mine/execfuse-jinja2 | ||
tag: "master" | ||
pullPolicy: Always | ||
|
||
securityContext: | ||
privileged: true | ||
capabilities: | ||
add: | ||
- SYS_ADMIN | ||
|
||
service: | ||
type: ClusterIP | ||
port: 3900 | ||
|
||
ClusterIPRange: | ||
from: 3901 | ||
to: 3920 | ||
|
||
description: "azurecloudfs" | ||
|
||
fs: | | ||
{% filter indent() -%}{% include 'fs.yml'%} | ||
{%- endfilter %} | ||
profile: | | ||
echo --- start of profile loading --- | ||
load file2chan | ||
load std | ||
ndb/cs | ||
for host_var in `{ os env } { '{'$host_var'}' } | ||
dir = $EXPORT_PATH | ||
port = $NINEP_PUBLIC_PORT | ||
echo $NINEP_PUBLIC_HOST > /dev/sysname | ||
test -d /mnt/registry || mkdir -p /mnt/registry | ||
mount -A tcp!registry!registry /mnt/registry | ||
AWS_DIR = /tmp/aws/cmd | ||
test -d $AWS_DIR || mkdir -p $AWS_DIR | ||
load mpexpr | ||
fs_port = ${expr $NINEP_PUBLIC_PORT 1 +} | ||
file2chan $AWS_DIR^/aws {} { | ||
load mpexpr | ||
var=${expr 10 rand} | ||
echo new id is $var | ||
echo hostname is `{os hostname} | ||
(app_id password tenant) = `{echo ${rget data}} | ||
`{os /bin/bash -c 'mkdir -p /accounts/'^$var} | ||
`{os /bin/bash -c 'export AZURE_CONFIG_DIR=/accounts/'^$var^'/credentials && az login --service-principal -u '^$app_id^' -p '^$password^' --tenant '^$tenant^''} | ||
grid/reglisten -A -r description 'user id is '^$var tcp!*!^$fs_port { export $dir^/^$var & } & | ||
fs_port=${expr $fs_port 1 +} | ||
} | ||
grid/reglisten -A -r description ${quote $NINEP_DESCRIPTION} 'tcp!*!'^$port { export $AWS_DIR & } | ||
test -n $status && os pkill -9 emu-g | ||
echo --- end of profile loading --- |
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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
image: | ||
repository: 9mine/9mine-azure-cloud-fs | ||
tag: "main" | ||
pullPolicy: Always | ||
|
||
initContainerImage: | ||
repository: 9mine/execfuse-jinja2 | ||
tag: "master" | ||
pullPolicy: Always | ||
|
||
securityContext: | ||
privileged: true | ||
capabilities: | ||
add: | ||
- SYS_ADMIN | ||
|
||
service: | ||
type: ClusterIP | ||
port: 3900 | ||
|
||
ClusterIPRange: | ||
from: 3901 | ||
to: 3920 | ||
|
||
description: "azurecloudfs" | ||
|
||
fs: | | ||
{% include './common.j2' %} | ||
fs: | ||
# root | ||
"/": | ||
readdir: | ||
sh: ls /accounts | ||
getattr: | ||
sh: *dir | ||
# /<id> | ||
"/[0-9]+": | ||
name: id | ||
readdir: | ||
list: | ||
- vm | ||
getattr: | ||
sh: *dir | ||
# /<id>/.init.lua | ||
"/.init.lua": | ||
getattr: | ||
sh: *file | ||
read_file: | ||
sh: | | ||
cat <<EOF | ||
print("dump") | ||
EOF | ||
# /<id>/vm | ||
"/vm": | ||
readdir: | ||
list: | ||
- list | ||
getattr: | ||
sh: *dir | ||
# /<id>/vm/list | ||
"/list": | ||
cache: 360 | ||
readdir: | ||
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r '.[].name' | ||
getattr: | ||
sh: *dir | ||
# /<id>/vm/list/<instance> | ||
"/[a-z0-9_-]+": | ||
name: instancename | ||
getattr: | ||
sh: *dir | ||
readdir: | ||
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\")" | jq -r "keys[]" | ||
# /<id>/vm/list/<instance>/<parameter> | ||
"/[a-zA-Z0-9_-]+": | ||
name: parameter | ||
getattr: | ||
sh: *file | ||
read_file: | ||
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\") .\"$parameter\"" | ||
profile: | | ||
echo --- start of profile loading --- | ||
load file2chan | ||
load std | ||
ndb/cs | ||
for host_var in `{ os env } { '{'$host_var'}' } | ||
dir = $EXPORT_PATH | ||
port = $NINEP_PUBLIC_PORT | ||
echo $NINEP_PUBLIC_HOST > /dev/sysname | ||
test -d /mnt/registry || mkdir -p /mnt/registry | ||
mount -A tcp!registry!registry /mnt/registry | ||
AWS_DIR = /tmp/aws/cmd | ||
test -d $AWS_DIR || mkdir -p $AWS_DIR | ||
load mpexpr | ||
fs_port = ${expr $NINEP_PUBLIC_PORT 1 +} | ||
file2chan $AWS_DIR^/aws {} { | ||
load mpexpr | ||
var=${expr 10 rand} | ||
echo new id is $var | ||
echo hostname is `{os hostname} | ||
(app_id password tenant) = `{echo ${rget data}} | ||
`{os /bin/bash -c 'mkdir -p /accounts/'^$var} | ||
`{os /bin/bash -c 'export AZURE_CONFIG_DIR=/accounts/'^$var^'/credentials && az login --service-principal -u '^$app_id^' -p '^$password^' --tenant '^$tenant^''} | ||
grid/reglisten -A -r description 'user id is '^$var tcp!*!^$fs_port { export $dir^/^$var & } & | ||
fs_port=${expr $fs_port 1 +} | ||
} | ||
grid/reglisten -A -r description ${quote $NINEP_DESCRIPTION} 'tcp!*!'^$port { export $AWS_DIR & } | ||
test -n $status && os pkill -9 emu-g | ||
echo --- end of profile loading --- |