diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-12 13:38:35 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-12 13:38:35 +0200 |
commit | 7ce5ca385e75265feb84abbfaefe738b55016c28 (patch) | |
tree | f376394b937ad3e64612bf815b0293ddd7229f23 | |
parent | f87809f78de9da04f38134ba5ce0cf9ddebf2f63 (diff) | |
download | gitlab-ce-7ce5ca385e75265feb84abbfaefe738b55016c28.tar.gz |
Add installation of Knative
-rw-r--r-- | app/assets/javascripts/clusters/clusters_bundle.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/clusters/components/applications.vue | 18 | ||||
-rw-r--r-- | app/assets/javascripts/clusters/services/clusters_service.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/clusters/stores/clusters_store.js | 8 | ||||
-rw-r--r-- | app/models/clusters/applications/knative.rb | 38 | ||||
-rw-r--r-- | app/models/clusters/cluster.rb | 7 | ||||
-rw-r--r-- | db/migrate/20180912111628_add_knative_application.rb | 40 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/helm/apply_command.rb | 38 |
9 files changed, 151 insertions, 2 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index ebf76af5966..aaf11bfb361 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -29,6 +29,7 @@ export default class Clusters { installRunnerPath, installJupyterPath, installPrometheusPath, + installKnativePath, managePrometheusPath, clusterStatus, clusterStatusReason, @@ -49,6 +50,7 @@ export default class Clusters { installRunnerEndpoint: installRunnerPath, installPrometheusEndpoint: installPrometheusPath, installJupyterEndpoint: installJupyterPath, + installKnativeEndpoint: installKnativePath, }); this.installApplication = this.installApplication.bind(this); diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue index d708a9e595a..085bf113b45 100644 --- a/app/assets/javascripts/clusters/components/applications.vue +++ b/app/assets/javascripts/clusters/components/applications.vue @@ -341,6 +341,24 @@ export default { </template> </div> </application-row> + <application-row + id="knative" + :title="applications.knative.title" + :status="applications.knative.status" + :status-reason="applications.knative.statusReason" + :request-status="applications.knative.requestStatus" + :request-reason="applications.knative.requestReason" + title-link="https://github.com/knative/docs/" + > + <div slot="description"> + {{ s__(`ClusterIntegration|A Knative build extends Kubernetes + and utilizes existing Kubernetes primitives to provide you with + the ability to run on-cluster container builds from source. + For example, you can write a build that uses Kubernetes-native + resources to obtain your source code from a repository, + build it into container a image, and then run that image.`) }} + </div> + </application-row> <!-- NOTE: Don't forget to update `clusters.scss` min-height for this block and uncomment `application_spec` tests diff --git a/app/assets/javascripts/clusters/services/clusters_service.js b/app/assets/javascripts/clusters/services/clusters_service.js index a7d82292ba9..da562b09ee5 100644 --- a/app/assets/javascripts/clusters/services/clusters_service.js +++ b/app/assets/javascripts/clusters/services/clusters_service.js @@ -9,6 +9,7 @@ export default class ClusterService { runner: this.options.installRunnerEndpoint, prometheus: this.options.installPrometheusEndpoint, jupyter: this.options.installJupyterEndpoint, + knative: this.options.installKnativeEndpoint, }; } diff --git a/app/assets/javascripts/clusters/stores/clusters_store.js b/app/assets/javascripts/clusters/stores/clusters_store.js index d90db7b103c..710203d8184 100644 --- a/app/assets/javascripts/clusters/stores/clusters_store.js +++ b/app/assets/javascripts/clusters/stores/clusters_store.js @@ -46,6 +46,14 @@ export default class ClusterStore { requestReason: null, hostname: null, }, + knative: { + title: s__('ClusterIntegration|Knative'), + status: null, + statusReason: null, + requestStatus: null, + requestReason: null, + hostname: null, + }, }, }; } diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb new file mode 100644 index 00000000000..efcc386483b --- /dev/null +++ b/app/models/clusters/applications/knative.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Clusters + module Applications + class Knative < ActiveRecord::Base + VERSION = '0.1.0'.freeze + + self.table_name = 'clusters_applications_knative' + + include ::Clusters::Concerns::ApplicationCore + include ::Clusters::Concerns::ApplicationStatus + include ::Clusters::Concerns::ApplicationVersion + include ::Clusters::Concerns::ApplicationData + include AfterCommitQueue + + default_value_for :version, VERSION + + def install_command + Gitlab::Kubernetes::Helm::KubectlCommand.new( + name: name, + version: VERSION, + rbac: false, + chart: chart, + files: files + ) + end + + private + + def script + [ + "kubectl apply -f https://raw.githubusercontent.com/knative/serving/v0.1.1/third_party/config/build/release.yaml", + "kubectl apply -f https://github.com/knative/serving/releases/download/v0.1.1/release.yaml" + ] + end + end + end +end diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index d7011ef447a..50d878e6df0 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -11,7 +11,8 @@ module Clusters Applications::Ingress.application_name => Applications::Ingress, Applications::Prometheus.application_name => Applications::Prometheus, Applications::Runner.application_name => Applications::Runner, - Applications::Jupyter.application_name => Applications::Jupyter + Applications::Jupyter.application_name => Applications::Jupyter, + Applications::Knative.application_name => Applications::Knative }.freeze DEFAULT_ENVIRONMENT = '*'.freeze @@ -30,6 +31,7 @@ module Clusters 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' + has_one :application_knative, class_name: 'Clusters::Applications::Knative' accepts_nested_attributes_for :provider_gcp, update_only: true accepts_nested_attributes_for :platform_kubernetes, update_only: true @@ -81,7 +83,8 @@ module Clusters application_ingress || build_application_ingress, application_prometheus || build_application_prometheus, application_runner || build_application_runner, - application_jupyter || build_application_jupyter + application_jupyter || build_application_jupyter, + application_knative || build_application_knative ] end diff --git a/db/migrate/20180912111628_add_knative_application.rb b/db/migrate/20180912111628_add_knative_application.rb new file mode 100644 index 00000000000..f1b44f07267 --- /dev/null +++ b/db/migrate/20180912111628_add_knative_application.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddKnativeApplication < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def change + create_table "clusters_applications_knative" 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.string "version", null: false + t.text "status_reason" + end + end +end diff --git a/lib/gitlab/kubernetes/helm.rb b/lib/gitlab/kubernetes/helm.rb index 4a1bdf34c3e..e1bc6867115 100644 --- a/lib/gitlab/kubernetes/helm.rb +++ b/lib/gitlab/kubernetes/helm.rb @@ -2,6 +2,7 @@ module Gitlab module Kubernetes module Helm HELM_VERSION = '2.7.2'.freeze + KUBECTL_VERSION = 'v1.11.0' NAMESPACE = 'gitlab-managed-apps'.freeze SERVICE_ACCOUNT = 'tiller'.freeze CLUSTER_ROLE_BINDING = 'tiller-admin'.freeze diff --git a/lib/gitlab/kubernetes/helm/apply_command.rb b/lib/gitlab/kubernetes/helm/apply_command.rb new file mode 100644 index 00000000000..c9ad8dc793c --- /dev/null +++ b/lib/gitlab/kubernetes/helm/apply_command.rb @@ -0,0 +1,38 @@ +module Gitlab + module Kubernetes + module Helm + class KubectlCommand + include BaseCommand + + attr_reader :name, :scripts, :files + + def initialize(name:, scripts:, files:) + @name = name + @files = files + @rbac = false + @scripts = scripts + end + + def base_script + <<~HEREDOC + set -eo pipefail + ALPINE_VERSION=$(cat /etc/alpine-release | cut -d '.' -f 1,2) + echo http://mirror.clarkson.edu/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories + echo http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories + apk add -U wget ca-certificates openssl >/dev/null + wget -q https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/darwin/amd64/kubectl + mv /usr/bin/ + HEREDOC + end + + def generate_script + (base_script + scripts).join("\n") + end + + def rbac? + @rbac + end + end + end + end +end |