From 99669614ca04e4dc23976c6155ca35e518779437 Mon Sep 17 00:00:00 2001 From: Colton Gerke Date: Tue, 26 Nov 2024 15:57:53 -0600 Subject: [PATCH 1/2] Add support for ingresses to be predeployed --- lib/krane/cluster_resource_discovery.rb | 17 +++++++++++++++++ lib/krane/deploy_task.rb | 1 + lib/krane/kubernetes_resource/ingress.rb | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/lib/krane/cluster_resource_discovery.rb b/lib/krane/cluster_resource_discovery.rb index fd98699f8..7b8b99b17 100644 --- a/lib/krane/cluster_resource_discovery.rb +++ b/lib/krane/cluster_resource_discovery.rb @@ -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| @@ -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 diff --git a/lib/krane/deploy_task.rb b/lib/krane/deploy_task.rb index 0c57799a2..36b928f86 100644 --- a/lib/krane/deploy_task.rb +++ b/lib/krane/deploy_task.rb @@ -72,6 +72,7 @@ def predeploy_sequence after_crs = %w( Deployment Service + Ingress Pod Job ).map { |r| [r, default_group] } diff --git a/lib/krane/kubernetes_resource/ingress.rb b/lib/krane/kubernetes_resource/ingress.rb index e34f4231c..b94ef4df4 100644 --- a/lib/krane/kubernetes_resource/ingress.rb +++ b/lib/krane/kubernetes_resource/ingress.rb @@ -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 From 941a18e58f187a3732dc3cd11248dd6c67b858a6 Mon Sep 17 00:00:00 2001 From: Colton Gerke Date: Fri, 29 Nov 2024 10:36:45 -0600 Subject: [PATCH 2/2] Bump the Krane version --- lib/krane/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/krane/version.rb b/lib/krane/version.rb index abb3bf6d1..3528c6437 100644 --- a/lib/krane/version.rb +++ b/lib/krane/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Krane - VERSION = "3.4.2-powerhrg-4" + VERSION = "3.4.2-powerhrg-5" end