-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcloud-init.yaml
54 lines (53 loc) · 1.91 KB
/
cloud-init.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#cloud-config
apt_update: true
apt_upgrade: true
users:
- name: ubuntu
uid: 1000
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
runcmd:
- |
# install k3s, direnv, task
curl -sfL https://get.k3s.io | sh -
curl -sfL https://direnv.net/install.sh | bash
snap install task --classic
cd /tmp
curl https://dlcdn.apache.org/skywalking/eyes/0.6.0/skywalking-license-eye-0.6.0-bin.tgz | tar xzvf -
mv skywalking-license-eye-0.6.0-bin/bin/linux/license-eye /usr/bin/license-eye
rm -Rvf skywalking-license-eye-0.6.0-bin
echo "OPS_CLOUD_INIT_VER=2" >>/etc/environment
- |
# set home and user
USR="$(getent passwd 1000 | awk -F: '{print $1}')"
HOME="/home/$USR"
# copy authkey if there is a root one
if test -e /root/.ssh/authorized_keys
then mkdir -p /home/$USR/.ssh
cat /root/.ssh/authorized_keys >>/home/$USR/.ssh/authorized_keys
fi
# access k3s
mkdir -p "$HOME/.kube"
cp /etc/rancher/k3s/k3s.yaml "$HOME/.kube/config"
echo "export KUBECONFIG=/home/$USR/.kube/config" >>$HOME/.bashrc
# use direnv for autoinit
echo 'eval "$(direnv hook bash)"' >>$HOME/.bashrc
# install nix
curl -L https://nixos.org/nix/install | sudo -u "$USR" sh
# get openserverless sources
cd $HOME
# add z.sh
curl "https://raw.githubusercontent.com/rupa/z/master/z.sh" -o "$HOME/.z.sh"
echo "source $HOME/.z.sh" >> $HOME/.bashrc
# add aliases
echo "source $HOME/openserverless/aliases" >>$HOME/.bashrc
# change owner to everything
chown -Rvf "$USR" "$HOME"
# allow direnv for submodules
sudo -u $USR git clone https://github.com/apache/openserverless --recurse-submodules
cd $HOME/openserverless
sudo -u $USR bash sync-branch.sh
sudo -i -H -u $USR bash "$HOME/openserverless/direnv-init.sh"
# install license-eye and a git-hook
sudo -u $USR git config core.hooksPath .git-hooks