summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Rathi <amit@hypertrack.io>2018-11-03 09:08:21 +0530
committerAmit Rathi <amit@hypertrack.io>2018-11-03 09:08:21 +0530
commit8837519445c319a699e0f3ced1c6912c839f3389 (patch)
tree41745e4c774025c568b0306206a58cff0965e353
parent98a504ecbb45907517ae465018906af7ef4573de (diff)
downloadgitlab-ce-8837519445c319a699e0f3ced1c6912c839f3389.tar.gz
Pushing WIP state for backup
-rw-r--r--app/assets/javascripts/clusters/clusters_bundle.js2
-rw-r--r--app/assets/javascripts/clusters/components/applications.vue27
-rw-r--r--app/assets/javascripts/clusters/services/clusters_service.js1
-rw-r--r--app/assets/javascripts/clusters/stores/clusters_store.js8
-rw-r--r--app/models/clusters/cluster.rb3
-rw-r--r--app/services/clusters/applications/check_installation_progress_service.rb4
-rw-r--r--app/services/clusters/applications/create_service.rb5
-rw-r--r--app/services/clusters/applications/install_service.rb12
-rw-r--r--app/views/projects/clusters/show.html.haml1
-rw-r--r--app/workers/cluster_install_app_worker.rb1
-rw-r--r--db/schema.rb14
-rw-r--r--lib/gitlab/kubernetes/helm/api.rb28
-rw-r--r--lib/gitlab/kubernetes/helm/install_command.rb5
13 files changed, 99 insertions, 12 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js
index ebf76af5966..b330b3fac89 100644
--- a/app/assets/javascripts/clusters/clusters_bundle.js
+++ b/app/assets/javascripts/clusters/clusters_bundle.js
@@ -26,6 +26,7 @@ export default class Clusters {
statusPath,
installHelmPath,
installIngressPath,
+ installCertManagerPath,
installRunnerPath,
installJupyterPath,
installPrometheusPath,
@@ -46,6 +47,7 @@ export default class Clusters {
endpoint: statusPath,
installHelmEndpoint: installHelmPath,
installIngressEndpoint: installIngressPath,
+ installCertManagerEndpoint: installCertManagerPath,
installRunnerEndpoint: installRunnerPath,
installPrometheusEndpoint: installPrometheusPath,
installJupyterEndpoint: installJupyterPath,
diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue
index 6e7b5eb5526..4f84d916e85 100644
--- a/app/assets/javascripts/clusters/components/applications.vue
+++ b/app/assets/javascripts/clusters/components/applications.vue
@@ -7,6 +7,7 @@ import helmLogo from 'images/cluster_app_logos/helm.png';
import jeagerLogo from 'images/cluster_app_logos/jeager.png';
import jupyterhubLogo from 'images/cluster_app_logos/jupyterhub.png';
import kubernetesLogo from 'images/cluster_app_logos/kubernetes.png';
+import certManagerLogo from 'images/cluster_app_logos/cert_manager.png';
import meltanoLogo from 'images/cluster_app_logos/meltano.png';
import prometheusLogo from 'images/cluster_app_logos/prometheus.png';
import { s__, sprintf } from '../../locale';
@@ -53,6 +54,7 @@ export default {
jeagerLogo,
jupyterhubLogo,
kubernetesLogo,
+ certManagerLogo,
meltanoLogo,
prometheusLogo,
}),
@@ -69,6 +71,9 @@ export default {
ingressInstalled() {
return this.applications.ingress.status === APPLICATION_STATUS.INSTALLED;
},
+ certManagerInstalled() {
+ return this.applications.cert_manager.status === APPLICATION_STATUS.INSTALLED;
+ },
ingressExternalIp() {
return this.applications.ingress.externalIp;
},
@@ -276,6 +281,28 @@ export default {
</div>
</application-row>
<application-row
+ id="cert_manager"
+ :logo-url="certManagerLogo"
+ :title="applications.cert_manager.title"
+ :status="applications.cert_manager.status"
+ :status-reason="applications.cert_manager.statusReason"
+ :request-status="applications.cert_manager.requestStatus"
+ :request-reason="applications.cert_manager.requestReason"
+ :disabled="!helmInstalled"
+ class="hide-bottom-border rounded-bottom"
+ title-link="https://cert-manager.readthedocs.io/en/latest/#"
+ >
+ <div slot="description">
+ <p>
+ {{ s__(`ClusterIntegration|Cert-Manager is a native Kubernetes
+ certificate management controller. It will ensure certificates
+ are valid and up to date, and attempt to renew certificates at
+ a configured time before expiry. We use Lets Encrypt as a Certificate
+ Authority with Cert-Manager.`) }}
+ </p>
+ </div>
+ </application-row>
+ <application-row
id="prometheus"
:logo-url="prometheusLogo"
:title="applications.prometheus.title"
diff --git a/app/assets/javascripts/clusters/services/clusters_service.js b/app/assets/javascripts/clusters/services/clusters_service.js
index a7d82292ba9..1abe244b0af 100644
--- a/app/assets/javascripts/clusters/services/clusters_service.js
+++ b/app/assets/javascripts/clusters/services/clusters_service.js
@@ -6,6 +6,7 @@ export default class ClusterService {
this.appInstallEndpointMap = {
helm: this.options.installHelmEndpoint,
ingress: this.options.installIngressEndpoint,
+ cert_manager: this.options.installCertManagerEndpoint,
runner: this.options.installRunnerEndpoint,
prometheus: this.options.installPrometheusEndpoint,
jupyter: this.options.installJupyterEndpoint,
diff --git a/app/assets/javascripts/clusters/stores/clusters_store.js b/app/assets/javascripts/clusters/stores/clusters_store.js
index 106ac3cb516..24ac35852fe 100644
--- a/app/assets/javascripts/clusters/stores/clusters_store.js
+++ b/app/assets/javascripts/clusters/stores/clusters_store.js
@@ -24,6 +24,14 @@ export default class ClusterStore {
requestReason: null,
externalIp: null,
},
+ cert_manager: {
+ title: s__('ClusterIntegration|Cert-Manager'),
+ status: null,
+ statusReason: null,
+ requestStatus: null,
+ requestReason: null,
+ externalIp: null,
+ },
runner: {
title: s__('ClusterIntegration|GitLab Runner'),
status: null,
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 222e4217e67..c2e2a380241 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -9,6 +9,7 @@ module Clusters
APPLICATIONS = {
Applications::Helm.application_name => Applications::Helm,
Applications::Ingress.application_name => Applications::Ingress,
+ Applications::CertManager.application_name => Applications::CertManager,
Applications::Prometheus.application_name => Applications::Prometheus,
Applications::Runner.application_name => Applications::Runner,
Applications::Jupyter.application_name => Applications::Jupyter
@@ -33,6 +34,7 @@ module Clusters
has_one :application_helm, class_name: 'Clusters::Applications::Helm'
has_one :application_ingress, class_name: 'Clusters::Applications::Ingress'
+ has_one :application_cert_manager, class_name: 'Clusters::Applications::CertManager'
has_one :application_prometheus, class_name: 'Clusters::Applications::Prometheus'
has_one :application_runner, class_name: 'Clusters::Applications::Runner'
has_one :application_jupyter, class_name: 'Clusters::Applications::Jupyter'
@@ -99,6 +101,7 @@ module Clusters
[
application_helm || build_application_helm,
application_ingress || build_application_ingress,
+ application_cert_manager || build_application_cert_manager,
application_prometheus || build_application_prometheus,
application_runner || build_application_runner,
application_jupyter || build_application_jupyter
diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb
index 5017fa093f3..5959a337489 100644
--- a/app/services/clusters/applications/check_installation_progress_service.rb
+++ b/app/services/clusters/applications/check_installation_progress_service.rb
@@ -27,9 +27,11 @@ module Clusters
end
def on_failed
+ Gitlab::AppLogger.info("Installation FAILED!!")
app.make_errored!('Installation failed')
ensure
- remove_installation_pod
+ Gitlab::AppLogger.info("SKIP CLEARING POD!")
+ # remove_installation_pod
end
def check_timeout
diff --git a/app/services/clusters/applications/create_service.rb b/app/services/clusters/applications/create_service.rb
index 55f917798de..933f9ad1bd2 100644
--- a/app/services/clusters/applications/create_service.rb
+++ b/app/services/clusters/applications/create_service.rb
@@ -19,6 +19,10 @@ module Clusters
application.hostname = params[:hostname]
end
+ if application.has_attribute?(:email)
+ application.email = @current_user.email
+ end
+
if application.respond_to?(:oauth_application)
application.oauth_application = create_oauth_application(application, request)
end
@@ -43,6 +47,7 @@ module Clusters
{
"helm" => -> (cluster) { cluster.application_helm || cluster.build_application_helm },
"ingress" => -> (cluster) { cluster.application_ingress || cluster.build_application_ingress },
+ "cert_manager" => -> (cluster) { cluster.application_cert_manager || cluster.build_application_cert_manager },
"prometheus" => -> (cluster) { cluster.application_prometheus || cluster.build_application_prometheus },
"runner" => -> (cluster) { cluster.application_runner || cluster.build_application_runner },
"jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter }
diff --git a/app/services/clusters/applications/install_service.rb b/app/services/clusters/applications/install_service.rb
index dd8d2ed5eb6..cf2c5952ad6 100644
--- a/app/services/clusters/applications/install_service.rb
+++ b/app/services/clusters/applications/install_service.rb
@@ -4,17 +4,25 @@ module Clusters
module Applications
class InstallService < BaseHelmService
def execute
+ Gitlab::AppLogger.info('---- IN execute installing ----')
return unless app.scheduled?
begin
+
app.make_installing!
helm_api.install(install_command)
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
- rescue Kubeclient::HttpError
+ rescue Kubeclient::HttpError => e
+ Gitlab::AppLogger.info('HttpError---- IN execute installing ----')
+ Gitlab::AppLogger.error(e)
+ Gitlab::AppLogger.error(e.backtrace.join("\n"))
app.make_errored!("Kubernetes error.")
- rescue StandardError
+ rescue StandardError => e
+ Gitlab::AppLogger.info('StandardError---- IN execute installing ----')
+ Gitlab::AppLogger.error(e)
+ Gitlab::AppLogger.error(e.backtrace.join("\n"))
app.make_errored!("Can't start installation process.")
end
end
diff --git a/app/views/projects/clusters/show.html.haml b/app/views/projects/clusters/show.html.haml
index eddd3613c5f..9c25b2da026 100644
--- a/app/views/projects/clusters/show.html.haml
+++ b/app/views/projects/clusters/show.html.haml
@@ -9,6 +9,7 @@
.edit-cluster-form.js-edit-cluster-form{ data: { status_path: status_path,
install_helm_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :helm),
install_ingress_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :ingress),
+ install_cert_manager_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :cert_manager),
install_prometheus_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :prometheus),
install_runner_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :runner),
install_jupyter_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :jupyter),
diff --git a/app/workers/cluster_install_app_worker.rb b/app/workers/cluster_install_app_worker.rb
index 32e2ea7996c..c683d718cdf 100644
--- a/app/workers/cluster_install_app_worker.rb
+++ b/app/workers/cluster_install_app_worker.rb
@@ -7,6 +7,7 @@ class ClusterInstallAppWorker
def perform(app_name, app_id)
find_application(app_name, app_id) do |app|
+
Clusters::Applications::InstallService.new(app).execute
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 6b0bb33f969..c18b312ad6b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20181017001059) do
+ActiveRecord::Schema.define(version: 20181101191341) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -668,6 +668,16 @@ ActiveRecord::Schema.define(version: 20181017001059) do
add_index "clusters", ["enabled"], name: "index_clusters_on_enabled", using: :btree
add_index "clusters", ["user_id"], name: "index_clusters_on_user_id", using: :btree
+ create_table "clusters_applications_cert_managers", force: :cascade do |t|
+ t.integer "cluster_id", null: false
+ t.integer "status", null: false
+ t.string "version", null: false
+ t.string "email", null: false
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.text "status_reason"
+ end
+
create_table "clusters_applications_helm", force: :cascade do |t|
t.integer "cluster_id", null: false
t.datetime_with_timezone "created_at", null: false
@@ -1843,6 +1853,7 @@ ActiveRecord::Schema.define(version: 20181017001059) do
end
add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree
+ add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"}
add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree
create_table "releases", force: :cascade do |t|
@@ -2391,6 +2402,7 @@ ActiveRecord::Schema.define(version: 20181017001059) do
add_foreign_key "cluster_projects", "projects", on_delete: :cascade
add_foreign_key "cluster_providers_gcp", "clusters", on_delete: :cascade
add_foreign_key "clusters", "users", on_delete: :nullify
+ add_foreign_key "clusters_applications_cert_managers", "clusters", on_delete: :cascade
add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade
add_foreign_key "clusters_applications_ingress", "clusters", name: "fk_753a7b41c1", on_delete: :cascade
add_foreign_key "clusters_applications_jupyter", "clusters", on_delete: :cascade
diff --git a/lib/gitlab/kubernetes/helm/api.rb b/lib/gitlab/kubernetes/helm/api.rb
index e21bc531444..63f3d863c61 100644
--- a/lib/gitlab/kubernetes/helm/api.rb
+++ b/lib/gitlab/kubernetes/helm/api.rb
@@ -8,13 +8,26 @@ module Gitlab
end
def install(command)
- namespace.ensure_exists!
-
- create_service_account(command)
- create_cluster_role_binding(command)
- create_config_map(command)
-
- kubeclient.create_pod(command.pod_resource)
+ begin
+ namespace.ensure_exists!
+
+ create_service_account(command)
+ create_cluster_role_binding(command)
+ Gitlab::AppLogger.info("---CREATING CONFIG MAP-----")
+ Gitlab::AppLogger.info(command)
+ create_config_map(command)
+ Gitlab::AppLogger.info("---CREATING K8s POD-----")
+
+ kubeclient.create_pod(command.pod_resource)
+ rescue StandardError => e
+ Gitlab::AppLogger.info('install_api_error------------------------------------------------')
+ Gitlab::AppLogger.error(e)
+ Gitlab::AppLogger.error(e.backtrace.join("\n"))
+ rescue Exception => e
+ Gitlab::AppLogger.info('install_api_exception--------------------------------------------------')
+ Gitlab::AppLogger.error(e)
+ Gitlab::AppLogger.error(e.backtrace.join("\n"))
+ end
end
def update(command)
@@ -54,6 +67,7 @@ module Gitlab
def create_config_map(command)
command.config_map_resource.tap do |config_map_resource|
+ Gitlab::AppLogger.info(config_map_resource)
kubeclient.create_config_map(config_map_resource)
end
end
diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb
index 1be7924d6ac..fb8d61bc5db 100644
--- a/lib/gitlab/kubernetes/helm/install_command.rb
+++ b/lib/gitlab/kubernetes/helm/install_command.rb
@@ -47,13 +47,16 @@ module Gitlab
name_flag = ['--name', name]
namespace_flag = ['--namespace', Gitlab::Kubernetes::Helm::NAMESPACE]
value_flag = ['-f', "/data/helm/#{name}/config/values.yaml"]
+ a = ['--set', 'ingressShim.defaultIssuerName=letsencrypt-prod']
+ b = ['--set', 'ingressShim.defaultIssuerKind=ClusterIssuer']
+ c = ['--set', 'rbac.create=false']
name_flag +
optional_tls_flags +
optional_version_flag +
optional_rbac_create_flag +
namespace_flag +
- value_flag
+ value_flag + a + b + c
end
def optional_rbac_create_flag