https://github.com/toshi0607/jctl
Build and execute Go applications with Kubernetes Job
https://github.com/toshi0607/jctl
client-go container-image container-registry docker-hub gcr go kubernetes kubernetes-job
Last synced: 4 months ago
JSON representation
Build and execute Go applications with Kubernetes Job
- Host: GitHub
- URL: https://github.com/toshi0607/jctl
- Owner: toshi0607
- License: mit
- Created: 2019-09-21T02:19:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T03:19:41.000Z (over 3 years ago)
- Last Synced: 2024-06-19T18:08:36.393Z (almost 2 years ago)
- Topics: client-go, container-image, container-registry, docker-hub, gcr, go, kubernetes, kubernetes-job
- Language: Go
- Size: 132 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
jctl
====
## Description
jctl (job-control) is a CLI to build and execute Go applications as Kubernetes Job by one command.
## VS.
### kubectl
[kubernetes/kubectl](https://github.com/kubernetes/kubectl) can control all the resources. It creates Job, of course. But, the Job uses already built container images. We have to build an application and a container image and then push it to our container registry.
### ko
[google/ko](https://github.com/google/ko) can build a Go application and container image, push it to registries, and kubectl apply. It make Dockerfile out of consciousness by using Go importpath. We write it in `spec.containers[].image` of a kubernetes manifest.
### jctl
[toshi0607/jctl](https://github.com/toshi0607/jctl) also specializes in Go application and utilize Go importpath. But, we can also remove manifest (only for Job). Write your small Go code and ship it to your cluster as Job!
## Requirement
Go application development environment
### Setup
Set environment variables
* container registry like toshi0607 (Docker Hub) or gcr.io/toshi0607 (Google Container Registry)
```shell script
$ export JCTL_DOCKER_REPO=[your repo]
```
* path to kubernetes config. same manner as kubectl. see also [Organizing Cluster Access Using kubeconfig Files](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
```shell script
$ export KUBECONFIG=[your kubernetes config]
```
* docker login
## Usage
```shell script
$ cd [path/to/your/application/project/root]
$ jctl ./testdata/cmd/hello_world
building image...
publishing image...
kubernetes: 2019/10/04 10:38:57 job created, name: jctl-jobxxxxx
kubernetes: 2019/10/04 10:39:00 job finished, name: jctl-jobxxxxx
# or you can use importpath
$ jctl github.com/toshi0607/jctl/testdata/cmd/hello_world
building image...
publishing image...
kubernetes: 2019/10/04 10:38:57 job created, name: jctl-jobyyyyy
kubernetes: 2019/10/04 10:39:00 job finished, name: jctl-jobyyyyy
# timeout option is available with -t or --timeout [seconds]
$ go run ./cmd/jctl/main.go ./testdata/cmd/long_hello_world -t 5
building image...
publishing image...
kubernetes: 2019/10/04 10:45:21 job created, name: jctl-jobd9l9b
kubernetes: 2019/10/04 10:45:21 job execution timeout name: jctl-jobzzzzz
job execution timeout: context deadline exceeded
exit status 1
```
## Install
Download the binary from [GitHub Releases](https://github.com/toshi0607/jctl/releases) and drop it in your `$PATH`
- [Darwin / Mac](https://github.com/toshi0607/jctl/releases/latest)
- [Linux](https://github.com/toshi0607/jctl/releases/latest)
## Licence
[MIT](LICENSE) file for details.
## Author
* [GitHub](https://github.com/toshi0607)
* [twitter](https://twitter.com/toshi0607)