activek8s 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cced9ad51fc24f2435e9b38833bbc5c991b63523db450701d7c80dd548669e7e
4
- data.tar.gz: 11f4f7296e0826865e57c5a86d61157d707b7662f63c8399583606460e8b74e8
3
+ metadata.gz: 1a5c465b6ebfde47bb5ac127401a2ea4fd741d1aea930ff96c6859e594d9ed86
4
+ data.tar.gz: ca0e3aff59ba3cb044c55bec7c044a5bbeaafb6244ba783f5b7ec84e817b76fc
5
5
  SHA512:
6
- metadata.gz: cd1a7680bc20702faf6334bdd50c85d0ae3c3cf23e4f0c89730e19c232ea114d3271fa7070932f87e184e326f4fa9f3c5f55bb2c760556205ba9703743c3ddb1
7
- data.tar.gz: 29696b79bc8487f13336cebfc73417e8aeff99a5f6c45b221de5fb2bf137a4359c6ff6cae9c25996e2657a7bc4eb2135d10e253816f37ef4f6ac4aecea69f409
6
+ metadata.gz: 2990b13ffe416d9218ed240425a3d654047189f4166a56fd7c77b4f7dcd856dc0403f42f007d75072ab61ac7f9a7414dc2b82da67e4f50157928ab262ac8507a
7
+ data.tar.gz: 2a12464f0fd071c2015e4f5ae1490c5889f83cf5f6d9325f00e439108705d309a3e16900a23a115c97ca693fd8452308d35a702820f98258b739e226209ceb75
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activek8s (0.3.0)
4
+ activek8s (0.4.0)
5
5
  childprocess (~> 1.0.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,28 +1,96 @@
1
1
  # Activek8s
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activek8s`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This gem provides a set of _Rake tasks for a convention based Kubernetes integration_. This means that by following some conventions you will be able to leverage some low level [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) commands using [Rake](https://github.com/ruby/rake).
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ These Rake tasks provide a set of high level customizable commands with sensible defaults. Not everyone in your teams has to be an expert in the Docker/Kubernetes/Ops area to interact with a Kubernetes cluster. __Activek8s__ can help teams working on any project, this isn't a Rails only solution (__not even a Ruby only solution__).
6
6
 
7
7
  ## Installation
8
8
 
9
+ $ gem install activek8s
10
+
11
+ ## Ruby/Rails project
12
+
9
13
  Add this line to your application's Gemfile:
10
14
 
11
15
  ```ruby
12
16
  gem 'activek8s'
13
17
  ```
14
18
 
15
- And then execute:
19
+ ## How it works
16
20
 
17
- $ bundle
21
+ This gem uses a directory named `kube` as a workspace for `deployment.yml`. This YAML file must contain a ConfigMap, Service and Deployment representing the current projects service to be deployed in a Kubernetes cluster. When managing a deployment in a Kubernetes cluster a very common command is `kubectl apply -f <config yml file>`.
18
22
 
19
- Or install it yourself as:
23
+ __Activek8s__ performs template-like text substitution on your `deployment.yml` to output a file named `last_deployment.yml`. This `last_deployment.yml` file is the one applied against the currently authenticated Kubernetes cluster (via kubectl). This text substitution is meant for container image name, container image tags and environment management (dev/staging/prod).
20
24
 
21
- $ gem install activek8s
25
+ ### Directory structure
26
+
27
+ ```
28
+ .
29
+ ├── Dockerfile
30
+ ├── kube
31
+ │   └── deployment.yml
32
+ ```
33
+
34
+ ### Things you'll need
35
+
36
+ 1. A Kubernetes cluster somewhere
37
+ 2. [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) authenticated to that cluster from #1 (if `kubectl get pods -n NAMESPACE` works you're good)
38
+ 3. A Dockerized project ready to be deployed on #1 or some other services already deployed to #1
39
+
40
+ ### Tasks
41
+
42
+ * ak8s:deploy
43
+ * Creates a `last_deployment.yml` from `deployment.yml` and applies the YAML specification on the currently authenticated Kubernetes cluster
44
+ * Ex: `kubectl apply -f kube/last_deployment.yml`
45
+ * ak8s:delete
46
+ * Creates a `last_deployment.yml` from `deployment.yml` and deletes the matching YAML specification on the currently authenticated Kubernetes cluster
47
+ * Ex: `kubectl delete -f kube/last_deployment.yml`
48
+ * ak8s:port_forward
49
+ * Port forwards all services defined in `.ak8s.yml`.
50
+ * Will create a file named `services.env` containing your service names and urls which you can source (i.e. `. services.env`)
51
+ * ak8s:port_forward_current
52
+ * Port forwards the current project's deployment in a certain namespace defined in `.ak8s.yml`.
53
+ * Ex: `kubectl port-forward {service} ...`
54
+
55
+ ## .ak8s.yml
56
+
57
+ This file lets you configure your port forwarding capabilities. Suppose an environment where you have 5 services deployed in a cluster. You would have something similar to the following:
58
+
59
+ ```
60
+ dev: # First level keys are namespaces in your cluster.
61
+ - name: webapp # Inside the list of services to forward the only
62
+ - name: backendwebapp # required field is 'name'.
63
+ - name: webapi
64
+ - name: analytics
65
+ - name: elasticsearch
66
+
67
+ staging:
68
+ - name: webapp
69
+ - name: backendwebapp
70
+ - name: webapi # You can specify the namespace of any service.
71
+ - name: analytics # This would cause the port forwarding to occur
72
+ namespace: logging # referencing the service deployed on a specific
73
+ - name: elasticsearch # namespace other than the first level key.
74
+
75
+ production:
76
+ - name: webapp
77
+ - name: backendwebapp
78
+ - name: webapi
79
+ - name: analytics # Target port specification allows you to pass in
80
+ target_port: 8080 # the target port of the service (not on the
81
+ - name: elasticsearch # localhost port where the service will be available
82
+ target_port: 9200
83
+
84
+ ak8s: # ak8s is where general config goes
85
+ first_port: 4200 # first_port lets you specify the first port where
86
+ # the multiple service port forwarding will start
87
+ ```
88
+
89
+ ### Port forwarding examples
22
90
 
23
- ## Usage
91
+ `rake ak8s:port_forward` will port forward all the services listed by name in the 'dev' namespace __because it was listed first__.
24
92
 
25
- TODO: Write usage instructions here
93
+ `rake ak8s:port_forward[staging]` will port forward all the services listed within the staging namespace. In this case the elasticsearch service will be port forwarded using the logging namespace, instead of using the default (which is the corresponding first level key, 'staging' in this case).
26
94
 
27
95
  ## Development
28
96
 
@@ -32,7 +100,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
100
 
33
101
  ## Contributing
34
102
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activek8s.
103
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fdoxyz/activek8s.
36
104
 
37
105
  ## License
38
106
 
@@ -1,3 +1,3 @@
1
1
  module Activek8s
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -11,7 +11,7 @@ namespace 'ak8s' do
11
11
 
12
12
  # Helper variables setup
13
13
  first_port = config.dig('ak8s', 'first_port') || 4200
14
- namespaced_services = config[args.namespace]['services']
14
+ namespaced_services = config[args.namespace]
15
15
  raise 'No services listed in .ak8s.yml' if namespaced_services.empty?
16
16
 
17
17
  # All services to port forward (an array of hashes)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activek8s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Valverde Arredondo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2019-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess