Skip to content

Setting up dev environment

Dan Cadden edited this page Oct 6, 2016 · 24 revisions

Before you continue with the installation process you should be aware of a few prerequisites.

Prerequisites

  • Must have go installed properly
  • Must be on macOS or Linux (Sorry Windows)

You must follow the entire installation process. If you have any questions feel free to jump in the Gophr slack and ask for help from @shikkic or @skeswa.

Clone Gophr repo

Before we begin installing all of our dependencies we'll want to clone the repo down.

$ git clone git@github.com:skeswa/gophr.git

Installing binaries

Our environment is based around kubernetes in both production and dev. So there are a few dependencies you will need before continuing.

Kubectl

This provides us with the kubectl binary that our dev environment will use to manage pod replication and cycling in our Kubernetes cluster.

Download kubectl from the Kubernetes release artifact site with the curl tool.

Download kubectl Linux binary

$ curl -O https://storage.googleapis.com/kubernetes-release/release/v1.3.4/bin/linux/amd64/kubectl
On an OS X workstation, replace linux in the URL above with darwin:

Download kubectl macOS binary

$ curl -O https://storage.googleapis.com/kubernetes-release/release/v1.3.4/bin/darwin/amd64/kubectl
After downloading the binary, ensure it is executable and move it into your PATH:

Permissions and Moving Binary to /bin

$ chmod +x kubectl
$ mv kubectl /usr/local/bin/kubectl

Minikube

Minikube is what lets us actually create a Kubernetes cluster locally for dev and with ease too. It provides a minikube binary that makes the process very simple and easy.

Install Minikube Linux binary

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.9.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Install Minikube macOS Binary

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.9.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

If you don't feel comfortable executing these commands listed above you can also find the official installation instructions for latest releases here

Gophrctl

Gophrctl is an house cli for controlling our production and dev environments. We interface easily with minikube and build images, cycle pods, create secrets, and more.

Install Gophrctl binary

Navigate to the gophr repo you cloned earlier, and go to ../infra/gophrctl

$ cd $GOPHR_PATH/infra/gophrctl && go install

This should build and place the binary in your PATH. You should now be able to run:

$ gophrctl 

You should see something like this

NAME:
   gophrctl - Manages the gophr development and deployment environment.

USAGE:
   gophrctl [global options] command [command options] [arguments...]

VERSION:
   0.0.1

COMMANDS:
     build    Updates module images
     cycle    Re-creates a module in kubernetes
     log      Logs module's container output to stdout
     ssh      Starts a shell session within a module's container
     update   Updates module kubernetes definition
     secrets  Deals with confidential data
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --env value        gophr execution environment (default: "dev")
   --repo-path value  path to the gophr repository (default: "/Users/shikkic/dev/go/src/github.com/skeswa/gophr")
   --help, -h         show help
   --version, -v      print the version

Getting minikube up and running

Now that we have all of our dependencies installed we'll want to get our kubernetes cluster up and running.

Start minikube

First we need to make sure minikube is running.

$ minikube start

After minikube is up and running we can open up a dashboard and use it to manage our pods that will run.

$ minikube dashboard

You should have something that looks like this (but empty). Imgur

Building your own secrets

// TODO

Building Images

Now we want to build all of images from scratch so we can cycle them into our kubernetes cluster.

$ gophrctl build 

It may take a little while to build all the images at first

Cycling the images

Now that all of our images are built we need to cycle them into our cluster.

$ gophrctl cycle

We're finished!

Retrieve your kuberenetes ip:

$ minikube ip

Then try hitting https://MINIKUBE_IP:30443 to get the dev web page up.

imgur

You can also try making a mock go get request your local dev by running:

$ go get --insecure https://${minikube ip}:30443/$REPO_NAME/$AUTHOR_NAME@(semver or SHA)

The @ at the end of the url is optional, you don't need to use it unless you're specifying a version