gjallarhorn 0.1.0.alpha → 0.1.0

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: f1803a8eea18b207eaee8efb506435449e7bc44e7b7d42f5641c937600f232f1
4
- data.tar.gz: e34842e3170ebdc2ea1b51ec9fc66526985fc9c4a2c159bfcedc60bbaf980bd4
3
+ metadata.gz: 30d18c641ccd046fc6231c52f2b28e9f4dbc80c0b27c73720d9edeea2e30790d
4
+ data.tar.gz: 77e143189ef34521f543777f698e081b18229f1cf6dd84e7a0297a200dec6a30
5
5
  SHA512:
6
- metadata.gz: 247368e61b771afc91243fade7d0cededffeac32be6252692a43d75abc35ca9445ccbfaad79a1ec0df6da68a3f5eed34f4ca7dbb6ee39350ab64cf8a0ed953ed
7
- data.tar.gz: 7b1d4a4f148def633aa427874f5079ae38404099bea1ed858bb16f21e286b4433f31a9aca1f87c3cc1716c76150238c8bb9b22e194f2aad4847e87fc914dd0a7
6
+ metadata.gz: 84bbcfa4911590da498b8c786d81c52df80b9ac1d15e1d9030641126a4b9e747c90a681f728f559a2d1e62b83c13ae1b93162e64a9fe014950319cde691b4608
7
+ data.tar.gz: 9c5b625499b0e907348909f23ecbf945ef13cd97cbab9743a62df545498fa0f81e3ecd2fc13d1e4d508ba7bd44790270ff3bb5e7569370b66ed84e8ce0c6394e
data/.yardopts ADDED
@@ -0,0 +1,12 @@
1
+ --markup markdown
2
+ --markup-provider kramdown
3
+ --readme README.md
4
+ --output-dir doc
5
+ --exclude test/
6
+ --exclude examples/
7
+ --exclude docs/
8
+ --private
9
+ lib/**/*.rb
10
+ -
11
+ CHANGELOG.md
12
+ LICENSE.txt
data/README.md CHANGED
@@ -2,12 +2,18 @@
2
2
 
3
3
  Multi-cloud deployment guardian as legendary as Heimdall's horn.
4
4
 
5
- > **⚠️ ALPHA RELEASE NOTICE**
6
- > This gem is currently in alpha development and **NOT RECOMMENDED FOR PRODUCTION USE**. We are publishing this early version to RubyGems.org primarily to secure the `gjallarhorn` gem name. The API and functionality are subject to significant changes. Use at your own risk.
5
+ A Ruby gem that sounds across all cloud realms with secure, API-first deployments beyond SSH. Currently supporting AWS with additional providers planned for future releases.
7
6
 
8
- A Ruby gem that sounds across all cloud realms with secure, API-first deployments beyond SSH:
7
+ ## Features
9
8
 
10
- - AWS (SSM)
9
+ **Phase 1 (0.1.0) - AWS Foundation:**
10
+ - ✅ AWS SSM-based deployments (no SSH required)
11
+ - ✅ Thor-based CLI with comprehensive commands
12
+ - ✅ YAML configuration system
13
+ - ✅ Comprehensive test coverage
14
+ - ✅ Complete YARD documentation
15
+
16
+ **Future Phases:**
11
17
  - Google Cloud Platform (Compute Engine API)
12
18
  - Microsoft Azure (Run Command API)
13
19
  - Self-hosted Docker (Docker API)
@@ -16,23 +22,124 @@ A Ruby gem that sounds across all cloud realms with secure, API-first deployment
16
22
 
17
23
  ## Installation
18
24
 
19
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
20
-
21
25
  Install the gem and add to the application's Gemfile by executing:
22
26
 
23
27
  ```bash
24
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
28
+ bundle add gjallarhorn
25
29
  ```
26
30
 
27
31
  If bundler is not being used to manage dependencies, install the gem by executing:
