kube_cluster 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34f6c89109b79b6be8137a3997de13bb5b0fce1c1d6b4993c62a9b8c742b0124
4
- data.tar.gz: 2788eef6b86900c2e0abcb4a7d41630667da5509d6f8c3a29258e5e833aaf0e0
3
+ metadata.gz: ba5822593c1d3e5d110c57b02c484b0f21b3abe5d78a1d7ecfebfa53060b51e0
4
+ data.tar.gz: '079d271449f119800d0dcfab155fb4abdc12805d042a88b773c9916d7e797f88'
5
5
  SHA512:
6
- metadata.gz: fb9f12348b47e796dfd1d96cdc44200b600b062beee943d4343292f5546e5bd3d4bfa744b99df1eae3c6d5838530d0f4f796eae11746ac05154d0a488677efc7
7
- data.tar.gz: be495978b1494e1dd84343de7e1aca23056c3d1b2cba811d42cb8c7a7ce9f5b70d96fae1c055ad26e73c767cfcad4bb68be50e6b043e677fddef738166cbf320
6
+ metadata.gz: d8be0266b451508ba21453bf47afd68d2fc2a8e0f208c5e6e4e46a872bc2a7e4250ab2aa9040a7a9c715c6252cca9019717240d472c712a3da05082c30867653
7
+ data.tar.gz: 344e1a830c357cd2bbd5e0a30608ae7478c36ef85d6e43c1e7ab5ab26d67245d340d30cc1f48c3a9e1cd4f8729676752cd44ef97d200dd42a3c10fc0504696cf
@@ -0,0 +1,57 @@
1
+ name: Github Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages:
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ # Allow one concurrent deployment:
15
+ concurrency:
16
+ group: "pages"
17
+ cancel-in-progress: true
18
+
19
+ env:
20
+ BUNDLE_WITH: maintenance
21
+
22
+ jobs:
23
+ generate:
24
+ runs-on: ubuntu-latest
25
+
26
+ steps:
27
+ - uses: actions/checkout@v6
28
+
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ruby
32
+ bundler-cache: true
33
+
34
+ - name: Installing packages
35
+ run: sudo apt-get install wget
36
+
37
+ - name: Generate documentation
38
+ timeout-minutes: 5
39
+ run: bundle exec bake utopia:project:static --force no
40
+
41
+ - name: Upload documentation artifact
42
+ uses: actions/upload-pages-artifact@v4
43
+ with:
44
+ path: docs
45
+
46
+ deploy:
47
+ runs-on: ubuntu-latest
48
+
49
+ environment:
50
+ name: github-pages
51
+ url: ${{steps.deployment.outputs.page_url}}
52
+
53
+ needs: generate
54
+ steps:
55
+ - name: Deploy to GitHub Pages
56
+ id: deployment
57
+ uses: actions/deploy-pages@v4
data/Gemfile CHANGED
@@ -3,3 +3,10 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ group :maintenance, optional: true do
8
+ gem "utopia-project"
9
+ gem "bake-gem"
10
+ gem "bake-modernize"
11
+ gem "bake-releases"
12
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kube_cluster (0.4.4)
4
+ kube_cluster (0.4.6)
5
5
  kube_kubectl (~> 2.0.9)
6
6
  kube_schema (~> 1.4.3)
7
7
  scampi (~> 0.1)
