Skip to content

Commit 190fa1e

Browse files
Merge pull request #72 from shahidhk/cli
introduce gitkube cli
2 parents 5ef88c6 + c686715 commit 190fa1e

File tree

879 files changed

+71912
-102136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

879 files changed

+71912
-102136
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
gitkube
22
cmd/gitkube-controller/gitkube-controller
33
ws/
4+
_output/

Makefile

+26-9
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,44 @@ GITKUBED_IMAGE ?= "$(IMAGE_REGISTRY)/$(GITKUBED_IMAGE_NAME)"
77
GITKUBED_DIR ?= "build/gitkubed"
88
SETUP_MANIFEST_FILE ?= "manifests/gitkube-setup.yaml"
99

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

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

1717
push-controller:
18-
docker push $(CONTROLLER_IMAGE):$(CONTROLLER_VERSION)
18+
docker push $(CONTROLLER_IMAGE):$(VERSION)
1919

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

2424
push-gitkubed:
25-
docker push $(GITKUBED_IMAGE):$(GITKUBED_VERSION)
25+
docker push $(GITKUBED_IMAGE):$(VERSION)
2626

2727
build-all: build-controller build-gitkubed
2828
push-all: push-controller push-gitkubed
2929

3030
controller: build-controller push-controller
3131
gitkubed: build-gitkubed push-gitkubed
3232

33-
all: build-all push-all
33+
# build cli locally, for all given platform/arch
34+
build-cli:
35+
go get github.com/mitchellh/gox
36+
gox -ldflags "-X github.com/hasura/gitkube/pkg/cmd.version=$(VERSION)" \
37+
-os="linux darwin windows" \
38+
-arch="amd64" \
39+
-output="_output/$(VERSION)/gitkube_{{.OS}}_{{.Arch}}" \
40+
./cmd/gitkube-cli/
41+
42+
# build cli inside a docker container
43+
build-cli-in-docker:
44+
docker build -t gitkube-cli-builder -f build/cli-builder.dockerfile build
45+
docker run --rm -it \
46+
-v $(PWD):/go/src/github.com/hasura/gitkube \
47+
gitkube-cli-builder \
48+
make build-cli
49+
50+
all: build-all push-all build-cli-in-docker

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,29 @@ Gitkube will run on any Kubernetes vendor/distribution AS IS. In case you find a
2929

3030
#### Install gitkube
3131

32+
##### Using kubectl
33+
3234
```sh
3335
kubectl create -f https://storage.googleapis.com/gitkube/gitkube-setup-stable.yaml
3436

3537
#expose gitkubed service
3638
kubectl --namespace kube-system expose deployment gitkubed --type=LoadBalancer --name=gitkubed
3739
```
3840

