Skip to content

Commit

Permalink
Merge pull request #72 from shahidhk/cli
Browse files Browse the repository at this point in the history
introduce gitkube cli
  • Loading branch information
tirumaraiselvan authored May 25, 2018
2 parents 5ef88c6 + c686715 commit 190fa1e
Show file tree
Hide file tree
Showing 879 changed files with 71,912 additions and 102,136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gitkube
cmd/gitkube-controller/gitkube-controller
ws/
_output/
35 changes: 26 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,44 @@ GITKUBED_IMAGE ?= "$(IMAGE_REGISTRY)/$(GITKUBED_IMAGE_NAME)"
GITKUBED_DIR ?= "build/gitkubed"
SETUP_MANIFEST_FILE ?= "manifests/gitkube-setup.yaml"

CONTROLLER_VERSION := $(shell hack/get-version.sh)
GITKUBED_VERSION := $(shell hack/get-component-version.sh $(GITKUBED_DIR))
PWD := $(shell pwd)
VERSION := $(shell hack/get-version.sh)

build-controller:
docker build -t $(CONTROLLER_IMAGE):$(CONTROLLER_VERSION) .
$(shell sed -i -E "s@image: .+\/$(CONTROLLER_IMAGE_NAME):.+@image: $(CONTROLLER_IMAGE):$(CONTROLLER_VERSION)@" $(SETUP_MANIFEST_FILE))
docker build -t $(CONTROLLER_IMAGE):$(VERSION) .
$(shell sed -i -E "s@image: .+\/$(CONTROLLER_IMAGE_NAME):.+@image: $(CONTROLLER_IMAGE):$(VERSION)@" $(SETUP_MANIFEST_FILE))

push-controller:
docker push $(CONTROLLER_IMAGE):$(CONTROLLER_VERSION)
docker push $(CONTROLLER_IMAGE):$(VERSION)

build-gitkubed:
docker build -t $(GITKUBED_IMAGE):$(GITKUBED_VERSION) $(GITKUBED_DIR)
$(shell sed -i -E "s@image: .+\/$(GITKUBED_IMAGE_NAME):.+@image: $(GITKUBED_IMAGE):$(GITKUBED_VERSION)@" $(SETUP_MANIFEST_FILE))
docker build -t $(GITKUBED_IMAGE):$(VERSION) $(GITKUBED_DIR)
$(shell sed -i -E "s@image: .+\/$(GITKUBED_IMAGE_NAME):.+@image: $(GITKUBED_IMAGE):$(VERSION)@" $(SETUP_MANIFEST_FILE))

push-gitkubed:
docker push $(GITKUBED_IMAGE):$(GITKUBED_VERSION)
docker push $(GITKUBED_IMAGE):$(VERSION)

build-all: build-controller build-gitkubed
push-all: push-controller push-gitkubed

controller: build-controller push-controller
gitkubed: build-gitkubed push-gitkubed

all: build-all push-all
# build cli locally, for all given platform/arch
build-cli:
go get github.com/mitchellh/gox
gox -ldflags "-X github.com/hasura/gitkube/pkg/cmd.version=$(VERSION)" \
-os="linux darwin windows" \
-arch="amd64" \
-output="_output/$(VERSION)/gitkube_{{.OS}}_{{.Arch}}" \
./cmd/gitkube-cli/

# build cli inside a docker container
build-cli-in-docker:
docker build -t gitkube-cli-builder -f build/cli-builder.dockerfile build
docker run --rm -it \
-v $(PWD):/go/src/github.com/hasura/gitkube \
gitkube-cli-builder \
make build-cli

all: build-all push-all build-cli-in-docker
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,29 @@ Gitkube will run on any Kubernetes vendor/distribution AS IS. In case you find a

#### Install gitkube

##### Using kubectl

```sh
kubectl create -f https://storage.googleapis.com/gitkube/gitkube-setup-stable.yaml

#expose gitkubed service
kubectl --namespace kube-system expose deployment gitkubed --type=LoadBalancer --name=gitkubed
```

##### Using gitkube CLI

