Skip to content

Commit

Permalink
Also allow Ingresses to respect the 'predeployed' annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
c-gerke committed Nov 26, 2024
1 parent ca20352 commit 5b45f3b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ before the deployment is considered successful.
- Percent (e.g. 90%): The deploy is successful when the number of new pods that are ready is equal to `spec.replicas` * Percent.
- _Compatibility_: StatefulSet
- `full`: The deployment is successful when all pods are ready.
- `krane.shopify.io/predeployed`: Causes a Custom Resource, Deployment, Service, or Job to be deployed in the pre-deploy phase.
- _Compatibility_: Custom Resource Definition, Deployment, Service, Job
- `krane.shopify.io/predeployed`: Causes a Custom Resource, Deployment, Service, Job, or Ingress to be deployed in the pre-deploy phase.
- _Compatibility_: Custom Resource Definition, Deployment, Service, Job, Ingress
- _Default_: `true`
- `true`: The custom resource, deployment, service, or job will be deployed in the pre-deploy phase.
- All other values: The custom resource, deployment, service, or job will be deployed in the main deployment phase.
- `true`: The custom resource, deployment, service, job, or ingress will be deployed in the pre-deploy phase.
- All other values: The custom resource, deployment, service, job, or ingress will be deployed in the main deployment phase.
- `krane.shopify.io/deploy-method-override`: Cause a resource to be deployed by the specified `kubectl` command, instead of the default `apply`.
- _Compatibility_: Cannot be used for `PodDisruptionBudget`, since it always uses `create/replace-force`
- _Accepted values_: `create`, `replace`, and `replace-force`
Expand Down
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 5b45f3b

Please sign in to comment.