kplay 0.4.3 → 0.4.5

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: dc35b067b4f0dbb20c4e1a6dee5836e55bdb8ebdad15f904d016612841c3500c
4
- data.tar.gz: f836b8eee716c322689020b7d1082f265ce19e7a4b4615efbddb9beba7c6fb8d
3
+ metadata.gz: 448f93f598e3390c0357bf92d85f41dbb69bb8a83951c9b78c0e4a2d3227aab2
4
+ data.tar.gz: 16e8791c0594021303f0dd222af720dd59f933d247015d596b970b4d43e78a92
5
5
  SHA512:
6
- metadata.gz: 5cfcb34d4e73b017549ce8edcb3302b89be99aeeda981c30d315ace03fd269dbb93cad13de5d55ce5c6353c31100a57074e7b504cb0ec91438f556f06d2817f7
7
- data.tar.gz: 5c231acbd206b8cad4984645389b05b12eae73afa196e6807713b382aea59b9094bb1e6d22d69be85ab79a84cde45bc51c2a98caa816115fd0beba2b1f168efa
6
+ metadata.gz: 02c3b9b9207c935e4fdb38a318cdfb9f9f879c9066952d6201a2af508ce375bbf199219d6a5c64840ef46778a8bb82651b611659852eb64993c331fac3fbd6e2
7
+ data.tar.gz: 221f485fcbff701b9c5bac451faeda8b3bcfdd2dc3b98eaa4c3f2991ddf93170fd7492c545751a63f33fff58209b25e07ba27b505cff3b14b65fb60a0f374cc5
data/README.md CHANGED
@@ -1,38 +1,164 @@
1
- # Kplay
1
+ # kplay
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/kplay`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Run your project in a container inside a `minikube` k8s cluster.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+
6
+ ## Prerequisites
7
+
8
+ To use `kplay` you need to have the following set up on your machine:
9
+
10
+ * Ruby 2.7+
11
+ * [minikube](https://minikube.sigs.k8s.io/docs/)
12
+ * Docker image(s) with your development environment,
13
+ e.g. [like this one](https://github.com/kukushkin/devenv/tree/master/images/dev)
6
14
 
7
15
  ## Installation
8
16
 
9
- Add this line to your application's Gemfile:
17
+ Install `kplay` gem for your user only:
18
+
19
+ ```bash
20
+ gem i kplay
21
+ ```
22
+
23
+ Or system-wide:
24
+ ```bash
25
+ sudo gem i kplay
26
+ ```
27
+
28
+ ## How to use
29
+
30
+
31
+ Run `kplay help` to list all available commands:
32
+ ```bash
33
+ $ kplay help
10
34
 
11
- ```ruby
12
- gem 'kplay'
35
+ Commands:
36
+ kplay config # Displays local configuration
37
+ kplay help [COMMAND] # Describe available commands or one specific command
38
+ kplay info # Displays environment info
39
+ kplay open # Opens a shell session into the container
40
+ kplay play # (default) Starts the container and opens a shell session into it
41
+ kplay pod_config # Displays the pod config
42
+ kplay start # Starts a container (pod) with the local folder mounted inside
43
+ kplay status # Displays the cluster and container (pod) status
44
+ kplay stop # Stops the container (pod) associated with the local folder
45
+
46
+ Options:
47
+ v, [--verbose], [--no-verbose]
48
+
49
+ ```
50
+
51
+ ### `kplay play` or `kplay` (with no arguments)
52
+
53
+ Starts a development container, mounts your project in it
54
+ and opens a shell into it.
55
+
56
+ Change to your projects directory on your machine and run `kplay` with no arguments:
57
+
58
+ ```bash
59
+ username:~ $ cd projects/hello
60
+ username:hello $ kplay
61
+ pod/hello configured
62
+ hello:/hello $
13
63
  ```
14
64
 
15
- And then execute:
65
+ This runs a container using `dev` as the default name of the development
66
+ Docker image. You can pass an argument to use a different Docker image:
16
67
 
17
- $ bundle
68
+ ```bash
69
+ kplay -i my-dev-image
70
+ ```
18
71
 
