diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf89f7d..73ca41a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,8 @@ -# Contributing to Create Kubernetes App +# Contributing to `kapp` -TODO +creating a new release + +1. `make bump-version` +2. `make all` +3. `make release` +4. `make tag` diff --git a/Makefile b/Makefile index c681d8b..c58e32f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ +CURRENT_DIR?=$(shell pwd) +BUILDDIR:=$(CURRENT_DIR)/release + NAME:=kapp -PKG:=github.com/peterj/kapp +PKG:=github.com/peterj/$(NAME) GOOSARCHES=darwin/amd64 VERSION_FILE:=VERSION.txt @@ -69,3 +72,24 @@ bump-version: echo $(NEW_VERSION) > VERSION.txt git add VERSION.txt README.md git commit -vsam "Bump version to $(NEW_VERSION)" + +# Create a new git tag to prepare to build a release +.PHONY: tag +tag: + git tag -sa $(VERSION) -m "$(VERSION)" + @echo "Run git push origin $(VERSION) to push your new tag to GitHub and trigger build." + +define buildrelease +GOOS=$(1) GOARCH=$(2) CGO_ENABLED=1 go build \ + -o $(BUILDDIR)/$(NAME)-$(1)-$(2) \ + -a -tags "$(BUILDTAGS) static_build netgo" \ + -installsuffix netgo ${GO_LDFLAGS_STATIC} .; +md5sum $(BUILDDIR)/$(NAME)-$(1)-$(2) > $(BUILDDIR)/$(NAME)-$(1)-$(2).md5; +shasum -a 256 $(BUILDDIR)/$(NAME)-$(1)-$(2) > $(BUILDDIR)/$(NAME)-$(1)-$(2).sha256; +endef + +# Builds the cross-compiled binaries, naming them in such a way for release (eg. binary-GOOS-GOARCH) +.PHONY: release +release: *.go VERSION.txt + @echo "+ $@" + $(foreach GOOSARCH,$(GOOSARCHES), $(call buildrelease,$(subst /,,$(dir $(GOOSARCH))),$(notdir $(GOOSARCH)))) \ No newline at end of file diff --git a/README.md b/README.md index 2fec6df..25ac506 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ Create Go apps/services that run on Kubernetes with minimal configuration. Inspiration for this project came from [create-react-app](https://github.com/facebook/create-react-app) project. +* [Prerequisites](#prerequisites) * [Creating an App](#creating-an-app) - How to create a new Kubernetes app +* [Development Workflow](#development-workflow) Tool was developed and tested on macOS. There's no guarantee that it works on other platforms. If you run into any issues, please @@ -37,6 +39,18 @@ Run the app with `./helloworld` and access it at http://localhost:8080/. ![kapp demo GIT](img/kapp-create.gif) +# Prerequisites + +* [Go](https://golang.org/dl/) +* [Docker](https://www.docker.com/docker-mac) +* [Helm](https://helm.sh/) +* [Dep](https://github.com/golang/dep) +* [Git](https://git-scm.com/) +* Kubernetes cluster - you can also use Kubernetes support in + [Docker for Mac](https://www.docker.com/docker-mac), + [Minikube](https://github.com/kubernetes/minikube) or an actual cluster from + one of the cloud providers + ## Creating an app To create a new Kubernetes app, run the following command: @@ -76,36 +90,36 @@ helloworld The inital workflow for getting your app running in Kubernetes involves these steps: -1. Build the app image -2. Push the app image to the registry -3. Create intial app release -4. Interact with the app +1. [Build the app image](#build-the-image) +2. [Push the app image to the registry](#push-the-image) +3. [Create intial app release (first deployment)](#first-deployment) +4. [Interact with the app](#interact-with-the-app) 5. Deploy app updates -After you've create the inital release you will be following a similar workflow -where you make some changes to your app, bump the version (or not), deploy the -updated app and interact with it. +After you have created the inital release (step #3) you will be #### Build the image -Makefile task `build.image` can be used to build and tag the Docker image with -your app. Before running `make build.image`, make sure you login to the image -registry you want to use and set the `DOCKER_REGISTRY` environment variable. +Makefile task `build.image` can be used to build the Docker image that contains +your app and tag that image. Note that before you run `make build.image`, you +have to do these two things: -Here's an example on how to set the image registry (note: if you're using a -different registry, you can provide the URL to the registry by running -`docker login [registry]`): +1. Login to the image registry you want to use +2. Set the `DOCKER_REGISTRY` environment variable to that registry + +Below is an example on how to set the image registry and run the `build.image` +task: ```bash $ cd helloworld -# Login to the hub.docker.com +# Login to the hub.docker.com (or any other image registry) $ docker login # Replace 'kubeapp' with your hub.docker.com username $ export DOCKER_REGISTRY=kubeapp -# Builds the image in format: kubeapp/helloworld:0.1.0 +# Build the image in format: kubeapp/helloworld:0.1.0 $ make build.image -> build.image docker build -f Dockerfile -t kubeapp/helloworld:0.1.0 . @@ -113,7 +127,7 @@ docker build -f Dockerfile -t kubeapp/helloworld:0.1.0 . Successfully tagged kubeapp/helloworld:0.1.0 ``` -#### Push the image to registry +#### Push the image With image built, you can use `make push.image` task to push the built image to the registry: @@ -127,10 +141,12 @@ The push refers to repository [docker.io/kubeapp/helloworld] 0.1.0: digest: sha256:b13772ff86c9f2691bfd56a6cbdc73d3456886f8b85385a43699706f0471c866 size: 1156 ``` -#### Create initial app release +#### First deployment Task `install.app` is used to create an inital installation/deployment of your -app to Kubernetes. +app to Kubernetes. Before running this task, you need to ensure you have Helm +installed and initialized on the cluster and your current cluster context is set +to the cluster you want to deploy the app to. ```bash $ make install.app @@ -156,9 +172,10 @@ helloworld-65b5fdc94f-42664 0/1 ContainerCreating 0 0s ``` The `install.app` task will install your application in `helloworld` namespace. -The initial installation creates a deployment as well as a service you can use -to access the application. You can run the following Helm command to check make -sure your app is installed: +The initial installation creates a Kubernetes deployment as well as a Kubernetes +service you can use to access the application. + +To double check your app is deployed, run the following Helm command: ```bash $ helm list @@ -166,9 +183,9 @@ NAME REVISION UPDATED STATUS CHART NAMESPACE helloworld 1 Tue May 1 16:25:54 2018 DEPLOYED helloworld-0.1.0 helloworld ``` -Alternatively, you can use `kubectl` to check the resources that were created -(below we are getting all services and deployments from the `helloworld` -namespace that have a label called `app` set to `helloworld`): +Alternatively, you can use `kubectl` to check the created resources. With the +command in the example below, we are getting all services and deployments from +the `helloworld` namespace that have a label called `app` set to `helloworld`: ```bash $ kubectl get svc,deploy -l app=helloworld -n helloworld @@ -181,8 +198,9 @@ deploy/helloworld 1 1 1 1 2m #### Interact with the app -Now that the app is deployed we can interact with it. The simples way is to use -Kubernetes proxy to create a connection to the cluster: +Now that your app is deployed and running in Kubernetes, you can interact with +it. There are a couple of different ways you could interact with the app, the +simplest being Kubernetes proxy to create a connection to the cluster: ```bash # Create a proxy to the cluster and run it in the background diff --git a/VERSION.txt b/VERSION.txt index 6c6aa7c..17e51c3 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.1