1. Install Gitkube CLI:
- Linux/MacOS
``` bash
curl https://raw.githubusercontent.com/hasura/gitkube/master/gimme.sh | bash
```
- Windows: download the latest [release](https://github.com/hasura/gitkube/releases) and add it to your `PATH`.

2. Use Gitkube CLI to install Gitkube on the cluster:
```bash
gitkube install
```

#### Provider walkthroughs

The above installation steps work on most Kubernetes clusters. Detailed walkthroughs for few specific providers are also available:
Expand Down
7 changes: 7 additions & 0 deletions build/cli-builder.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.10

# install gox
RUN go get github.com/mitchellh/gox

# setup the working directory
WORKDIR /go/src/github.com/hasura/gitkube
16 changes: 16 additions & 0 deletions cmd/gitkube-cli/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// A CLI tool to install and manage Gitkube and associated remotes on a
// Kubernetes cluster.
package main

import (
"github.com/hasura/gitkube/pkg/cmd"
log "github.com/sirupsen/logrus"
)

// main is the entrypoint function
func main() {
err := cmd.Execute()
if err != nil {
log.Fatal(err)
}
}
43 changes: 43 additions & 0 deletions docs/cli/gitkube.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## gitkube

Build and deploy docker images to Kubernetes using git push

### Synopsis

Install Gitkube and manage its Remotes on a Kubernetes cluster

### Examples

```
# Get your application running on Kubernetes in 4 simple steps.
# Step 1: Install Gitkube on a Kubernetes cluster:
gitkube install
# Step 2: Generate a Gitkube Remote spec interactively and save it as 'example-remote.yaml':
gitkube remote generate -f example-remote.yaml
# Step 3: Create a Remote defined in 'example-remote.yaml' on the cluster:
gitkube remote create -f example-remote.yaml
# outputs the remote url
# Step 4: Add remote to the git repo and push:
git remote add example <remote_url>
git push example master
```

### Options

```
-h, --help help for gitkube
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube install](gitkube_install.md) - Install Gitkube on a Kubernetes cluster
* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster
* [gitkube uninstall](gitkube_uninstall.md) - Uninstall Gitkube components from a cluster
* [gitkube version](gitkube_version.md) - Output the cli version

###### Auto generated by spf13/cobra on 26-May-2018
46 changes: 46 additions & 0 deletions docs/cli/gitkube_install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## gitkube install

Install Gitkube on a Kubernetes cluster

### Synopsis

Install all Gitkube components on the cluster and expose the gitkubed deployment

```
gitkube install [flags]
```

### Examples

```
# Install Gitkube in 'kube-system' namespace:
gitkube install
# Install in another namespace:
gitkube install --namespace <your-namespace>
# The command prompts for a ServiceType to expose gitkubed deployment.
# Use '--expose' flag to set a ServiceType and skip the prompt
# Say, 'LoadBalancer':
gitkube install --expose LoadBalancer
```

### Options

```
-e, --expose string k8s service type to expose the gitkubed deployment
-h, --help help for install
-n, --namespace string namespace to create install gitkube resources in (default "kube-system")
```

### Options inherited from parent commands

```
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube](gitkube.md) - Build and deploy docker images to Kubernetes using git push

###### Auto generated by spf13/cobra on 26-May-2018
29 changes: 29 additions & 0 deletions docs/cli/gitkube_remote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## gitkube remote

Manage Gitkube Remotes on a cluster

### Synopsis

Manage Gitkube Remotes on a cluster

### Options

```
-h, --help help for remote
```

### Options inherited from parent commands

```
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube](gitkube.md) - Build and deploy docker images to Kubernetes using git push
* [gitkube remote create](gitkube_remote_create.md) - Create Remote for enabling git-push, from a spec file
* [gitkube remote delete](gitkube_remote_delete.md) - Delete a Remote from the cluster
* [gitkube remote generate](gitkube_remote_generate.md) - Generate a Remote spec in an interactive manner
* [gitkube remote list](gitkube_remote_list.md) - List Remotes

###### Auto generated by spf13/cobra on 26-May-2018
37 changes: 37 additions & 0 deletions docs/cli/gitkube_remote_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## gitkube remote create

Create Remote for enabling git-push, from a spec file

### Synopsis

Create Remote for enabling git-push, from a spec file

```
gitkube remote create [flags]
```

### Examples

```
# Create a remote by reading 'example-remote.yaml':
gitkube create -f example-remote.yaml
```

### Options

```
-f, --file string spec file
-h, --help help for create
```

### Options inherited from parent commands

```
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster

###### Auto generated by spf13/cobra on 26-May-2018
37 changes: 37 additions & 0 deletions docs/cli/gitkube_remote_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## gitkube remote delete

Delete a Remote from the cluster

### Synopsis

Delete a Gitkube remote from the cluster

```
gitkube remote delete [flags]
```

### Examples

```
# Delete remote called 'example':
gitkube remote delete example
```

### Options

```
-h, --help help for delete
-n, --namespace string namespace of the remote (default "default")
```

### Options inherited from parent commands

```
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster

###### Auto generated by spf13/cobra on 26-May-2018
41 changes: 41 additions & 0 deletions docs/cli/gitkube_remote_generate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## gitkube remote generate

Generate a Remote spec in an interactive manner

### Synopsis

An interactive prompt-driven approach to generate Remote spec, rather than writing yaml by hand

```
gitkube remote generate [flags]
```

### Examples

```
# Generate a remote and save it as 'example-remote.yaml':
gitkube remote generate -f example-remote.yaml
# Shows interactive prompts to type-in/select options.
# Contacts the cluster to create docker registry secret (if provided)
```

### Options

```
-h, --help help for generate
-o, --output string file format to output, supports yaml and json (default "yaml")
-f, --output-file string write generated spec to this file
```

### Options inherited from parent commands

```
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster

###### Auto generated by spf13/cobra on 26-May-2018
37 changes: 37 additions & 0 deletions docs/cli/gitkube_remote_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## gitkube remote list

List Remotes

### Synopsis

List Gitkube Remotes on a cluster

```
gitkube remote list [flags]
```

### Examples

```
# List all remotes:
gitkube remote list
```

### Options

```
-h, --help help for list
-n, --namespace string namespace for listing (default "default")
```

### Options inherited from parent commands

```
--kube-context string kubernetes context to use
```

### SEE ALSO

* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster

###### Auto generated by spf13/cobra on 26-May-2018
Loading

0 comments on commit 190fa1e

Please sign in to comment.