19
- Or install it yourself as:
72
+ When you exit the shell, the container is automatically stopped.
20
73
 
21
- $ gem install kplay
74
+ ### `kplay start` and `kplay open`
22
75
 
23
- ## Usage
76
+ The default behaviour (`kplay play`) opens a shell for you, but after your exit it the container is automatically stopped. This can be a limitation: you may want to keep the container running or you may need to open more than one shell into that container.
24
77
 
25
- TODO: Write usage instructions here
78
+ In this case you can separately start the container in a "detached" mode:
26
79
 
27
- ## Development
80
+ ```bash
81
+ username:~ $ cd projects/hello
82
+ username:hello $ kplay start
83
+ pod/hello configured
84
+ username:hello $
85
+ ```
28
86
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
87
+ The container should be running now, which you can verify by listing the k8s pods:
30
88
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
89
+ ```bash
90
+ username:hello $ kubectl get pods
91
+ NAME READY STATUS RESTARTS AGE
92
+ hello 1/1 Running 0 9s
93
+ ```
32
94
 
33
- ## Contributing
95
+ Now to open a shell into it, run `kplay open` from the project folder:
34
96
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kplay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
97
+ ```bash
98
+ username:hello $ kplay open
99
+ hello:hello $
100
+ ```
101
+
102
+ This way you can open several sessions into the same container!
103
+ Simply run `kplay open` from the project folder in a different terminal
104
+ window or tab.
105
+
106
+ When you exit the shell in the container, it will still keep running.
107
+ If you are done with it, you will need to stop the container explicitly
108
+ by running `kplay stop` from your project folder:
109
+
110
+ ```bash
111
+ username:hello $ kplay stop
112
+ pod "hello" deleted
113
+ username:hello $
114
+ ```
115
+
116
+ ## Configuration
117
+
118
+ You can pass some parameters as arguments to `kplay` commands, but much
119
+ more convenient is to configure the global or project specific defaults.
120
+
121
+ `kplay` looks for the configuration files in:
122
+ * `~/.kplay/config` for global defaults
123
+ * `.kplay` in the local (current) folder for project-specific defaults
124
+
125
+ Settings in the `.kplay` in the local folder supercede the settings
126
+ found the global config file.
127
+
128
+ Each `kplay` configuration file is a YAML document with the following
129
+ structure:
130
+
131
+ ```yaml=
132
+
133
+ # Name of the Docker image to use for the development container
134
+ image: ruby-dev
135
+
136
+ # Path inside the container where the project folder is going to be mounted
137
+ mount_path: "/${name}"
138
+
139
+ # Size of the shared memory volume (/dev/shm) inside the container
140
+ shm_size: 64Mi
141
+
142
+ # Command and its args to run inside the container
143
+ # when opening a shell into it
144
+ shell: "/bin/bash"
145
+ shell_args:
146
+ - "-c"
147
+ - cd /${name}; exec "${SHELL:-sh}"
148
+
149
+ # Grace period (seconds) to respect when stopping containers
150
+ stop_grace_period: 15
151
+
152
+ # Custom entries to add to the /etc/hosts file inside the container
153
+ etc_hosts:
154
+ - "1.1.1.1 test-host-alpha"
155
+ - "2.2.2.2 test-host-beta"
156
+
157
+ # Additional volumes/files to be mounted inside the container
158
+ volumes:
159
+ - "~/.ssh/id_rsa:/root/.ssh/id_rsa"
160
+ - "~/.gitconfig:/root/.gitconfig"
161
+ ```
36
162
 
37
163
 
38
164
  ## License
data/kplay.gemspec CHANGED
@@ -30,11 +30,11 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_dependency 'thor', '~> 0.20'
34
- spec.add_dependency 'rainbow', '~> 3.0'
33
+ spec.add_dependency 'thor' , '~> 1.2'
34
+ spec.add_dependency 'rainbow' , '~> 3.1'
35
35
 