@@ -10,17 +10,97 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ast (2.4.3)
13
+ async (2.39.0)
14
+ console (~> 1.29)
15
+ fiber-annotation
16
+ io-event (~> 1.11)
17
+ metrics (~> 0.12)
18
+ traces (~> 0.18)
19
+ async-container (0.34.5)
20
+ async (~> 2.22)
21
+ async-http (0.95.0)
22
+ async (>= 2.10.2)
23
+ async-pool (~> 0.11)
24
+ io-endpoint (~> 0.14)
25
+ io-stream (~> 0.6)
26
+ metrics (~> 0.12)
27
+ protocol-http (~> 0.62)
28
+ protocol-http1 (~> 0.39)
29
+ protocol-http2 (~> 0.26)
30
+ protocol-url (~> 0.2)
31
+ traces (~> 0.10)
32
+ async-http-cache (0.4.6)
33
+ async-http (~> 0.56)
34
+ async-ollama (0.10.3)
35
+ async
36
+ async-rest
37
+ async-pool (0.11.2)
38
+ async (>= 2.0)
39
+ async-rest (0.20.0)
40
+ async-http (~> 0.42)
41
+ protocol-url (~> 0.2)
42
+ async-service (0.22.0)
43
+ async
44
+ async-container (~> 0.34)
45
+ string-format (~> 0.2)
46
+ async-utilization (0.3.2)
47
+ console (~> 1.0)
48
+ bake (0.24.1)
49
+ bigdecimal
50
+ samovar (~> 2.1)
51
+ bake-gem (0.13.1)
52
+ console (~> 1.25)
53
+ bake-modernize (0.54.1)
54
+ async-http
55
+ async-ollama (~> 0.10)
56
+ bake
57
+ build-files (~> 1.6)
58
+ markly (~> 0.13)
59
+ rugged
60
+ bake-releases (0.5.4)
61
+ bake (~> 0.21)
62
+ markly (~> 0.8)
13
63
  bigdecimal (4.1.2)
64
+ build-files (1.10.2)
14
65
  colorize (1.1.0)
15
66
  colorize-extended (0.1.0)
16
67
  colorize (~> 1.1)
68
+ concurrent-ruby (1.3.6)
69
+ console (1.34.3)
70
+ fiber-annotation
71
+ fiber-local (~> 1.1)
72
+ json
17
73
  date (3.5.1)
18
74
  debug (1.11.1)
19
75
  irb (~> 1.10)
20
76
  reline (>= 0.3.8)
77
+ decode (0.27.0)
78
+ prism
79
+ rbs
21
80
  erb (6.0.4)
81
+ falcon (0.55.3)
82
+ async
83
+ async-container (~> 0.20)
84
+ async-http (~> 0.75)
85
+ async-http-cache (~> 0.4)
86
+ async-service (~> 0.19)
87
+ async-utilization (~> 0.3)
88
+ bundler
89
+ localhost (~> 1.1)
90
+ openssl (>= 3.0)
91
+ protocol-http (~> 0.31)
92
+ protocol-rack (~> 0.7)
93
+ samovar (~> 2.3)
94
+ fiber-annotation (0.2.0)
95
+ fiber-local (1.1.0)
96
+ fiber-storage
97
+ fiber-storage (1.0.1)
22
98
  hana (1.3.7)
99
+ http-accept (2.2.1)
23
100
  io-console (0.8.2)
101
+ io-endpoint (0.17.2)
102
+ io-event (1.15.1)
103
+ io-stream (0.13.0)
24
104
  irb (1.18.0)
25
105
  pp (>= 0.6.0)
26
106
  prism (>= 1.3.0)
@@ -43,6 +123,33 @@ GEM
43
123
  rubyshell (~> 1.5.0)
44
124
  language_server-protocol (3.17.0.5)
45
125
  lint_roller (1.1.0)
126
+ localhost (1.7.0)
127
+ logger (1.7.0)
128
+ mail (2.9.0)
129
+ logger
130
+ mini_mime (>= 0.1.1)
131
+ net-imap
132
+ net-pop
133
+ net-smtp
134
+ mapping (1.1.3)
135
+ markly (0.16.0)
136
+ metrics (0.15.0)
137
+ mime-types (3.7.0)
138
+ logger
139
+ mime-types-data (~> 3.2025, >= 3.2025.0507)
140
+ mime-types-data (3.2026.0414)
141
+ mini_mime (1.1.5)
142
+ msgpack (1.8.0)
143
+ net-imap (0.6.4)
144
+ date
145
+ net-protocol
146
+ net-pop (0.1.2)
147
+ net-protocol
148
+ net-protocol (0.2.2)
149
+ timeout
150
+ net-smtp (0.5.1)
151
+ net-protocol
152
+ openssl (4.0.1)
46
153
  parallel (2.1.0)
47
154
  parser (3.3.11.1)
48
155
  ast (~> 2.4.1)
@@ -51,12 +158,33 @@ GEM
51
158
  prettyprint
52
159
  prettyprint (0.2.0)
53
160
  prism (1.9.0)
