Commit d8223468 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Add ingress application

parent 3a174c99
module Clusters
module Applications
class Ingress < ActiveRecord::Base
self.table_name = 'clusters_applications_ingress'
include ::Clusters::Concerns::ApplicationStatus
belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
validates :cluster, presence: true
default_value_for :ingress_type, :nginx
default_value_for :version, :nginx
enum ingress_type: {
nginx: 1
}
def self.application_name
self.to_s.demodulize.underscore
end
def name
self.class.application_name
end
def chart
'stable/nginx-ingress'
end
end
end
end
......@@ -5,7 +5,8 @@ module Clusters
self.table_name = 'clusters'
APPLICATIONS = {
Applications::Helm.application_name => Applications::Helm
Applications::Helm.application_name => Applications::Helm,
Applications::Ingress.application_name => Applications::Ingress
}.freeze
belongs_to :user
......@@ -20,6 +21,7 @@ module Clusters
has_one :platform_kubernetes, class_name: 'Clusters::Platforms::Kubernetes', autosave: true, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_one :application_helm, class_name: 'Clusters::Applications::Helm'
has_one :application_ingress, class_name: 'Clusters::Applications::Ingress'
accepts_nested_attributes_for :provider_gcp, update_only: true
accepts_nested_attributes_for :platform_kubernetes, update_only: true
......@@ -59,7 +61,8 @@ module Clusters
def applications
[
application_helm || build_application_helm
application_helm || build_application_helm,
application_ingress || build_application_ingress
]
end
......
class CreateClustersKubernetesIngressApps < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :clusters_applications_ingress do |t|
t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
t.datetime_with_timezone :created_at, null: false
t.datetime_with_timezone :updated_at, null: false
t.integer :status, null: false
t.integer :ingress_type, null: false
t.string :version, null: false
t.string :cluster_ip
t.text :status_reason
end
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171031100710) do
ActiveRecord::Schema.define(version: 20171106101200) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -464,9 +464,7 @@ ActiveRecord::Schema.define(version: 20171031100710) do
create_table "cluster_platforms_kubernetes", force: :cascade do |t|
t.integer "cluster_id", null: false
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.text "api_url"
t.string "api_url"
t.text "ca_cert"
t.string "namespace"
t.string "username"
......@@ -493,9 +491,6 @@ ActiveRecord::Schema.define(version: 20171031100710) do
create_table "cluster_providers_gcp", force: :cascade do |t|
t.integer "cluster_id", null: false
t.integer "status"
t.integer "num_nodes", null: false
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.text "status_reason"
t.string "gcp_project_id", null: false
t.string "zone", null: false
......@@ -513,10 +508,6 @@ ActiveRecord::Schema.define(version: 20171031100710) do
create_table "clusters", force: :cascade do |t|
t.integer "user_id"
t.integer "provider_type"
t.integer "platform_type"
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.boolean "enabled", default: true
t.string "name", null: false
t.integer "provider_type"
......@@ -534,6 +525,17 @@ ActiveRecord::Schema.define(version: 20171031100710) do
t.text "status_reason"
end
create_table "clusters_applications_ingress", force: :cascade do |t|
t.integer "cluster_id", null: false
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.integer "status", null: false
t.integer "ingress_type", null: false
t.string "version", null: false
t.string "cluster_ip"
t.text "status_reason"
end
create_table "container_repositories", force: :cascade do |t|
t.integer "project_id", null: false
t.string "name", null: false
......@@ -1888,6 +1890,7 @@ ActiveRecord::Schema.define(version: 20171031100710) do
add_foreign_key "cluster_providers_gcp", "clusters", on_delete: :cascade
add_foreign_key "clusters", "users", on_delete: :nullify
add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade
add_foreign_key "clusters_applications_ingress", "clusters", on_delete: :cascade
add_foreign_key "container_repositories", "projects"
add_foreign_key "deploy_keys_projects", "projects", name: "fk_58a901ca7e", on_delete: :cascade
add_foreign_key "deployments", "projects", name: "fk_b9a3851b82", on_delete: :cascade
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment