-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrancher-master
31 lines (31 loc) · 5.42 KB
/
rancher-master
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
( [ "$version" ] || version=$(curl -fsSL "https://install.portworx.com/?type=dock&stork=false" | awk -F: '/image: / {print $3}')
docker run --name rs -d -v /rancher/mysql:/var/lib/mysql --restart=unless-stopped -p 8080:8080 rancher/server
curl -sSL https://github.com/rancher/cli/releases/download/v2.2.0/rancher-linux-amd64-v2.2.0.tar.gz | tar xzf - --strip-components=2 -C /usr/bin
docker run --name etcd -d -v /etcd:/etcd-data -p 2379:2379 -p 2380:2380 quay.io/coreos/etcd:latest /usr/local/bin/etcd --advertise-client-urls http://$(hostname -i):2379 --listen-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --data-dir=/etcd-data --initial-advertise-peer-urls http://$(hostname -i):2380 --initial-cluster node1=http://$(hostname -i):2380 --name node1
while : ; do
curl -s -X PUT http://localhost:8080/v1/settings/api.host -H 'content-type: application/json' -d '{"value":"http://'$(hostname -i)':8080"}'
[ $? -eq 0 ] && break
sleep 1
done
while : ; do
template_id=$(curl -s http://master-$c:8080/v2-beta/projectTemplates?name=kubernetes | json data[0].id)
[ $template_id ] && break
sleep 1
done
curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"description":"kubernetes","name":"kubernetes","projectTemplateId":"'$template_id'","allowSystemRole":false,"members":[],"virtualMachine":false,"servicesPortRange":null}' "http://master-$c:8080/v2-beta/projects" | json
default_env_id=$(curl -s "http://master-$c:8080/v2-beta/project?name=Default" | json data[0].id)
while : ; do
curl -s -X POST -H 'Content-Type: application/json' -H 'accept: application/json' -d '{"type":"registrationToken"}' "http://master-$c:8080/v2-beta/projects/$default_env_id/registrationtoken"
[ $? -eq 0 ] && break
done
if [ $journal = true ]; then
while : ; do
journal_args="-j /dev/$(ssh -oConnectTimeout=1 -oStrictHostKeyChecking=no node-$c-1 lsblk | grep 3G | tail -f | cut -f 1 -d ' ')"
[ $? -eq 0 ] && break
sleep 5
done
fi
curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' http://master-$c:8080/v2-beta/projects/$default_env_id/stack -d@- <<EOF | json
{"system":true,"type":"stack","name":"portworx","startOnCreate":true,"environment":{"INSTALL_SCALE":"global","CLUSTER_ID":"$cluster_name","KVDB":"etcd://$(hostname -i):2379","USE_DISKS":"-a","EXTRA_OPTS":""},"dockerCompose":"version: '2'\nservices:\n portworx:\n image: portworx/oci-monitor:$version\n container_name: px-oci-mon\n privileged: true\n labels:\n io.rancher.container.dns: 'true'\n {{- if eq .Values.INSTALL_SCALE \"global\" }}\n io.rancher.scheduler.global: 'true'\n {{- end }}\n io.rancher.container.pull_image: always\n io.rancher.container.hostname_override: container_name\n io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=\$\${stack_name}/\$\${service_name}\n io.rancher.scheduler.affinity:host_label_ne: px/enabled=false\n environment:\n CLUSTER_ID: \${CLUSTER_ID}\n KVDB: \${KVDB}\n USE_DISKS: \${USE_DISKS}\n EXTRA_OPTS: \${EXTRA_OPTS}\n ENABLE_ATTR_CACHE: true\n volumes:\n - /var/run/docker.sock:/var/run/docker.sock:rprivate\n - /etc/pwx:/etc/pwx:rprivate\n - /opt/pwx:/opt/pwx:rprivate\n - /etc/systemd/system:/etc/systemd/system:rprivate\n - /proc/1/ns:/host_proc/1/ns:rprivate\n - /var/run/dbus:/var/run/dbus:rprivate\n command: -c \${CLUSTER_ID} -k \${KVDB} \${USE_DISKS} $journal_args -x rancher --endpoint 0.0.0.0:9015 \${EXTRA_OPTS}\n","rancherCompose":".catalog:\n name: \"Portworx\"\n version: \"$version.0-oci\"\n description: \"Portworx Docker Volume Driver\"\n questions:\n\n - variable: INSTALL_SCALE\n label: Install scale\n description: \"Determine if Portworx should install globally on all the nodes, or scaled via stacks (starting with Scale=1).\"\n required: true\n default: \"global\"\n type: enum\n options:\n - \"global\"\n - \"scaled\"\n - variable: \"CLUSTER_ID\"\n description: \"Arbitrary Cluster ID, common to all nodes in PX cluster \"\n label: \"Cluster ID\"\n type: \"string\"\n required: true\n default: \"\"\n - variable: \"KVDB\"\n description: \"Key-value database, accessibe to all nodes in PX cluster\"\n label: \"Key-Value Database\"\n type: \"string\"\n required: true\n default: \"\"\n - variable: \"USE_DISKS\"\n description: \"Specify which disks to use (Ex: '-a' for all available unformatted disks, or '-s /dev/sdX' for each individual disk)\"\n label: \"Use Disks\"\n type: \"string\"\n required: true\n default: \"-a\"\n - variable: \"EXTRA_OPTS\"\n description: \"Extra portworx options (see https://docs.portworx.com/runc/#command-line-arguments)\"\n label: \"Extra Options\"\n type: \"string\"\n required: false\n default: \"\"\n\nportworx:\n metadata:\n version: 1\n storageDriverName: pxd\n debug: true\n volumeDriverName: pxd\n storage_driver:\n name: pxd\n scope: environment\n volume_access_mode: multiHostRW\n blockDevicePath: null\n start_on_create: true\n health_check:\n request_line: GET /health HTTP/1.0\n port: 9015\n interval: 10000\n response_timeout: 5000\n unhealthy_threshold: 3\n healthy_threshold: 2\n initializing_timeout: 840000\n strategy: none\n\n","externalId":"catalog://library:infra*portworx:50"}
EOF
echo End) >&/var/log/vagrant.bootstrap &