class Krane::StatefulSet
Constants
- ONDELETE
- SYNC_DEPENDENCIES
- TIMEOUT
Attributes
pods[R]
Public Instance Methods
deploy_failed?()
click to toggle source
# File lib/krane/kubernetes_resource/stateful_set.rb, line 39 def deploy_failed? return false if update_strategy == ONDELETE pods.present? && pods.any?(&:deploy_failed?) && observed_generation == current_generation end
deploy_succeeded?()
click to toggle source
# File lib/krane/kubernetes_resource/stateful_set.rb, line 21 def deploy_succeeded? if update_strategy == ONDELETE # Gem cannot monitor update since it doesn't occur until delete unless @success_assumption_warning_shown @logger.warn("WARNING: Your StatefulSet's updateStrategy is set to OnDelete, "\ "which means updates will not be applied until its pods are deleted. "\ "Consider switching to rollingUpdate.") @success_assumption_warning_shown = true end true else observed_generation == current_generation && status_data['currentRevision'] == status_data['updateRevision'] && desired_replicas == status_data['readyReplicas'].to_i && desired_replicas == status_data['currentReplicas'].to_i end end
status()
click to toggle source
Calls superclass method
Krane::KubernetesResource#status
# File lib/krane/kubernetes_resource/stateful_set.rb, line 15 def status return super unless @instance_data["status"].present? rollout_data = @instance_data["status"].slice("replicas", "readyReplicas", "currentReplicas") rollout_data.map { |state_replicas, num| "#{num} #{state_replicas.chop.pluralize(num)}" }.join(", ") end
sync(cache)
click to toggle source
Calls superclass method
Krane::KubernetesResource#sync
# File lib/krane/kubernetes_resource/stateful_set.rb, line 10 def sync(cache) super @pods = exists? ? find_pods(cache) : [] end
Private Instance Methods
desired_replicas()
click to toggle source
# File lib/krane/kubernetes_resource/stateful_set.rb, line 60 def desired_replicas return -1 unless exists? @instance_data["spec"]["replicas"].to_i end
parent_of_pod?(pod_data)
click to toggle source
# File lib/krane/kubernetes_resource/stateful_set.rb, line 65 def parent_of_pod?(pod_data) return false unless pod_data.dig("metadata", "ownerReferences") pod_data["metadata"]["ownerReferences"].any? { |ref| ref["uid"] == @instance_data["metadata"]["uid"] } && @instance_data["status"]["currentRevision"] == pod_data["metadata"]["labels"]["controller-revision-hash"] end
status_data()
click to toggle source
# File lib/krane/kubernetes_resource/stateful_set.rb, line 55 def status_data return { 'readyReplicas' => '-1', 'currentReplicas' => '-2' } unless exists? @instance_data["status"] end
update_strategy()
click to toggle source
# File lib/krane/kubernetes_resource/stateful_set.rb, line 47 def update_strategy if exists? @instance_data['spec']['updateStrategy']['type'] else 'Unknown' end end