Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Homebrew is an easy way to install all of these and prepare your Mac to build and deploy OpenWhisk. The following shell command is provided for your convenience to install brew with Cask and bootstraps these to complete the setup. Copy the entire section below and paste it into your terminal to run it.


Code Block
languagebash
themeEmacs
echo '
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install cask
brew tap caskroom/cask
# install virtualbox
brew cask install virtualbox
# install docker 1.12.0
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/33301827c3d770bfd49f0e50d84e0b125b06b0b7/Formula/docker.rb
# install docker-machine
brew install docker-machine
# install java 8
brew cask install java
# install scala
brew install scala
# install gnu tar
brew install gnu-tar
# install pip
sudo easy_install pip
# install script prerequisites
sudo -H pip install docker==2.2.1 ansible==2.5.2 jinja2==2.9.6 couchdb==1.1 httplib2==0.9.2 requests==2.10.0' | bash

...

It is recommended that you create a virtual machine whisk with at least 4GB of RAM.


Code Block
languagebashthemeEmacs
docker-machine create -d virtualbox \
--virtualbox-memory 4096 \
--virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.12.0/boot2docker.iso \
whisk # the name of your docker machine

...

The Docker virtual machine requires some tweaking to work from the Mac host with OpenWhisk.
The following script([tweak-dockermachine.sh]) will disable TLS, add port forwarding
within the VM and routes 172.17.x.x from the Mac host to the Docker virtual machine.
Enter your sudo Mac password when prompted.


Code Block
languagebashthemeEmacs
cd /your/path/to/openwhisk
./tools/macos/docker-machine/tweak-dockermachine.sh

...

The final output of the script should resemble the following two lines.


Code Block
languagebashthemeEmacs
Run the following:
export DOCKER_HOST="tcp://192.168.99.100:4243" # your Docker virtual machine IP may vary

...

Ignore errors messages from docker-machine ls for the whisk virtual machine, this is due
to the configuration of the port 4243 vs. 2376


Code Block
languagebashthemeEmacs
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
whisk - virtualbox Running tcp://192.168.99.100:2376 Unknown Unable to query docker version: Cannot connect to the docker engine endpoint

...

To verify that docker is configured properly with docker-machine run docker ps, you should not see any errors. Here is an example output:


Code Block
theme
languagebashEmacs
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

...

You may find it convenient to set these environment variables in your bash profile (e.g., ~/.bash_profile or ~/.profile).


Code Block
languagebashthemeEmacs
export OPENWHISK_HOME=/your/path/to/openwhisk
export DOCKER_HOST=tcp://$(docker-machine ip whisk):4243

...

The tweaks to the Docker machine persist across reboots.
However, one of the tweaks is applied on the Mac host and must be applied
again if you reboot your Mac. Without it, some tests which require direct
communication with Docker containers will fail. To run just the Mac host tweaks,
run the following script([tweak-dockerhost.sh]). Enter your sudo Mac password when prompted.


Code Block
languagebashthemeEmacs
cd /your/path/to/openwhisk
./tools/macos/docker-machine/tweak-dockerhost.sh

...

Build


Code Block
theme
languagebashEmacs
cd /your/path/to/openwhisk
./gradlew distDocker

...

Deploy


Code Block
languagebashthemeEmacs
brew install python
pip install ansible==2.5.0
pip install jinja2==2.9.6

cd ansible
ansible-playbook -i environments/docker-machine setup.yml [-e docker_machine_name=whisk]

...

To verify the hosts file you can do a quick ping to the docker machine:


Code Block
theme
languagebashEmacs
cd ansible
ansible all -i environments/docker-machine -m ping

...

Should result in something like:


Code Block
languagebashthemeEmacs
ansible | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.99.100 | SUCCESS => {
"changed": false,
"ping": "pong"
}

...

Use the wsk CLI


Code Block
languagebashthemeEmacs
bin/wsk action invoke /whisk.system/utils/echo -p message hello --result
{
"message": "hello"
}

...