@@ -7,6 +7,10 @@ Rather than installing all the dependencies locally, you can test and build Agon
77built from the Dockerfile in this directory. There is an accompanying Makefile for all the common
88tasks you may wish to accomplish.
99
10+ ** Note** - this has been tested on Linux. Tickets for [ OSX] ( https://github.com/googleprivate/agon/issues/46 )
11+ and [ Windows] ( https://github.com/googleprivate/agon/issues/47 ) exist, and require work. Testing on these platforms
12+ and reporting bugs is appreciated.
13+
1014<!-- ToC start -->
1115## Table of Contents
1216
@@ -18,12 +22,13 @@ tasks you may wish to accomplish.
1822 1 . [ Make Variable Reference] ( #make-variable-reference )
1923 1 . [ VERSION] ( #version )
2024 1 . [ REGISTRY] ( #registry )
21- 1 . [ KUBECONFIG ] ( #kubeconfig )
25+ 1 . [ KUBEPATH ] ( #kubepath )
2226 1 . [ CLUSTER_NAME] ( #cluster_name )
2327 1 . [ Make Target Reference] ( #make-target-reference )
2428 1 . [ Development Targets] ( #development-targets )
2529 1 . [ Build Image Targets] ( #build-image-targets )
2630 1 . [ Google Cloud Platform] ( #google-cloud-platform )
31+ 1 . [ Minikube] ( #minikube )
2732<!-- ToC end -->
2833
2934## GOPATH
@@ -69,8 +74,8 @@ to be open to UDP traffic.
6974
7075First step is to create a Google Cloud Project at https://console.cloud.google.com or reuse an existing one.
7176
72- The build tools (by default) maintain configuration for gcloud and kubectl within the ` build ` folder, so as to keep
73- everything seperate (see below for overwriting these config locations). Therefore, once the project has been created,
77+ The build tools (by default) maintain configuration for gcloud within the ` build ` folder, so as to keep
78+ everything separate (see below for overwriting these config locations). Therefore, once the project has been created,
7479we will need to authenticate out gcloud tooling against it. To do that run ` make gcloud-init ` and fill in the
7580prompts as directed.
7681
@@ -81,8 +86,8 @@ done you can go to the Google Cloud Platform console and see that a cluster is u
8186name of the test cluster you can set the ` CLUSTER_NAME ` environemnt varlable to value you would like.
8287
8388To grab the kubectl authentication details for this cluster, run ` make gcloud-auth-cluster ` , which will generate the
84- required Kubernetes security credintials for ` kubectl ` . This will be stored in ` build /.kube` by default, but can also be
85- overwritten by setting the ` KUBECONFIG ` environment variable before running the command.
89+ required Kubernetes security credintials for ` kubectl ` . This will be stored in ` ~ /.kube` by default, but can also be
90+ overwritten by setting the ` KUBEPATH ` environment variable before running the command.
8691
8792Great! Now we are setup, let's try out the development shell, and see if our ` kubectl ` is working!
8893
@@ -106,11 +111,60 @@ To push our images up at this point, is simple `make push` and that will push up
106111project's container registry.
107112
108113Now that the images are pushed, to install the development version (with all imagePolicies set to always download),
109- run ` make install ` and agon will install the image that you just built and pushed on the test cluster you
114+ run ` make install ` and Agon will install the image that you just built and pushed on the test cluster you
110115created at the beginning of this section. (if you want to see the resulting installation yaml, you can find it in ` build/.install.yaml ` )
111116
112117### Running a Test Minikube cluster
113- (Coming soon: Track [ this bug] ( https://github.com/googleprivate/agon/issues/30 ) for details)
118+ This will setup a [ Minikube] ( https://github.com/kubernetes/minikube ) cluster, running on an ` agon ` profile,
119+
120+ Because Minikube runs on a virtualisation layer on the host, some of the standard build and development Make targets
121+ need to be replaced by Minikube specific targets.
122+
123+ First, [ install Minikube] ( https://github.com/kubernetes/minikube#installation ) , which may also require you to install
124+ a virtualisation solution, such as [ VirtualBox] ( https://www.virtualbox.org ) as well.
125+
126+ Next we will create the Agon Minikube cluster. Run ` make minikube-test-cluster ` to create an ` agon ` profile,
127+ create a Kubernetes cluster under this profile of the supported version,
128+ and mount the development code inside the Minikube instance so we are able to build Agon inside Minikube.
129+
130+ This will also install the kubectl authentication credentials in ` ~/.kube ` , and set the
131+ [ ` kubectl ` context] ( https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ )
132+ to ` agon ` .
133+
134+ Great! Now we are setup, let's try out the development shell, and see if our ` kubectl ` is working!
135+
136+ Run ` make minikube-shell ` to enter the development shell. You should see a bash shell that has you as the root user.
137+ Enter ` kubectl get pods ` and press enter. You should see that you have no resources currently, but otherwise see no errors.
138+ Assuming that all works, let's exit the shell by typing ` exit ` and hitting enter, and look at a couple of
139+ options for building, pushing and installing Agon next.
140+
141+ There are two options for building Agon, and depending on your virtualisation solution and its configuration
142+ each has it's pros and cons
143+
144+ #### Building directly on Minikube
145+ Since Minikube allows you to [ reuse its Docker daemon] ( https://github.com/kubernetes/minikube/blob/master/docs/reusing_the_docker_daemon.md )
146+ we can build our images to run Agon directly on Minikube!
147+
148+ To do this, run ` make minikube-build ` , which will transfer the build image into the cluster
149+ and run the ` build-images ` target on the Minikube instance, creating the images required to run Agon.
150+
151+ Again depending on your virtualisation layer, you may want to configure it to allow it to have access to more
152+ cores and/or memory than the default, to allow for faster compilation (or for it to compile at all).
153+
154+ #### Pushing locally built images to Minikube
155+ You may remember in the first part of this walkthrough, we ran ` make build ` , which created all the images and binaries
156+ we needed to work with Agon locally. So instead of rebuilding them, can we push them straight into Minikube?
157+
158+ You bet we can!
159+
160+ Run ` make minikube-push ` which will send all of Agon's docker images from your local Docker into the Agon Minikube
161+ instance.
162+
163+ This may be better option if you find building on Minikube slow, or you just prefer to build locally.
164+
165+ Now that the images are pushed, to install the development version,
166+ run ` make minikube-install ` and Agon will install the images that you built and pushed to the Agon Minikube instance
167+ created at the beginning of this section. (if you want to see the resulting installation yaml, you can find it in ` build/.install.yaml ` )
114168
115169### Next Steps
116170
@@ -124,8 +178,9 @@ The version of this build. Version defaults to the short hash of the latest comm
124178### REGISTRY
125179The registry that is being used to store docker images. Defaults to gcr.io/agon-images - the release + CI registry.
126180
127- ### KUBECONFIG
128- Where the kubectl configuration files are being stored for shell and kubectl targets. Defaults to build/.kube
181+ ### KUBEPATH
182+ The directory the kubectl configuration files are being stored for shell and kubectl targets.
183+ Defaults to ~ /.kube (where your Kubernetes configs are likely to already exist)
129184
130185### CLUSTER_NAME
131186The (gcloud) test cluster that is being worked against. Defaults to ` test-cluster `
@@ -156,6 +211,9 @@ Run all tests
156211#### ` make push `
157212Pushes all built images up to the ` $(REGISTRY) `
158213
214+ #### ` make install `
215+ Installs the current development version of Agon into the Kubernetes cluster
216+
159217#### ` make shell `
160218Run a bash shell with the developer tools (go tooling, kubectl, etc) and source code in it.
161219
@@ -189,7 +247,7 @@ Creates the build docker image
189247
190248### Google Cloud Platform
191249
192- A set of utilities for setting up a Container Engine cluster on Google Cloud Platform,
250+ A set of utilities for setting up a Kubernetes Engine cluster on Google Cloud Platform,
193251since it's an easy way to get a test cluster working with Kubernetes.
194252
195253#### ` make gcloud-init `
@@ -205,3 +263,37 @@ Pulls down authentication information for kubectl against a cluster, name can be
205263#### ` make gcloud-auth-docker `
206264Creates a short lived access to Google Cloud container repositories, so that you are able to call
207265` docker push ` directly. Useful when used in combination with ` make push ` command.
266+
267+ ### Minikube
268+
269+ A set of utilities for setting up and running a [ Minikube] ( https://github.com/kubernetes/minikube ) instance,
270+ for local development.
271+
272+ Since Minikube runs locally, there are some targets that need to be used instead of the standard ones above.
273+
274+ #### ` minikube-test-cluster `
275+ Switches to an "agon" profile, and starts a kubernetes cluster
276+ of the right version. Also mounts the project directory into Minikube,
277+ so that the build tools will work.
278+
279+ Use DRIVER variable to change the VM driver (default virtualbox) if you so desire.
280+
281+ #### ` minikube-build `
282+ Convenience target to build Agon's docker images directly on Minikube.
283+
284+ #### ` minikube-push `
285+ Instead of building Agon's docker images inside Minikube,
286+ use this command to push the local images that have already been built
287+ via ` make build ` or ` make build-images ` .
288+
289+ #### ` minikube-install `
290+ Installs the current development version of Agon into the Kubernetes cluster.
291+ Use this instead of ` make install ` , as it disables PullAlways on the install.yaml
292+
293+ #### ` minikube-shell `
294+ Connecting to Minikube requires so enhanced permissions, so use this target
295+ instead of ` make shell ` to start an interactive shell for development on Minikube.
296+
297+ Depending on the virtualisation driver/configuration,
298+ it may be faster to build locally and push, rather than building directly on Minikube.
299+
0 commit comments