Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ClusterIP as a service option #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/cuber/cuberfile_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def initialize
@lb = {}
@ingress = nil
@ssl = nil
@cluster_ip = nil
end

def method_missing m, *args
Expand Down Expand Up @@ -76,7 +77,7 @@ def cron name, schedule, cmd
def env key, value, secret: false
secret ? (@secrets[key] = value) : (@env[key] = value)
end

def health url
@health = url
end
Expand All @@ -89,6 +90,10 @@ def ingress enabled
@ingress = enabled
end

def cluster_ip enabled
@cluster_ip = enabled
end

def ssl crt, key
@ssl = { crt: crt, key: key }
end
Expand Down
6 changes: 6 additions & 0 deletions lib/cuber/cuberfile_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def validate
validate_health
validate_lb
validate_ingress
validate_cluster_ip
validate_ssl
@errors
end
Expand Down Expand Up @@ -121,6 +122,11 @@ def validate_ingress
@errors << 'ingress must be true or false' if @options[:ingress] != true && @options[:ingress] != false
end

def validate_cluster_ip
return unless @options[:cluster_ip]
@errors << 'cluster_ip must be true or false' if @options[:cluster_ip] != true && @options[:cluster_ip] != false
end

def validate_ssl
return unless @options[:ssl]
@errors << 'ssl crt must be a file' unless File.exist? @options[:ssl][:crt]
Expand Down
20 changes: 20 additions & 0 deletions lib/cuber/templates/deployment.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,26 @@ spec:
name: web-service
port:
number: 80
<%- elsif @options[:cluster_ip] -%>
---
apiVersion: v1
kind: Service
metadata:
name: cluster-ip
namespace: <%= @options[:app] %>
labels:
app.kubernetes.io/name: <%= @options[:app].to_s.to_json %>
app.kubernetes.io/instance: <%= @options[:instance].to_s.to_json %>
app.kubernetes.io/version: <%= @options[:release].to_s.to_json %>
app.kubernetes.io/managed-by: cuber
spec:
type: ClusterIP
selector:
app: web-proc
ports:
- protocol: TCP
port: 8080
targetPort: 8080
<%- else -%>
---
apiVersion: v1
Expand Down