28
32
 
29
33
  ```bash
30
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
34
+ gem install gjallarhorn
31
35
  ```
32
36
 
33
37
  ## Usage
34
38
 
35
- TODO: Write usage instructions here
39
+ ### Configuration
40
+
41
+ Create a `deploy.yml` file in your project root:
42
+
43
+ ```yaml
44
+ production:
45
+ provider: aws
46
+ region: us-west-2
47
+ services:
48
+ - name: web
49
+ ports: ["80:8080"]
50
+ env:
51
+ RAILS_ENV: production
52
+ DATABASE_URL: postgresql://user:pass@host/db
53
+
54
+ staging:
55
+ provider: aws
56
+ region: us-west-2
57
+ services:
58
+ - name: web
59
+ ports: ["80:8080"]
60
+ env:
61
+ RAILS_ENV: staging
62
+ ```
63
+
64
+ ### CLI Commands
65
+
66
+ Deploy to an environment:
67
+ ```bash
68
+ gjallarhorn deploy production myapp:v1.2.3
69
+ ```
70
+
71
+ Check deployment status:
72
+ ```bash
73
+ gjallarhorn status production
74
+ ```
75
+
76
+ Rollback to previous version:
77
+ ```bash
78
+ gjallarhorn rollback production v1.2.2
79
+ ```
80
+
81
+ View configuration:
82
+ ```bash
83
+ gjallarhorn config
84
+ ```
85
+
86
+ Show version:
87
+ ```bash
88
+ gjallarhorn version
89
+ ```
90
+
91
+ ### AWS Prerequisites
92
+
93
+ Ensure your EC2 instances have:
94
+ - SSM Agent installed and running
95
+ - Appropriate IAM roles for SSM access
96
+ - Tags: `Environment` (e.g., "production") and `Role` (e.g., "web", "app")
97
+ - Docker installed and running
98
+
99
+ #### Required IAM Permissions
100
+
101
+ Your EC2 instances need an IAM role with the following permissions:
102
+
103
+ **For SSM access:**
104
+ ```json
105
+ {
106
+ "Version": "2012-10-17",
107
+ "Statement": [
108
+ {
109
+ "Effect": "Allow",
110
+ "Action": [
111
+ "ssm:UpdateInstanceInformation",
112
+ "ssmmessages:CreateControlChannel",
113
+ "ssmmessages:CreateDataChannel",
114
+ "ssmmessages:OpenControlChannel",
115
+ "ssmmessages:OpenDataChannel"
116
+ ],
117
+ "Resource": "*"
118
+ }
119
+ ]
120
+ }
121
+ ```
122
+
123
+ **For ECR access (when deploying from ECR):**
124
+ ```json
125
+ {
126
+ "Version": "2012-10-17",
127
+ "Statement": [
128
+ {
129
+ "Effect": "Allow",
130
+ "Action": [
131
+ "ecr:GetAuthorizationToken",
132
+ "ecr:BatchCheckLayerAvailability",
133
+ "ecr:GetDownloadUrlForLayer",
134
+ "ecr:BatchGetImage"
135
+ ],
136
+ "Resource": "*"
137
+ }
138
+ ]
139
+ }
140
+ ```
141
+
142
+ You can use the AWS managed policy `AmazonSSMManagedInstanceCore` for SSM access, and create a custom policy for ECR access.
36
143
 
37
144
  ## Development
