Class: Keel::GCloud::Kubernetes::Deployment

Inherits:
PodManager
  • Object
show all
Defined in:
lib/keel/gcloud/kubernetes/deployment.rb

Overview

A class to represent a Kubernetes Deployment

Instance Attribute Summary

Attributes inherited from PodManager

#containers, #name, #namespace, #original, #uid

Class Method Summary collapse

Methods inherited from PodManager

from_yaml, #initialize, replace, #to_file, #to_yaml, #update

Constructor Details

This class inherits a constructor from Keel::GCloud::Kubernetes::PodManager

Class Method Details

.create(app_name, image_path, port, sha, namespace) ⇒ Object

Create a Deployment and expose it on kubernetes



24
25
26
27
28
29
30
# File 'lib/keel/gcloud/kubernetes/deployment.rb', line 24

def self.create app_name, image_path, port, sha, namespace
    cli            = Cli.new
    deploy_command = "kubectl run #{app_name} --image=#{image_path}:#{sha} --namespace=#{namespace}"
    expose_command = "kubectl expose deployment #{app_name} --port=80 --target-port=#{port} --type=LoadBalancer --namespace=#{namespace}"
    cli.execute(deploy_command)
    cli.execute(expose_command)
end

.fetch_all(env, app) ⇒ Hash

Fetches the correct deployment or replication controller from Kubernetes.

Parameters:

  • env (String)

    the namespace/environment for which to fetch the controllers

  • app (String)

    the app for which to fetch the controllers

Returns:

  • (Hash)

    the parsed result of the API call



14
15
16
17
18
19
# File 'lib/keel/gcloud/kubernetes/deployment.rb', line 14

def self.fetch_all env, app
    command = "kubectl get deployment --namespace=#{env} -l app=#{app} -o yaml"
    rcs_yaml = YAML.load Cli.new.execute(command)
    return [] unless rcs_yaml["items"].count > 0
    self.from_yaml rcs_yaml 
end