161
+ protocol-hpack (1.5.1)
162
+ protocol-http (0.62.2)
163
+ protocol-http1 (0.39.0)
164
+ protocol-http (~> 0.62)
165
+ protocol-http2 (0.26.0)
166
+ protocol-hpack (~> 1.4)
167
+ protocol-http (~> 0.62)
168
+ protocol-rack (0.22.1)
169
+ io-stream (>= 0.10)
170
+ protocol-http (~> 0.58)
171
+ rack (>= 1.0)
172
+ protocol-url (0.4.0)
54
173
  psych (5.3.1)
55
174
  date
56
175
  stringio
57
176
  racc (1.8.1)
177
+ rack (3.2.6)
178
+ rackula (1.4.1)
179
+ falcon (~> 0.46)
180
+ samovar (~> 2.1)
181
+ variant
58
182
  rainbow (3.1.1)
59
183
  rake (13.4.2)
184
+ rbs (4.0.2)
185
+ logger
186
+ prism (>= 1.6.0)
187
+ tsort
60
188
  rdoc (7.2.0)
61
189
  erb
62
190
  psych (>= 4.0.0)
@@ -80,25 +208,63 @@ GEM
80
208
  prism (~> 1.7)
81
209
  ruby-progressbar (1.13.0)
82
210
  rubyshell (1.5.0)
211
+ rugged (1.9.0)
212
+ samovar (2.4.1)
213
+ console (~> 1.0)
214
+ mapping (~> 1.0)
83
215
  scampi (0.1.7)
84
216
  colorize-extended
85
217
  shellwords (0.2.2)
86
218
  simpleidn (0.2.3)
219
+ string-format (0.2.0)
87
220
  string_builder (1.2.4)
88
221
  stringio (3.2.0)
222
+ thread-local (1.1.0)
223
+ timeout (0.6.1)
224
+ traces (0.18.2)
89
225
  tsort (0.2.0)
90
226
  unicode-display_width (3.2.0)
91
227
  unicode-emoji (~> 4.1)
92
228
  unicode-emoji (4.2.0)
229
+ utopia (2.32.1)
230
+ bake (~> 0.20)
231
+ concurrent-ruby (~> 1.2)
232
+ console (~> 1.24)
233
+ http-accept (~> 2.1)
234
+ irb
235
+ mail (~> 2.6)
236
+ mime-types (~> 3.0)
237
+ msgpack
238
+ net-smtp
239
+ protocol-url (~> 0.4)
240
+ rack (~> 3.0)
241
+ samovar (~> 2.1)
242
+ traces (~> 0.10)
243
+ variant (~> 0.1)
244
+ xrb (~> 0.4)
245
+ utopia-project (0.40.0)
246
+ decode (~> 0.26)
247
+ falcon
248
+ markly (~> 0.15)
249
+ rackula (~> 1.3)
250
+ thread-local
251
+ utopia (~> 2.32)
252
+ variant (0.1.1)
253
+ thread-local
254
+ xrb (0.11.2)
93
255
 
94
256
  PLATFORMS
95
257
  ruby
96
258
  x86_64-linux
97
259
 
98
260
  DEPENDENCIES
261
+ bake-gem
262
+ bake-modernize
263
+ bake-releases
99
264
  kube_cluster!
100
265
  rake (~> 13.0)
101
266
  rubocop (~> 1.21)
267
+ utopia-project
102
268
 
103
269
  BUNDLED WITH
104
270
  2.6.9
@@ -0,0 +1,26 @@
1
+ # Custom Resource Definitions
2
+
3
+ This guide covers registering CRDs from Helm charts as first-class resources.
4
+
5
+ ## Registering CRDs
6
+
7
+ ```ruby
8
+ chart = Kube::Helm::Repo.new("jetstack", url: "https://charts.jetstack.io")
9
+ .fetch("cert-manager", version: "1.17.2")
10
+
11
+ chart.crds.each { |crd|
12
+ s = crd.to_json_schema
13
+ Kube::Schema.register(s[:kind], schema: s[:schema], api_version: s[:api_version])
14
+ }
15
+ ```
16
+
17
+ ## Using Registered CRDs
18
+
19
+ Once registered, CRDs work like any built-in resource:
20
+
21
+ ```ruby
22
+ issuer = Kube::Cluster["ClusterIssuer"].new {
23
+ metadata.name = "letsencrypt"
24
+ spec.acme.server = "https://acme-v02.api.letsencrypt.org/directory"
25
+ }
26
+ ```
@@ -0,0 +1,25 @@
1
+ # Dirty Tracking
2
+
3
+ This guide covers dirty tracking and patching for resources connected to a live cluster.
4
+
5
+ ## Connecting to a Cluster
6
+
7
+ ```ruby
8
+ cluster = Kube::Cluster.connect(kubeconfig: "~/.kube/config")
9
+ ```
10
+
11
+ ## Creating and Patching Resources
12
+
13
+ ```ruby
14
+ config = Kube::Cluster["ConfigMap"].new(cluster:) {
15
+ metadata.name = "app-config"
16
+ self.data = { version: "1" }
17
+ }
18
+
19
+ config.apply # creates on cluster
20
+ config.data.version = "2"
21
+ config.changed? # => true
22
+ config.patch # sends only { data: { version: "2" } }
23
+ ```
24
+
25
+ Changes are tracked automatically. When you call `patch`, only the modified fields are sent to the cluster.
@@ -0,0 +1,36 @@
1
+ # Getting Started
2
+
3
+ This guide walks you through installing kube_cluster and defining your first Kubernetes resource in Ruby.
4
+
5
+ ## Install
6
+
7
+ ```ruby
8
+ gem "kube_cluster", "~> 0.3"
9
+ ```
10
+
11
+ ## Define a Resource
12
+
13
+ ```ruby
14
+ pod = Kube::Cluster["Pod"].new {
15
+ metadata.name = "redis"
16
+ spec.containers = [{ name: "redis", image: "redis:8" }]
17
+ }
18
+
19
+ puts pod.to_yaml
20
+ ```
21
+
22
+ ## Subclass for Reuse
23
+
24
+ ```ruby
25
+ class RedisPod < Kube::Cluster["Pod"]
26
+ def initialize(&block)
27
+ super {
28
+ metadata.name = "redis"
29
+ spec.containers = [{ name: "redis", image: "redis:8", ports: [{ containerPort: 6379 }] }]
30
+ }
31
+ instance_exec(&block) if block_given?
32
+ end
33
+ end
34
+
35
+ puts RedisPod.new { metadata.namespace = "production" }.to_yaml
36
+ ```
@@ -0,0 +1,16 @@
1
+ # Helm Charts
2
+
3
+ This guide covers loading Helm charts as kube_cluster manifests.
4
+
5
+ ## Loading a Chart
6
+
7
+ ```ruby
8
+ manifest = Kube::Helm::Repo
9
+ .new("bitnami", url: "https://charts.bitnami.com/bitnami")
10
+ .fetch("nginx", version: "18.1.0")
11
+ .apply_values("replicaCount" => 3)
12
+
13
+ puts manifest.to_yaml
14
+ ```
15
+
16
+ Helm charts are fetched, templated, and returned as standard kube_cluster manifests. You can then apply middleware, modify resources, or deploy them.
data/guides/links.yaml ADDED
@@ -0,0 +1,12 @@
1
+ getting-started:
2
+ order: 1
3
+ resources:
4
+ order: 2
5
+ middleware:
6
+ order: 3
7
+ dirty-tracking:
8
+ order: 4
9
+ helm-charts:
10
+ order: 5
11
+ crds:
12
+ order: 6
@@ -0,0 +1,49 @@
1
+ # Middleware
2
+
3
+ This guide covers the middleware stack that transforms a single Deployment declaration into a fully-configured stack.
4
+
5
+ ## The Middleware Stack
6
+
7
+ ```ruby
8
+ manifest = Kube::Cluster::Manifest.new(
9
+ Kube::Cluster["Deployment"].new {
10
+ metadata.name = "web"
11
+ metadata.labels = {
12
+ "app.kubernetes.io/expose": "app.example.com",
13
+ "app.kubernetes.io/autoscale": "2-10",
14
+ "app.kubernetes.io/size": "small"
15
+ }
16
+ spec.selector.matchLabels = { app: "web" }
17
+ spec.template.spec.containers = [
18
+ { name: "web", image: "nginx", ports: [{ name: "http", containerPort: 8080 }] }
19
+ ]
20
+ }
21
+ )
22
+
23
+ Kube::Cluster::Middleware::Stack.new {
24
+ use Middleware::ServiceForDeployment
25
+ use Middleware::IngressForService
26
+ use Middleware::HPAForDeployment
27
+ use Middleware::Namespace, "production"
28
+ use Middleware::Labels, managed_by: "kube_cluster"
29
+ use Middleware::ResourcePreset
30
+ use Middleware::SecurityContext
31
+ use Middleware::PodAntiAffinity
32
+ }.call(manifest)
33
+
34
+ puts manifest.to_yaml # => Deployment, Service, Ingress, HPA -- all configured
35
+ ```
36
+
37
+ ## Available Middleware
38
+
39
+ | Middleware | Effect |
40
+ |---|---|
41
+ | `Namespace` | Sets `metadata.namespace` on all resources |
42
+ | `Labels` | Merges standard Kubernetes labels |
43
+ | `Annotations` | Merges annotations |
44
+ | `ResourcePreset` | Injects CPU/memory from `app.kubernetes.io/size` (nano to 2xlarge) |
45
+ | `SecurityContext` | Injects restricted/baseline security contexts |
46
+ | `PodAntiAffinity` | Spreads pods across nodes |
47
+ | `ServiceForDeployment` | Generates Service from named container ports |
48
+ | `IngressForService` | Generates Ingress from `app.kubernetes.io/expose` label |
49
+ | `HPAForDeployment` | Generates HPA from `app.kubernetes.io/autoscale` label |
@@ -0,0 +1,50 @@
1
+ # Resources
2
+
3
+ This guide covers defining and working with Kubernetes resources as Ruby objects.
4
+
5
+ ## Defining Resources
6
+
7
+ Every Kubernetes kind is accessible by name:
8
+
9
+ ```ruby
10
+ pod = Kube::Cluster["Pod"].new {
11
+ metadata.name = "redis"
12
+ spec.containers = [{ name: "redis", image: "redis:8" }]
13
+ }
14
+ ```
15
+
16
+ ## Subclassing
17
+
18
+ Create reusable resource templates by subclassing:
19
+
20
+ ```ruby
21
+ class RedisPod < Kube::Cluster["Pod"]
22
+ def initialize(&block)
23
+ super {
24
+ metadata.name = "redis"
25
+ spec.containers = [{ name: "redis", image: "redis:8", ports: [{ containerPort: 6379 }] }]
26
+ }
27
+ instance_exec(&block) if block_given?
28
+ end
29
+ end
30
+
31
+ puts RedisPod.new { metadata.namespace = "production" }.to_yaml
32
+ ```
33
+
34
+ ## Manifests
35
+
36
+ Group resources into multi-document YAML using manifests:
37
+
38
+ ```ruby
39
+ manifest = Kube::Cluster::Manifest.new(
40
+ Kube::Cluster["Deployment"].new {
41
+ metadata.name = "web"
42
+ spec.selector.matchLabels = { app: "web" }
43
+ spec.template.spec.containers = [
44
+ { name: "web", image: "nginx", ports: [{ name: "http", containerPort: 8080 }] }
45
+ ]
46
+ }
47
+ )
48
+
49
+ puts manifest.to_yaml
50
+ ```
data/kube_cluster.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.metadata["homepage_uri"] = spec.homepage
22
22
  spec.metadata["source_code_uri"] = spec.homepage
