Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RYDM/79c7ebbcba35842610a5303fe8d9f573 to your computer and use it in GitHub Desktop.
Save RYDM/79c7ebbcba35842610a5303fe8d9f573 to your computer and use it in GitHub Desktop.
Docker/Docker-Machine/Golang and Dep Install/Opennebula Plugin/OpenVPN/VM Startup
for launching Opennebula Shell Environment for Galaxy Container
Centos7 Clean install
This Guide assumes a clean Centos 7 instance/installation.
Install Docker-CE (alternatively you can install Docker-EE):
$ sudo yum install docker-ce
If prompted give the following GPG Key:
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
Start Docker-CE with the following:
$ sudo systemctl start docker
Note on Docker:
Docker commands are run by using “sudo”
Install Docker-Machine:
base=https://github.com/docker/machine/releases/download/v0.14.0 &&
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
sudo install /tmp/docker-machine /usr/local/bin/docker-machine
Check installation:
$ docker-machine version
docker-machine version 0.14.0, build 89b8332
Installing Golang Libraries:
Update the OS prior to starting this. Depending on your user privileges you may need to run this as root:
$ su root
Password:
# yum update
Get the lib repositories manually by:
# wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
Extract:
# tar -xzf go1.10.1.linux-amd64.tar.gz
Immediately follow up with this command to move the extracted files to your $PATH (unless you've changed this to something else, use it instead):
# mv go /usr/local
Get this directory right. This was the biggest head ache and although theres more than one way to do this I found this one works best:
# mkdir -p ~/go_projects/{bin,src,pkg}
You can check to see that the directory is in fact there:
# cd ~/go_projects
# ls
“.bash_profile” config (can edit with nano):
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
#added go env
export PATH=$PATH:/usr/local/go/bin
export GOPATH="$HOME/go_projects" #notice this directory and how you made it prior... its key.
export GOBIN="$GOPATH/bin"
export PATH
Run this to verify your Golang environment is setup:
$ go env
[root@localhost bin]# go env
GOARCH="amd64"
GOBIN="/root/go_projects/bin"
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go_projects"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build058004574=/tmp/go-build -gno-record-gcc-switches"
Check install by checking version:
$ go version
go version go1.10.1 linux/amd64
Special Note about Go sw Dependancies:
Replacing the "Godep" repos for the new repo's called “Dep” are suggested at the github site. The information should not be followed, as of the current docker-machine/opennebula drivers build, explicitly; or at least you need to realize that the opennebula driver calls for “Godep” dependancies instad of “Dep” specifically (even though they are older, they will work with newer releases of Go going 1.4 forward).
As stated, Opennebula plugin commands don't call by command for "Dep".  Only "Godep".
The good news is you can have both setting up the Go environment as shown above.
“Godep” Dependancies (Golang Version 1.4 switched to “Dep”, but this old dependancy repo (Godep) will work with newer Golang versions, and is required to install the opennebula plugin):
# go get github.com/tools/godep
Go “Dep” (Dependancies, Dep is the successor to ``GoDep`` and is suggested by Go developers, it will not work for opennebula):
$ curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
Install Opennebula Plugin:
$ go get github.com/OpenNebula/docker-machine-opennebula
$ cd $GOPATH/src/github.com/OpenNebula/docker-machine-opennebula
$ make build
This builds the opennebula plugin into ~/go_projects/bin/docker-machine-driver-opennebula
From there you need to copy that file to your $PATH directory ( I personally used /usr/local/bin)
Don't be dumb-dumb like me and put it in $GOPATH . . . .
Then run:
$make install
Install EPEL Repos:
In Centos 7 you should be able to install the packages by:
$yum install epel-release
This should get your packages installed.
If the binaries aren't available you can manually download and get them by:
$ wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ rpm -ivh epel-release-latest-7.noarch.rpm
Note that both ways will result in the same thing.
Open VPN Install:
$ yum install openvpn
$  cp [OPENVPN CONFIG FILE PROVIDED BY ADMIN] /etc/openvpn/client/[YOUR_CONFIG_FILE].conf
$ systemctl start openvpn-client@[HOST_NAME]
$ (optional). systemctl enable openvpn-client@[HOST_NAME]
You can check openvpn by pinging the ip address stated in the config file (I still need to figure out how to make these myself, lots and lots of documentation).
Ifconfig would also indicate an OpenVPN tunnel showing:
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
         inet 10.5.8.6  netmask 255.255.255.0  destination 10.5.8.6
         inet6 fe80::984e:fd58:fbc0:2ced  prefixlen 64  scopeid 0x20<link>
         unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100
Note “tun0” over something like “eth0”. Its possible the names could be radically different.
You can disconnect OpenVPN by:
$sudo killall openvpn
Connecting to Opennebula Cloud:
If you have access to the Sunstone Opennebula Web API you can get a token (string of numbers the has a timed existence before it won't grant the user access and privileges). This token should be of the user group with privileges (I used one from another default “group” class of users and it didn't work and everytime Docker-Machine/Opennebula booted the VM, it would call the ONE_AUTH file and EOF while building the drivers). So be careful that you don't select the wrong thing(s) and/or wait to long if the time on the token wasn't set long enough, when you try to create the VM and log in.
Create this directory and a file in there called “one_auth”:
$ mkdir ~/.one
$ cat >~/.one/one_auth <<EOF ##this doesn't need to have a file format
In the one auth file create your credentials by using the user name of your Sunstone account (provided by Sunstone administrator) and the token string generated. Use nano or vi (or whatever you wish), to enter the format as follows:
[username]:[generatedtokenstring]
EOF
Pretty simple really. It's not clear to me if the whitespace in this file has ill implications for it successfully being executed. I suggest entering the text immediately at the start of the file.
From here if all was done right (and I haven't left anything out) you should be able to enter the command to run docker-machine with the opennebula driver and access the Opennebula cloud:
ONE_XMLRPC=https://opennebula.[HOST_NAME].com/RPC2 \
docker-machine create --driver opennebula \
--opennebula-template-id 21 [machinename]
[machine name] can be defined as you please.
Once the commands execute and the VM is running you can prompt your terminal to execute into the VM by running:
Once the commands execute
$ eval $(docker-machine env [name-of-machine])
And you can follow it up with the classic:
docker run -d -t -p 80:80 bgruening/galaxy-stable startup
. . . or whatever variant of running this you want (the ports are different on this for logging into Sunstone).
To remove the VM/Container run:
Docker-Machine rm [name-of-machine]
If you're having an error, or some other issue using this command you can “force” it by inserting the argument:
Docker-Machine rm -f [name-of-machine]
Note about Opennebula:
The file one_auth and ONE_XMLRPC are part of the Opennebula Shell.
If you don't want to write the ONE_XMLRPC line in your command then you can edit it in to .bashrc or .bash_profile and follow up with the source command to execute the changes.
To the reader:
I created this to assist others in some of the "information holes" I encountered and had to figure out the hard way. For the most part someone a little "brighter" may have no issues with information currently out there, but I've noted a few "undocumented" issues I wasn't able to explicitly find elsewhere online.
Any questions, concerns or corrections/additions are greatly appreciated and you can reach me at:
rydmsound @ <nospamSVP> gmail.com
Best Regards,
Robin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment