Skip to content

Commit

Permalink
Add support for ingresses to be predeployed
Browse files Browse the repository at this point in the history
  • Loading branch information
c-gerke committed Nov 26, 2024
1 parent 020c966 commit 9966961
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/krane/cluster_resource_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def jobs
end
end

def ingresses
@ingresses ||= fetch_ingresses.map do |ingress|
Ingress.new(namespace: namespace, context: context, logger: logger,
definition: ingress, statsd_tags: @namespace_tags)
end
end

def prunable_resources(namespaced:)
black_list = %w(Namespace Node ControllerRevision Event)
fetch_resources(namespaced: namespaced).map do |resource|
Expand Down Expand Up @@ -149,6 +156,16 @@ def fetch_jobs
end
end

def fetch_ingresses
raw_json, err, st = kubectl.run("get", "Ingress", output: "json", attempts: 5,
use_namespace: false)
if st.success?
MultiJson.load(raw_json)["items"]
else
raise FatalKubeAPIError, "Error retrieving Ingress: #{err}"
end
end

def kubectl
@kubectl ||= Kubectl.new(task_config: @task_config, log_failure_by_default: true)
end
Expand Down
1 change: 1 addition & 0 deletions lib/krane/deploy_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def predeploy_sequence
after_crs = %w(
Deployment
Service
Ingress
Pod
Job
).map { |r| [r, default_group] }
Expand Down
8 changes: 8 additions & 0 deletions lib/krane/kubernetes_resource/ingress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@ def deploy_succeeded?
def deploy_failed?
false
end

def predeployed?
krane_annotation_value("predeployed") == "true"
end

def kind
@definition["kind"]
end
end
end

0 comments on commit 9966961

Please sign in to comment.