38
145
 
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Example of zero-downtime deployment with Gjallarhorn
5
+ # This demonstrates the new deployment architecture with strategies and proxy management
6
+
7
+ require_relative "../lib/gjallarhorn"
8
+
9
+ # Example configuration for zero-downtime deployment
10
+ config_yml = <<~YAML
11
+ production:
12
+ provider: aws
13
+ region: us-west-2
14
+ #{" "}
15
+ # Proxy configuration for zero-downtime deployments
16
+ proxy:
17
+ type: nginx
18
+ domain: myapp.example.com
19
+ ssl: true
20
+ health_check_path: /health
21
+ conf_dir: /etc/nginx/conf.d
22
+ #{" "}
23
+ services:
24
+ - name: web
25
+ ports: ["80:3000"]
26
+ env:
27
+ RAILS_ENV: production
28
+ DATABASE_URL: postgresql://db.example.com/myapp_production
29
+ healthcheck:
30
+ type: http
31
+ path: /health
32
+ port: 3000
33
+ expected_status: [200, 204]
34
+ max_attempts: 30
35
+ interval: 3
36
+ drain_timeout: 30
37
+ restart_policy: unless-stopped
38
+ #{" "}
39
+ - name: worker
40
+ env:
41
+ RAILS_ENV: production
42
+ DATABASE_URL: postgresql://db.example.com/myapp_production
43
+ cmd: bundle exec sidekiq
44
+ healthcheck:
45
+ type: command
46
+ command: pgrep -f sidekiq
47
+ restart_policy: unless-stopped
48
+ YAML
49
+
50
+ # Write temporary config file
51
+ require "tempfile"
52
+ config_file = Tempfile.new(["deploy", ".yml"])
53
+ config_file.write(config_yml)
54
+ config_file.close
55
+
56
+ begin
57
+ # Initialize deployer
58
+ Gjallarhorn::Deployer.new(config_file.path)
59
+
60
+ puts "🚀 Starting zero-downtime deployment..."
61
+ puts "=" * 50
62
+
63
+ # Deploy with zero-downtime strategy (default)
64
+ puts "\n1. Deploying with zero-downtime strategy:"
65
+ puts " - Starts new containers alongside existing ones"
66
+ puts " - Waits for health checks to pass"
67
+ puts " - Switches nginx proxy traffic to new containers"
68
+ puts " - Gracefully stops old containers"
69
+ puts ""
70
+
71
+ # This would perform the actual deployment:
72
+ # deployer.deploy('production', 'myapp:v2.1.0')
73
+
74
+ # For demo purposes, show what strategies are available
75
+ puts "✅ Available deployment strategies:"
76
+ puts " - zero_downtime: Full zero-downtime with proxy switching (default)"
77
+ puts " - basic: Stop old containers, start new ones (downtime expected)"
78
+ puts " - legacy: Use original adapter interface (for compatibility)"
79
+
80
+ puts "\n📊 Zero-downtime deployment features:"
81
+ puts " ✅ Container orchestration with health checks"
82
+ puts " ✅ Nginx proxy management with traffic switching"
83
+ puts " ✅ Graceful container shutdown with drain timeout"
84
+ puts " ✅ Container versioning and cleanup"
85
+ puts " ✅ Rollback support (keeps old containers for quick rollback)"
86
+ puts " ✅ Multiple service support (web + worker)"
87
+ puts " ✅ HTTP and command-based health checks"
88
+
89
+ puts "\n🔧 Proxy managers supported:"
90
+ puts " ✅ Nginx (fully implemented)"
91
+ puts " 🚧 Traefik (placeholder - future release)"
92
+ puts " 🚧 Kamal-proxy (placeholder - future release)"
93
+
94
+ puts "\n💡 Usage examples:"
95
+ puts " deployer.deploy('production', 'myapp:v2.1.0') # Zero-downtime (default)"
96
+ puts " deployer.deploy('production', 'myapp:v2.1.0', strategy: 'basic') # Basic deployment"
97
+ puts " deployer.deploy_with_strategy('production', 'myapp:v2.1.0', 'zero_downtime')"
98
+ rescue Gjallarhorn::ConfigurationError => e
99
+ puts "❌ Configuration error: #{e.message}"
100
+ rescue Gjallarhorn::DeploymentError => e
101
+ puts "❌ Deployment error: #{e.message}"
102
+ ensure
103
+ config_file&.unlink
104
+ end