23
- spec.metadata["documentation_uri"] = spec.homepage
23
+ spec.metadata["documentation_uri"] = "https://general-intelligence-systems.github.io/kube_cluster/"
24
24
  spec.metadata["rubygems_mfa_required"] = "true"
25
25
 
26
26
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -51,8 +51,8 @@ module Kube
51
51
  end
52
52
 
53
53
  # Build a new resource of the same schema subclass from a hash.
54
- def rebuild(hash)
55
- self.class.new(hash)
54
+ def rebuild(hash = {})
55
+ self.class.new(**hash)
56
56
  end
57
57
 
58
58
  # Read a label value from the resource.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kube
4
4
  module Cluster
5
- VERSION = "0.4.4"
5
+ VERSION = "0.4.6"
6
6
  end
7
7
  end
data/readme.md ADDED
@@ -0,0 +1,27 @@
1
+ # kube_cluster
2
+
3
+ Ruby-native Kubernetes. Define, transform, and deploy cluster resources with pure Ruby.
4
+
5
+ ## Usage
6
+
7
+ Please see the [project documentation](https://general-intelligence-systems.github.io/kube_cluster/) for more details.
8
+
9
+ - [Getting Started](https://general-intelligence-systems.github.io/kube_cluster/guides/getting-started/index) - This guide walks you through installing kube_cluster and defining your first Kubernetes resource in Ruby.
10
+
11
+ - [Resources](https://general-intelligence-systems.github.io/kube_cluster/guides/resources/index) - This guide covers defining and working with Kubernetes resources as Ruby objects.
12
+
13
+ - [Middleware](https://general-intelligence-systems.github.io/kube_cluster/guides/middleware/index) - This guide covers the middleware stack that transforms a single Deployment declaration into a fully-configured stack.
14
+
15
+ - [Dirty Tracking](https://general-intelligence-systems.github.io/kube_cluster/guides/dirty-tracking/index) - This guide covers dirty tracking and patching for resources connected to a live cluster.
16
+
17
+ - [Helm Charts](https://general-intelligence-systems.github.io/kube_cluster/guides/helm-charts/index) - This guide covers loading Helm charts as kube_cluster manifests.
18
+
19
+ - [Custom Resource Definitions](https://general-intelligence-systems.github.io/kube_cluster/guides/crds/index) - This guide covers registering CRDs from Helm charts as first-class resources.
20
+
21
+ ## See Also
22
+
23
+ - [Examples directory](https://github.com/general-intelligence-systems/kube_cluster/tree/main/examples)
24
+
25
+ ## License
26
+
27
+ Apache-2.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K
@@ -90,6 +90,7 @@ extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
92
  - ".envrc"
93
+ - ".github/workflows/gh-pages.yml"
93
94
  - ".github/workflows/release.yml"
94
95
  - ".github/workflows/tag-gem-version-bump.yml"
95
96
  - ".github/workflows/test.yaml"
@@ -98,7 +99,6 @@ files:
98
99
  - Gemfile
99
100
  - Gemfile.lock
100
101
  - LICENSE
101
- - README.md
102
102
  - Rakefile
103
103
  - bin/console
104
104
  - bin/dev
@@ -164,6 +164,13 @@ files:
164
164
  - examples/README.md
165
165
  - flake.lock
166
166
  - flake.nix
167
+ - guides/crds/readme.md
168
+ - guides/dirty-tracking/readme.md
169
+ - guides/getting-started/readme.md
170
+ - guides/helm-charts/readme.md
171
+ - guides/links.yaml
172
+ - guides/middleware/readme.md
173
+ - guides/resources/readme.md
167
174
  - kube_cluster.gemspec
168
175
  - lib/kube/cli/cluster.rb
169
176
  - lib/kube/cluster.rb
@@ -193,13 +200,14 @@ files:
193
200
  - lib/kube/helm/chart.rb
194
201
  - lib/kube/helm/endpoint.rb
195
202
  - lib/kube/helm/repo.rb
203
+ - readme.md
196
204
  homepage: https://github.com/general-intelligence-systems/kube_cluster
197
205
  licenses:
198
206
  - Apache-2.0
199
207
  metadata:
200
208
  homepage_uri: https://github.com/general-intelligence-systems/kube_cluster
201
209
  source_code_uri: https://github.com/general-intelligence-systems/kube_cluster
202
- documentation_uri: https://github.com/general-intelligence-systems/kube_cluster
210
+ documentation_uri: https://general-intelligence-systems.github.io/kube_cluster/
203
211
  rubygems_mfa_required: 'true'
204
212
  rdoc_options: []
205
213
  require_paths:
data/README.md DELETED
@@ -1,138 +0,0 @@
1
- # kube_cluster
2
-
3
- Ruby-native Kubernetes. Define, transform, and deploy cluster resources with pure Ruby.
4
-
5
- ## Install
6
-
7
- ```ruby
8
- gem "kube_cluster", "~> 0.3"
9
- ```
10
-
11
- ## Examples
12
-
13
- ### Define a resource
14
-
15
- ```ruby
16
- pod = Kube::Cluster["Pod"].new {
17
- metadata.name = "redis"
18
- spec.containers = [{ name: "redis", image: "redis:8" }]
19
- }
20
-
21
- puts pod.to_yaml
22
- ```
23
-
24
- ### Subclass for reuse
25
-
26
- ```ruby
27
- class RedisPod < Kube::Cluster["Pod"]
28
- def initialize(&block)
29
- super {
30
- metadata.name = "redis"
31
- spec.containers = [{ name: "redis", image: "redis:8", ports: [{ containerPort: 6379 }] }]
32
- }
33
- instance_exec(&block) if block_given?
34
- end
35
- end
36
-
37
- puts RedisPod.new { metadata.namespace = "production" }.to_yaml
38
- ```
39
-
40
- ### Manifest + middleware
41
-
42
- One Deployment declaration becomes a fully-configured stack:
43
-
44
- ```ruby
45
- manifest = Kube::Cluster::Manifest.new(
46
- Kube::Cluster["Deployment"].new {
47
- metadata.name = "web"
48
- metadata.labels = {
49
- "app.kubernetes.io/expose": "app.example.com",
50
- "app.kubernetes.io/autoscale": "2-10",
51
- "app.kubernetes.io/size": "small"
52
- }
53
- spec.selector.matchLabels = { app: "web" }
54
- spec.template.spec.containers = [
55
- { name: "web", image: "nginx", ports: [{ name: "http", containerPort: 8080 }] }
56
- ]
57
- }
58
- )
59
-
60
- Kube::Cluster::Middleware::Stack.new {
61
- use Middleware::ServiceForDeployment
62
- use Middleware::IngressForService
63
- use Middleware::HPAForDeployment
64
- use Middleware::Namespace, "production"
65
- use Middleware::Labels, managed_by: "kube_cluster"
66
- use Middleware::ResourcePreset
67
- use Middleware::SecurityContext
68
- use Middleware::PodAntiAffinity
69
- }.call(manifest)
70
-
71
- puts manifest.to_yaml # => Deployment, Service, Ingress, HPA — all configured
72
- ```
73
-
74
- ### Dirty tracking + patching
75
-
76
- ```ruby
77
- cluster = Kube::Cluster.connect(kubeconfig: "~/.kube/config")
78
-
79
- config = Kube::Cluster["ConfigMap"].new(cluster:) {
80
- metadata.name = "app-config"
81
- self.data = { version: "1" }
82
- }
83
-
84
- config.apply # creates on cluster
85
- config.data.version = "2"
86
- config.changed? # => true
87
- config.patch # sends only { data: { version: "2" } }
88
- ```
89
-
90
- ### Helm charts as manifests
91
-
92
- ```ruby
93
- manifest = Kube::Helm::Repo
94
- .new("bitnami", url: "https://charts.bitnami.com/bitnami")
95
- .fetch("nginx", version: "18.1.0")
96
- .apply_values("replicaCount" => 3)
97
-
98
- puts manifest.to_yaml
99
- ```
100
-
101
- ### Register CRDs as first-class resources
102
-
103
- ```ruby
104
- chart = Kube::Helm::Repo.new("jetstack", url: "https://charts.jetstack.io")
105
- .fetch("cert-manager", version: "1.17.2")
106
-
107
- chart.crds.each { |crd|
108
- s = crd.to_json_schema
109
- Kube::Schema.register(s[:kind], schema: s[:schema], api_version: s[:api_version])
110
- }
111
-
112
- issuer = Kube::Cluster["ClusterIssuer"].new {
113
- metadata.name = "letsencrypt"
114
- spec.acme.server = "https://acme-v02.api.letsencrypt.org/directory"
115
- }
116
- ```
117
-
118
- ## Middleware
119
-
120
- | Middleware | Effect |
121
- |---|---|
122
- | `Namespace` | Sets `metadata.namespace` on all resources |
123
- | `Labels` | Merges standard Kubernetes labels |
124
- | `Annotations` | Merges annotations |
125
- | `ResourcePreset` | Injects CPU/memory from `app.kubernetes.io/size` (nano → 2xlarge) |
126
- | `SecurityContext` | Injects restricted/baseline security contexts |
127
- | `PodAntiAffinity` | Spreads pods across nodes |
128
- | `ServiceForDeployment` | Generates Service from named container ports |
129
- | `IngressForService` | Generates Ingress from `app.kubernetes.io/expose` label |
130
- | `HPAForDeployment` | Generates HPA from `app.kubernetes.io/autoscale` label |
131
-
132
- ## More examples
133
-
134
- See the [`examples/`](examples/) directory for complete runnable projects.
135
-
136
- ## License
137
-
138
- Apache-2.0