Commit e4c1ee5d authored by Amit Rathi's avatar Amit Rathi
Browse files

Pushing WIP state for backup

parent aef40d78759b
......@@ -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,
......
......@@ -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;
},
......@@ -275,6 +280,28 @@ export default {
</div>
</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"
......
......@@ -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,
......
......@@ -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,
......
......@@ -9,6 +9,7 @@ class Cluster < ActiveRecord::Base
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 @@ class Cluster < ActiveRecord::Base
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 @@ def applications
[
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
......
......@@ -27,9 +27,11 @@ def on_success
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
......
......@@ -19,6 +19,10 @@ def execute(request)
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 @@ def builders
{
"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 }
......
......@@ -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
......
......@@ -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),
......
......@@ -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
......
......@@ -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 @@
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 @@
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 @@
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
......
......@@ -8,13 +8,26 @@ def initialize(kubeclient)
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 @@ def get_config_map(config_map_name)
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
......
......@@ -47,13 +47,16 @@ def install_command_flags
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
......
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