41+
##### Using gitkube CLI
42+
43+
1. Install Gitkube CLI:
44+
- Linux/MacOS
45+
``` bash
46+
curl https://raw.githubusercontent.com/hasura/gitkube/master/gimme.sh | bash
47+
```
48+
- Windows: download the latest [release](https://github.com/hasura/gitkube/releases) and add it to your `PATH`.
49+
50+
2. Use Gitkube CLI to install Gitkube on the cluster:
51+
```bash
52+
gitkube install
53+
```
54+
3955
#### Provider walkthroughs
4056

4157
The above installation steps work on most Kubernetes clusters. Detailed walkthroughs for few specific providers are also available:

build/cli-builder.dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM golang:1.10
2+
3+
# install gox
4+
RUN go get github.com/mitchellh/gox
5+
6+
# setup the working directory
7+
WORKDIR /go/src/github.com/hasura/gitkube

cmd/gitkube-cli/main.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// A CLI tool to install and manage Gitkube and associated remotes on a
2+
// Kubernetes cluster.
3+
package main
4+
5+
import (
6+
"github.com/hasura/gitkube/pkg/cmd"
7+
log "github.com/sirupsen/logrus"
8+
)
9+
10+
// main is the entrypoint function
11+
func main() {
12+
err := cmd.Execute()
13+
if err != nil {
14+
log.Fatal(err)
15+
}
16+
}

docs/cli/gitkube.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## gitkube
2+
3+
Build and deploy docker images to Kubernetes using git push
4+
5+
### Synopsis
6+
7+
Install Gitkube and manage its Remotes on a Kubernetes cluster
8+
9+
### Examples
10+
11+
```
12+
# Get your application running on Kubernetes in 4 simple steps.
13+
14+
# Step 1: Install Gitkube on a Kubernetes cluster:
15+
gitkube install
16+
17+
# Step 2: Generate a Gitkube Remote spec interactively and save it as 'example-remote.yaml':
18+
gitkube remote generate -f example-remote.yaml
19+
20+
# Step 3: Create a Remote defined in 'example-remote.yaml' on the cluster:
21+
gitkube remote create -f example-remote.yaml
22+
# outputs the remote url
23+
24+
# Step 4: Add remote to the git repo and push:
25+
git remote add example <remote_url>
26+
git push example master
27+
```
28+
29+
### Options
30+
31+
```
32+
-h, --help help for gitkube
33+
--kube-context string kubernetes context to use
34+
```
35+
36+
### SEE ALSO
37+
38+
* [gitkube install](gitkube_install.md) - Install Gitkube on a Kubernetes cluster
39+
* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster
40+
* [gitkube uninstall](gitkube_uninstall.md) - Uninstall Gitkube components from a cluster
41+
* [gitkube version](gitkube_version.md) - Output the cli version
42+
43+
###### Auto generated by spf13/cobra on 26-May-2018

docs/cli/gitkube_install.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## gitkube install
2+
3+
Install Gitkube on a Kubernetes cluster
4+
5+
### Synopsis
6+
7+
Install all Gitkube components on the cluster and expose the gitkubed deployment
8+
9+
```
10+
gitkube install [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# Install Gitkube in 'kube-system' namespace:
17+
gitkube install
18+
19+
# Install in another namespace:
20+
gitkube install --namespace <your-namespace>
21+
22+
# The command prompts for a ServiceType to expose gitkubed deployment.
23+
# Use '--expose' flag to set a ServiceType and skip the prompt
24+
# Say, 'LoadBalancer':
25+
gitkube install --expose LoadBalancer
26+
```
27+
28+
### Options
29+
30+
```
31+
-e, --expose string k8s service type to expose the gitkubed deployment
32+
-h, --help help for install
33+
-n, --namespace string namespace to create install gitkube resources in (default "kube-system")
34+
```
35+
36+
### Options inherited from parent commands
37+
38+
```
39+
--kube-context string kubernetes context to use
40+
```
41+
42+
### SEE ALSO
43+
44+
* [gitkube](gitkube.md) - Build and deploy docker images to Kubernetes using git push
45+
46+
###### Auto generated by spf13/cobra on 26-May-2018

docs/cli/gitkube_remote.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## gitkube remote
2+
3+
Manage Gitkube Remotes on a cluster
4+
5+
### Synopsis
6+
7+
Manage Gitkube Remotes on a cluster
8+
9+
### Options
10+
11+
```
12+
-h, --help help for remote
13+
```
14+
15+
### Options inherited from parent commands
16+
17+
```
18+
--kube-context string kubernetes context to use
19+
```
20+
21+
### SEE ALSO
22+
23+
* [gitkube](gitkube.md) - Build and deploy docker images to Kubernetes using git push
24+
* [gitkube remote create](gitkube_remote_create.md) - Create Remote for enabling git-push, from a spec file
25+
* [gitkube remote delete](gitkube_remote_delete.md) - Delete a Remote from the cluster
26+
* [gitkube remote generate](gitkube_remote_generate.md) - Generate a Remote spec in an interactive manner
27+
* [gitkube remote list](gitkube_remote_list.md) - List Remotes
28+
29+
###### Auto generated by spf13/cobra on 26-May-2018

docs/cli/gitkube_remote_create.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## gitkube remote create
2+
3+
Create Remote for enabling git-push, from a spec file
4+
5+
### Synopsis
6+
7+
Create Remote for enabling git-push, from a spec file
8+
9+
```
10+
gitkube remote create [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# Create a remote by reading 'example-remote.yaml':
17+
gitkube create -f example-remote.yaml
18+
```
19+
20+
### Options
21+
22+
```
23+
-f, --file string spec file
24+
-h, --help help for create
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
--kube-context string kubernetes context to use
31+
```
32+
33+
### SEE ALSO
34+
35+
* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster
36+
37+
###### Auto generated by spf13/cobra on 26-May-2018

docs/cli/gitkube_remote_delete.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## gitkube remote delete
2+
3+
Delete a Remote from the cluster
4+
5+
### Synopsis
6+
7+
Delete a Gitkube remote from the cluster
8+
9+
```
10+
gitkube remote delete [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# Delete remote called 'example':
17+
gitkube remote delete example
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help help for delete
24+
-n, --namespace string namespace of the remote (default "default")
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
--kube-context string kubernetes context to use
31+
```
32+
33+
### SEE ALSO
34+
35+
* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster
36+
37+
###### Auto generated by spf13/cobra on 26-May-2018

docs/cli/gitkube_remote_generate.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## gitkube remote generate
2+
3+
Generate a Remote spec in an interactive manner
4+
5+
### Synopsis
6+
7+
An interactive prompt-driven approach to generate Remote spec, rather than writing yaml by hand
8+
9+
```
10+
gitkube remote generate [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# Generate a remote and save it as 'example-remote.yaml':
17+
gitkube remote generate -f example-remote.yaml
18+
19+
# Shows interactive prompts to type-in/select options.
20+
# Contacts the cluster to create docker registry secret (if provided)
21+
```
22+
23+
### Options
24+
25+
```
26+
-h, --help help for generate
27+
-o, --output string file format to output, supports yaml and json (default "yaml")
28+
-f, --output-file string write generated spec to this file
29+
```
30+
31+
### Options inherited from parent commands
32+
33+
```
34+
--kube-context string kubernetes context to use
35+
```
36+
37+
### SEE ALSO
38+
39+
* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster
40+
41+
###### Auto generated by spf13/cobra on 26-May-2018

docs/cli/gitkube_remote_list.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## gitkube remote list
2+
3+
List Remotes
4+
5+
### Synopsis
6+
7+
List Gitkube Remotes on a cluster
8+
9+
```
10+
gitkube remote list [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# List all remotes:
17+
gitkube remote list
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help help for list
24+
-n, --namespace string namespace for listing (default "default")
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
--kube-context string kubernetes context to use
31+
```
32+
33+
### SEE ALSO
34+
35+
* [gitkube remote](gitkube_remote.md) - Manage Gitkube Remotes on a cluster
36+
37+
###### Auto generated by spf13/cobra on 26-May-2018

0 commit comments

Comments
 (0)