Class: KubernetesDeploy::Runner
- Inherits:
-
Object
- Object
- KubernetesDeploy::Runner
- Defined in:
- lib/kubernetes-deploy/runner.rb
Constant Summary collapse
- PREDEPLOY_SEQUENCE =
%w( Cloudsql Redis ConfigMap PersistentVolumeClaim Pod )
- PROTECTED_NAMESPACES =
%w( default kube-system )
- PRUNE_WHITELIST =
Things removed from default prune whitelist: core/v1/Namespace – not namespaced core/v1/PersistentVolume – not namespaced core/v1/Endpoints – managed by services core/v1/PersistentVolumeClaim – would delete data core/v1/ReplicationController – superseded by deployments/replicasets extensions/v1beta1/ReplicaSet – managed by deployments core/v1/Secret – should not committed / managed by shipit
%w( core/v1/ConfigMap core/v1/Pod core/v1/Service batch/v1/Job extensions/v1beta1/DaemonSet extensions/v1beta1/Deployment extensions/v1beta1/HorizontalPodAutoscaler extensions/v1beta1/Ingress apps/v1beta1/StatefulSet ).freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(namespace:, current_sha:, context:, wait_for_completion:, template_dir:) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #template_variables ⇒ Object
- #wait_for_completion? ⇒ Boolean
Constructor Details
#initialize(namespace:, current_sha:, context:, wait_for_completion:, template_dir:) ⇒ Runner
Returns a new instance of Runner.
66 67 68 69 70 71 72 73 74 |
# File 'lib/kubernetes-deploy/runner.rb', line 66 def initialize(namespace:, current_sha:, context:, wait_for_completion:, template_dir:) @namespace = namespace @context = context @current_sha = current_sha @template_dir = File.(template_dir) # Max length of podname is only 63chars so try to save some room by truncating sha to 8 chars @id = current_sha[0...8] + "-#{SecureRandom.hex(4)}" if current_sha @wait_for_completion = wait_for_completion end |
Class Method Details
.with_friendly_errors ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/kubernetes-deploy/runner.rb', line 56 def self.with_friendly_errors yield rescue FatalDeploymentError => error KubernetesDeploy.logger.fatal <<-MSG #{error.class}: #{error.} #{error.backtrace && error.backtrace.join("\n ")} MSG exit 1 end |
Instance Method Details
#run ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/kubernetes-deploy/runner.rb', line 80 def run @current_phase = 0 phase_heading("Validating configuration") validate_configuration phase_heading("Identifying deployment target") confirm_context_exists confirm_namespace_exists phase_heading("Parsing deploy content") resources = discover_resources phase_heading("Checking initial resource statuses") resources.each(&:sync) phase_heading("Predeploying priority resources") predeploy_priority_resources(resources) phase_heading("Deploying all resources") deploy_resources(resources, prune: true) return unless wait_for_completion? wait_for_completion(resources) report_final_status(resources) end |
#template_variables ⇒ Object
106 107 108 109 110 111 |
# File 'lib/kubernetes-deploy/runner.rb', line 106 def template_variables { 'current_sha' => @current_sha, 'deployment_id' => @id, } end |
#wait_for_completion? ⇒ Boolean
76 77 78 |
# File 'lib/kubernetes-deploy/runner.rb', line 76 def wait_for_completion? @wait_for_completion end |