firethorn

changeset 4299:beb31dffa5e2 2.1.35-stv-issue-1182

Notes on new TAP deployment
author Stelios <stv@roe.ac.uk>
date Mon Apr 06 14:37:59 2020 +0300 (10 months ago)
parents 2840ac7384f9
children 931b8811816c
files doc/notes/stv/20200331-TAP-Swarm-deploy-2.1.36.txt
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/doc/notes/stv/20200331-TAP-Swarm-deploy-2.1.36.txt	Mon Apr 06 14:37:59 2020 +0300
     1.3 @@ -0,0 +1,395 @@
     1.4 +#
     1.5 +# <meta:header>
     1.6 +#   <meta:licence>
     1.7 +#     Copyright (c) 2015, ROE (http://www.roe.ac.uk/)
     1.8 +#
     1.9 +#     This information is free software: you can redistribute it and/or modify
    1.10 +#     it under the terms of the GNU General Public License as published by
    1.11 +#     the Free Software Foundation, either version 3 of the License, or
    1.12 +#     (at your option) any later version.
    1.13 +#
    1.14 +#     This information is distributed in the hope that it will be useful,
    1.15 +#     but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 +#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.17 +#     GNU General Public License for more details.
    1.18 +#  
    1.19 +#     You should have received a copy of the GNU General Public License
    1.20 +#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.21 +#   </meta:licence>
    1.22 +# </meta:header>
    1.23 +#
    1.24 +#
    1.25 +
    1.26 +
    1.27 +## ------------------------------------------------------------------------------------------
    1.28 +## CreateVM
    1.29 +## ------------------------------------------------------------------------------------------
    1.30 +
    1.31 +stv@trop02:~$ createvm
    1.32 +..
    1.33 +INFO : Node name [Lothigometh]
    1.34 +INFO : Base name [fedora-28-32G-docker-base-20181016.qcow]
    1.35 +INFO : Base path [/var/lib/libvirt/images/base/fedora-28-32G-docker-base-20181016.qcow]
    1.36 +INFO : Disc name [Lothigometh.qcow]
    1.37 +INFO : Disc size [32GiB]
    1.38 +
    1.39 +
    1.40 +
    1.41 +## ------------------------------------------------------------------------------------------
    1.42 +## Initialize Swarm with VM's address
    1.43 +## ------------------------------------------------------------------------------------------
    1.44 +
    1.45 +ssh Stevedore@Lothigometh
    1.46 +
    1.47 +ip=$(ip -f inet -o addr show ens3|cut -d\  -f 7 | cut -d/ -f 1)
    1.48 +docker swarm init --advertise-addr ${ip}
    1.49 +
    1.50 +
    1.51 +	Swarm initialized: current node (fhowzurjvitnuy0ja8esc2c7p) is now a manager.
    1.52 +
    1.53 +	To add a worker to this swarm, run the following command:
    1.54 +
    1.55 +	    docker swarm join --token SWM.....cskl 192.168.202.9:2377
    1.56 +
    1.57 +	To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
    1.58 +
    1.59 +
    1.60 +## Firewall Ports for Swarm
    1.61 +
    1.62 +sudo su
    1.63 +    firewall-cmd --add-port=2377/tcp --permanent
    1.64 +    firewall-cmd --add-port=2377/tcp --permanent
    1.65 +    firewall-cmd --add-port=7946/tcp --permanent
    1.66 +    firewall-cmd --add-port=4789/tcp --permanent
    1.67 +    firewall-cmd --add-port=4789/udp --permanent
    1.68 +    iptables -A INPUT -p 50 -j ACCEPT    
    1.69 +    firewall-cmd --reload
    1.70 +exit
    1.71 +
    1.72 +
    1.73 +
    1.74 +
    1.75 +## -------------------------------------------------------------------------------------------
    1.76 +## Add secret function.
    1.77 +## -------------------------------------------------------------------------------------------
    1.78 +
    1.79 +    secrethost='stv@shepseskaf.roe.ac.uk'
    1.80 +    secretfile='${HOME:?}/secret.store.20190828'
    1.81 +
    1.82 +    secret()
    1.83 +    {
    1.84 +        local key=${1:?}
    1.85 +        ssh -o 'VisualHostKey=no' "${secrethost:?}" "sed -n 's/${key}=\\(.*\\)/\\1/p' \"${secretfile:?}\"" 
    1.86 +    }
    1.87 +
    1.88 +    secret 'firethorn.ssh.keys' >> "${HOME}/.ssh/authorized_keys"
    1.89 +
    1.90 +
    1.91 +
    1.92 +## -------------------------------------------------------------------------------------------
    1.93 +## Set the target branch and builtag
    1.94 +## -------------------------------------------------------------------------------------------
    1.95 +
    1.96 +
    1.97 +    export buildtag=2.1.36
    1.98 +    export branch=default
    1.99 +
   1.100 +
   1.101 +
   1.102 +## -------------------------------------------------------------------------------------------
   1.103 +## Create our chain.properties file
   1.104 +## -------------------------------------------------------------------------------------------
   1.105 +
   1.106 +cat > "${HOME:?}/chain.properties" << EOF
   1.107 +
   1.108 +metadata=postgres
   1.109 +metauser=$(pwgen 20 1)
   1.110 +metapass=$(pwgen 20 1) 
   1.111 +
   1.112 +userhost=$(secret 'firethorn.user.host')
   1.113 +userdata=$(secret 'firethorn.user.data')
   1.114 +useruser=$(secret 'firethorn.user.user')
   1.115 +userpass=$(secret 'firethorn.user.pass')
   1.116 +usertype=mssql
   1.117 +
   1.118 +datahost=$(secret 'firethorn.data.host')
   1.119 +datadata=$(secret 'firethorn.data.data')
   1.120 +datacatalog=$(secret 'firethorn.data.catalog')
   1.121 +datatype=$(secret 'firethorn.data.type')
   1.122 +datauser=$(secret 'firethorn.data.user')
   1.123 +datapass=$(secret 'firethorn.data.pass')
   1.124 +
   1.125 +tapschemadata=$(secret 'firethorn.tapschema.database.name')
   1.126 +tapschemauser=$(secret 'firethorn.tapschema.database.user')
   1.127 +tapschemapass=$(secret 'firethorn.tapschema.database.pass')
   1.128 +tapschemahost=$(secret 'firethorn.tapschema.database.host')
   1.129 +tapschemaport=$(secret 'firethorn.tapschema.database.port')
   1.130 +tapschematype=$(secret 'firethorn.tapschema.database.type')
   1.131 +tapschemajdbc=$(secret 'firethorn.tapschema.jdbc.name')
   1.132 +
   1.133 +tunneluser=$(secret 'ssh.tunnel.user')
   1.134 +tunnelhost=$(secret 'ssh.tunnel.host')
   1.135 +
   1.136 +admingroup=$(pwgen 20 1)	
   1.137 +adminuser=$(pwgen 20 1)
   1.138 +adminpass=$(pwgen 20 1)
   1.139 +
   1.140 +adql_query_delay_first=$(secret 'adql.query.delay.first')
   1.141 + 
   1.142 +firethorn_limits_rows_absolute=$(secret 'firethorn.limits.rows.absolute')
   1.143 +firethorn_limits_rows_default=$(secret 'firethorn.limits.rows.default')
   1.144 +
   1.145 +guestgroup=friends
   1.146 +endpoint=$(secret 'endpoint')
   1.147 +
   1.148 +firethornhost=gillian
   1.149 +
   1.150 +EOF
   1.151 +
   1.152 +
   1.153 +
   1.154 +## -----------------------------------------------------
   1.155 +## Create our Firethorn properties.
   1.156 +## -----------------------------------------------------
   1.157 +
   1.158 +source "${HOME:?}/chain.properties"
   1.159 +cat > "${HOME:?}/firethorn.properties" << EOF
   1.160 +
   1.161 +firethorn.meta.type=pgsql
   1.162 +firethorn.meta.driver=org.postgresql.Driver
   1.163 +firethorn.meta.host=bethany
   1.164 +firethorn.meta.url=jdbc:postgresql://bethany/${metadata}
   1.165 +firethorn.meta.data=postgres
   1.166 +firethorn.meta.user=${metauser:?}
   1.167 +firethorn.meta.pass=${metapass:?}
   1.168 +
   1.169 +firethorn.user.type=mssql
   1.170 +firethorn.user.url=jdbc:jtds:sqlserver://${userhost:?}/${userdata:?}
   1.171 +firethorn.user.driver=net.sourceforge.jtds.jdbc.Driver
   1.172 +firethorn.user.host=${userhost:?}
   1.173 +firethorn.user.data=${userdata:?}
   1.174 +firethorn.user.user=${useruser:?}
   1.175 +firethorn.user.pass=${userpass:?}
   1.176 +
   1.177 +firethorn.tapschema.resource.name=${tapschemajdbc}
   1.178 +firethorn.tapschema.database.name=${tapschemadata}
   1.179 +firethorn.tapschema.database.host=${tapschemahost}
   1.180 +firethorn.tapschema.database.port=${tapschemaport}
   1.181 +firethorn.tapschema.database.user=${tapschemauser}
   1.182 +firethorn.tapschema.database.pass=${tapschemapass}
   1.183 +
   1.184 +firethorn.admin.community=${admingroup:?}
   1.185 +firethorn.admin.user.name=${adminuser:?}
   1.186 +firethorn.admin.user.pass=${adminpass:?}
   1.187 +
   1.188 +firethorn.guest.community=${guestgroup:?}
   1.189 +
   1.190 +adql.query.delay.first=${adql_query_delay_first:?}
   1.191 +
   1.192 +firethorn.limits.rows.absolute=${firethorn_limits_rows_absolute:?}
   1.193 +firethorn.limits.rows.default=${firethorn_limits_rows_default:?}
   1.194 +
   1.195 +firethornhost=gillian
   1.196 +
   1.197 +
   1.198 +EOF
   1.199 +
   1.200 +
   1.201 +
   1.202 +## -------------------------------------------------------------------------------------------
   1.203 +## Create our compose env files.
   1.204 +## -------------------------------------------------------------------------------------------
   1.205 +
   1.206 +source "${HOME:?}/chain.properties"
   1.207 +cat > "${HOME:?}/.env" << EOF
   1.208 +
   1.209 +buildtag=${branch:?}
   1.210 +endpoint=${endpoint:?}
   1.211 +
   1.212 +
   1.213 +metadata=postgres
   1.214 +metauser=${metauser:?}
   1.215 +metapass=${metapass:?}
   1.216 +firethorn.meta.type=pgsql
   1.217 +firethorn.meta.driver=org.postgresql.Driver
   1.218 +firethorn.meta.host=bethany
   1.219 +firethorn.meta.url=jdbc:postgresql://bethany/postgres
   1.220 +firethorn.meta.data=postgres
   1.221 +firethorn.meta.user=${metauser:?}
   1.222 +firethorn.meta.pass=${metapass:?}
   1.223 +
   1.224 +
   1.225 +datadata=${datadata:?}
   1.226 +datauser=${datauser:?}
   1.227 +datapass=${datapass:?}
   1.228 +datahost=${datahost:?}
   1.229 +datacatalog=${datacatalog:?}
   1.230 +datatype=mssql
   1.231 +
   1.232 +
   1.233 +tapschemadata=${tapschemadata:?}
   1.234 +tapschemauser=${tapschemauser:?}
   1.235 +tapschemapass=${tapschemapass:?}
   1.236 +tapschemahost=${tapschemahost}
   1.237 +tapschemaport=${tapschemaport:?}
   1.238 +tapschemajdbc=${tapschemajdbc:?}
   1.239 +tapschematype=${tapschematype:?}
   1.240 +firethorn.tapschema.resource.name=${tapschemajdbc:?}
   1.241 +firethorn.tapschema.database.name=${tapschemadata:?}
   1.242 +firethorn.tapschema.database.host=${tapschemahost:?}
   1.243 +firethorn.tapschema.database.port=5432
   1.244 +firethorn.tapschema.database.user=${tapschemauser:?}
   1.245 +firethorn.tapschema.database.pass=${tapschemapass:?}
   1.246 +firethorn.tapschema.database.type=pgsql
   1.247 +
   1.248 +userhost=${userhost:?}
   1.249 +userdata=${userdata:?}
   1.250 +useruser=${useruser:?}
   1.251 +userpass=${userpass:?}
   1.252 +usertype=mssql
   1.253 +firethorn.user.type=mssql
   1.254 +firethorn.user.url=jdbc:jtds:sqlserver://${userhost:?}/${userdata:?}
   1.255 +firethorn.user.driver=net.sourceforge.jtds.jdbc.Driver
   1.256 +firethorn.user.host=${userhost:?}
   1.257 +firethorn.user.data=${userdata:?}
   1.258 +firethorn.user.user=${useruser:?}
   1.259 +firethorn.user.pass=${userpass:?}
   1.260 +
   1.261 +
   1.262 +admingroup=${admingroup:?}
   1.263 +adminuser=${adminuser:?}
   1.264 +adminpass=${adminpass:?}
   1.265 +guestgroup=${guestgroup:?}
   1.266 +firethorn.admin.community=${admingroup:?}
   1.267 +firethorn.admin.user.name=${adminuser:?}
   1.268 +firethorn.admin.user.pass=${adminpass:?}
   1.269 +firethorn.guest.community=${guestgroup:?}
   1.270 +
   1.271 +
   1.272 +adql_query_delay_first=${adql_query_delay_first:?}
   1.273 +adql.query.delay.first=${adql_query_delay_first:?}
   1.274 +firethorn_limits_rows_absolute=${firethorn_limits_rows_absolute:?}
   1.275 +firethorn_limits_rows_default=${firethorn_limits_rows_default:?}
   1.276 +firethorn.limits.rows.absolute=${firethorn_limits_rows_absolute:?}
   1.277 +firethorn.limits.rows.default=${firethorn_limits_rows_default:?}
   1.278 +
   1.279 +firethorn.ogsadai.endpoint=http://jarmila:8080/ogsadai/services
   1.280 +firethornhost=gillian
   1.281 +
   1.282 +
   1.283 +EOF
   1.284 +
   1.285 +
   1.286 +source "${HOME:?}/chain.properties"
   1.287 +cat > "${HOME:?}/.tapschema_env" << EOF
   1.288 +
   1.289 +POSTGRES_DB=${tapschemadata}
   1.290 +POSTGRES_USER=${tapschemauser}
   1.291 +POSTGRES_PASSWORD=${tapschemapass}
   1.292 +
   1.293 +EOF
   1.294 +
   1.295 +
   1.296 +source "${HOME:?}/chain.properties"
   1.297 +cat > "${HOME:?}/.metadata_env" << EOF
   1.298 +
   1.299 +POSTGRES_DB=${metadata}
   1.300 +POSTGRES_USER=${metauser}
   1.301 +POSTGRES_PASSWORD=${metapass}
   1.302 +         
   1.303 +EOF
   1.304 +
   1.305 +
   1.306 +
   1.307 +
   1.308 +## -------------------------------------------------------------------------------------------
   1.309 +## Fetch the TAP Deployer
   1.310 +## -------------------------------------------------------------------------------------------
   1.311 +
   1.312 +wget https://raw.githubusercontent.com/stvoutsin/firethorn.py/master/docker/firethorn-compose-v3.yml -O  docker-compose.yml
   1.313 +
   1.314 +
   1.315 +
   1.316 +
   1.317 +## ------------------------------------------------------------------------
   1.318 +## Deploy Swarm stack
   1.319 +## ------------------------------------------------------------------------
   1.320 +
   1.321 +docker stack deploy -c docker-compose.yml ft
   1.322 +
   1.323 +
   1.324 +
   1.325 +## ------------------------------------------------------------------------
   1.326 +## To remove all docker services 
   1.327 +## ------------------------------------------------------------------------
   1.328 +
   1.329 +## docker service rm $(docker service ls -q)
   1.330 +
   1.331 +
   1.332 +
   1.333 +
   1.334 +## ------------------------------------------------------------------------
   1.335 +## To remove all docker services 
   1.336 +## ------------------------------------------------------------------------
   1.337 +
   1.338 +## docker service rm $(docker service ls -q)
   1.339 +
   1.340 +
   1.341 +
   1.342 +## ------------------------------------------------------------------------
   1.343 +## To remove stack of services
   1.344 +## ------------------------------------------------------------------------
   1.345 +
   1.346 +## docker stack rm ft
   1.347 +
   1.348 +
   1.349 +## ------------------------------------------------------------------------
   1.350 +## Check that the services started
   1.351 +## ------------------------------------------------------------------------
   1.352 +
   1.353 +docker ps
   1.354 +CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                  PORTS               NAMES
   1.355 +b154bf2ede7a        firethorn/firethorn:latest      "/bin/sh -c '/var/lo…"   43 hours ago        Up 43 hours (healthy)   8080/tcp            ft_gillian.1.ude71jy4xuptv0jxw62zkz7v7
   1.356 +ac589bee6502        firethorn/ogsadai:latest        "/bin/sh -c '/var/lo…"   43 hours ago        Up 43 hours (healthy)   8080/tcp            ft_jarmila.1.4txmkjsy3z7ppzc4r9fzkmi1s
   1.357 +a938fdfa97e8        firethorn/postgres:latest       "docker-entrypoint.s…"   43 hours ago        Up 43 hours             5432/tcp            ft_carolina.1.zlxhpq9966nfxxwdchai75842
   1.358 +e17d1e510a75        firethorn/postgres:latest       "docker-entrypoint.s…"   43 hours ago        Up 43 hours             5432/tcp            ft_bethany.1.wrs3lalr60jaz6hxtjpv4i55y
   1.359 +1b7d90a7913d        firethorn/firethorn-py:latest   "python3"                43 hours ago        Up 43 hours                                 ft_firethorn-py.1.ma6yslq3gf4hnisccsoh1p1bd
   1.360 +
   1.361 +
   1.362 +## ------------------------------------------------------------------------
   1.363 +## Run Docker Compose tap-deployer.yml from firethorn.py
   1.364 +## ------------------------------------------------------------------------
   1.365 +
   1.366 +docker exec -it 1b7d90a7913d bash
   1.367 +
   1.368 +
   1.369 +cat > "deployer.py" << EOF
   1.370 +
   1.371 +def main():
   1.372 +    import firethorn
   1.373 +    import firethorn_utils.configurator as configur
   1.374 +    ft = firethorn.Firethorn(endpoint="http://gillian:8080/firethorn")
   1.375 +    ft.login(firethorn.config.adminuser, firethorn.config.adminpass, firethorn.config.admingroup)
   1.376 +    configurator =  configur.Configurator(ft)
   1.377 +    configurator.load_resources("https://raw.githubusercontent.com/stvoutsin/metadata/master/firethorn/config/osa-tap.json")
   1.378 +    configurator.load_resources("https://raw.githubusercontent.com/stvoutsin/metadata/master/firethorn/config/ssa-tap.json")
   1.379 +    configurator.load_resources("https://raw.githubusercontent.com/stvoutsin/metadata/master/firethorn/config/vsa-tap.json")
   1.380 +    configurator.load_resources("https://raw.githubusercontent.com/stvoutsin/metadata/master/firethorn/config/wsa-tap.json")
   1.381 +
   1.382 +if __name__== "__main__":
   1.383 +    main()
   1.384 +
   1.385 +EOF
   1.386 +
   1.387 +
   1.388 +
   1.389 +nohup python3 -u deployer.py &
   1.390 +
   1.391 +
   1.392 +
   1.393 +
   1.394 +OSA - http://gillian:8080/firethorn/tap/54/
   1.395 +SSA - http://gillian:8080/firethorn/tap/62/
   1.396 +VSA - http://gillian:8080/firethorn/tap/65/
   1.397 +WSA - http://gillian:8080/firethorn/tap/72/
   1.398 +