36
- spec.add_development_dependency 'bundler', '~> 1.14'
37
- spec.add_development_dependency 'rake', '~> 12.0', '>= 12.3.3'
38
- spec.add_development_dependency 'rspec', '~> 3.0'
39
- spec.add_development_dependency 'pry', '~> 0.11'
36
+ spec.add_development_dependency 'bundler', '~> 2.4'
37
+ spec.add_development_dependency 'rake' , '~> 13.0'
38
+ spec.add_development_dependency 'rspec', '~> 3.12'
39
+ spec.add_development_dependency 'pry' # , '~> 0.11'
40
40
  end
data/lib/kplay/config.rb CHANGED
@@ -10,6 +10,7 @@ module Kplay
10
10
  GLOBAL_DEFAULTS = {
11
11
  'image' => 'dev',
12
12
  'mount_path' => '/${name}',
13
+ 'shm_size' => '64Mi',
13
14
  'shell' => '/bin/bash',
14
15
  'shell_args' => ['-c', 'cd /${name}; exec "${SHELL:-sh}"'],
15
16
  'stop_grace_period' => 5,
data/lib/kplay/pod.rb CHANGED
@@ -7,6 +7,9 @@ module Kplay
7
7
  # Pod represents a pod associated with a folder on a host machine
8
8
  #
9
9
  class Pod
10
+ DEFAULT_SHM_VOLUME_NAME = "pod-shm-volume"
11
+ DEFAULT_SHM_VOLUME_PATH = "/dev/shm"
12
+
10
13
  attr_reader :name, :config, :volume_name, :path_host, :path_vm, :mount_path, :options
11
14
 
12
15
  # Creates a Pod from a path on host
@@ -54,6 +57,7 @@ module Kplay
54
57
  ],
55
58
  'volumeMounts' => [
56
59
  { 'mountPath' => config[:mount_path], 'name' => volume_name },
60
+ { 'mountPath' => DEFAULT_SHM_VOLUME_PATH, 'name' => DEFAULT_SHM_VOLUME_NAME },
57
61
  # <-- ssh forwarding socket should be mounted a CONTAINER here
58
62
  ]
59
63
  }
@@ -62,6 +66,13 @@ module Kplay
62
66
  {
63
67
  'name' => volume_name,
64
68
  'hostPath' => { 'path' => path_vm.to_s }
69
+ },
70
+ {
71
+ 'name' => DEFAULT_SHM_VOLUME_NAME,
72
+ 'emptyDir' => {
73
+ 'medium' => 'Memory',
74
+ 'sizeLimit' => config[:shm_size]
75
+ }
65
76
  }
66
77
  # <-- ssh forwarding socket in VM mounted here
67
78
  ]
data/lib/kplay/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kplay
3
- VERSION = '0.4.3'.freeze
3
+ VERSION = "0.4.5".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kplay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kukushkin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,90 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.20'
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.20'
26
+ version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rainbow
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.14'
47
+ version: '2.4'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.14'
54
+ version: '2.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '12.0'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 12.3.3
61
+ version: '13.0'
65
62
  type: :development
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
66
  - - "~>"
70
67
  - !ruby/object:Gem::Version
71
- version: '12.0'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 12.3.3
68
+ version: '13.0'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: rspec
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
73
  - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: '3.0'
75
+ version: '3.12'
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '3.0'
82
+ version: '3.12'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: pry
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
87
+ - - ">="
94
88
  - !ruby/object:Gem::Version
95
- version: '0.11'
89
+ version: '0'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - "~>"
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
- version: '0.11'
96
+ version: '0'
103
97
  description: A tool to start a container in minikube and mount your project folder
104
98
  into it
105
99
  email:
@@ -135,7 +129,7 @@ licenses:
135
129
  - MIT
136
130
  metadata:
137
131
  allowed_push_host: https://rubygems.org
138
- post_install_message:
132
+ post_install_message:
139
133
  rdoc_options: []
140
134
  require_paths:
141
135
  - lib
@@ -150,8 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
144
  - !ruby/object:Gem::Version
151
145
  version: '0'
152
146
  requirements: []
153
- rubygems_version: 3.0.3
154
- signing_key:
147
+ rubygems_version: 3.4.10
148
+ signing_key:
155
149
  specification_version: 4
156
150
  summary: Starts your project within a container in minikube
157
151
  test_files: []