diff options
author | Chris Baumbauer <cab@cabnetworks.net> | 2018-11-26 23:02:33 +0300 |
---|---|---|
committer | Chris Baumbauer <cab@cabnetworks.net> | 2018-11-26 23:46:00 +0300 |
commit | 2937be7b0c46ae97aa89572a9a349ed636198696 (patch) | |
tree | 49757cdd159b2385600d9a08ede07caf07a31313 /app | |
parent | 95ebdf3053ef9aeba657ff9bf1a5a66b608cc6dc (diff) |
Expose external_ip to knative cluster application
Diffstat (limited to 'app')
5 files changed, 76 insertions, 11 deletions
diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue index 8354c28778c..34c510cb468 100644 --- a/app/assets/javascripts/clusters/components/applications.vue +++ b/app/assets/javascripts/clusters/components/applications.vue @@ -168,6 +168,9 @@ export default { knativeInstalled() { return this.applications.knative.status === APPLICATION_STATUS.INSTALLED; }, + knativeExternalIp() { + return this.applications.knative.externalIp; + }, }, created() { this.helmInstallIllustration = helmInstallIllustration; @@ -444,6 +447,49 @@ export default { /> </div> </template> + <template v-if="knativeInstalled"> + <div class="form-group"> + <label for="knative-ip-address"> + {{ s__('ClusterIntegration|Knative IP Address:') }} + </label> + <div v-if="knativeExternalIp" class="input-group"> + <input + id="knative-ip-address" + :value="knativeExternalIp" + type="text" + class="form-control js-ip-address" + readonly + /> + <span class="input-group-append"> + <clipboard-button + :text="knativeExternalIp" + :title="s__('ClusterIntegration|Copy Knative IP Address to clipboard')" + class="input-group-text js-clipboard-btn" + /> + </span> + </div> + <input v-else type="text" class="form-control js-ip-address" readonly value="?" /> + </div> + + <p v-if="!knativeExternalIp" class="settings-message js-no-ip-message"> + {{ + s__(`ClusterIntegration|The IP address is in + the process of being assigned. Please check your Kubernetes + cluster or Quotas on Google Kubernetes Engine if it takes a long time.`) + }} + </p> + + <p> + {{ + s__(`ClusterIntegration|Point a wildcard DNS to this + generated IP address in order to access + your application after it has been deployed.`) + }} + <a :href="ingressDnsHelpPath" target="_blank" rel="noopener noreferrer"> + {{ __('More information') }} + </a> + </p> + </template> </div> </application-row> </div> diff --git a/app/assets/javascripts/clusters/stores/clusters_store.js b/app/assets/javascripts/clusters/stores/clusters_store.js index 3678be59d24..2d69da8eaec 100644 --- a/app/assets/javascripts/clusters/stores/clusters_store.js +++ b/app/assets/javascripts/clusters/stores/clusters_store.js @@ -60,6 +60,7 @@ export default class ClusterStore { requestStatus: null, requestReason: null, hostname: null, + externalIp: null, }, }, }; @@ -111,6 +112,8 @@ export default class ClusterStore { } else if (appId === KNATIVE) { this.state.applications.knative.hostname = serverAppEntry.hostname || this.state.applications.knative.hostname; + this.state.applications.knative.externalIp = + serverAppEntry.external_ip || this.state.applications.knative.externalIp; } }); } diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb index bd0286ee3f9..8f8790585a3 100644 --- a/app/models/clusters/applications/ingress.rb +++ b/app/models/clusters/applications/ingress.rb @@ -51,6 +51,10 @@ module Clusters ClusterWaitForIngressIpAddressWorker.perform_async(name, id) end + + def ingress_service + cluster.kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE) + end end end end diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index c66d5ce54db..c0aaa8dce20 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -6,9 +6,7 @@ module Clusters VERSION = '0.1.3'.freeze REPOSITORY = 'https://storage.googleapis.com/triggermesh-charts'.freeze - # This is required for helm version <= 2.10.x in order to support - # Setting up CRDs - ISTIO_CRDS = 'https://storage.googleapis.com/triggermesh-charts/istio-crds.yaml'.freeze + FETCH_IP_ADDRESS_DELAY = 30.seconds self.table_name = 'clusters_applications_knative' @@ -16,6 +14,16 @@ module Clusters include ::Clusters::Concerns::ApplicationStatus include ::Clusters::Concerns::ApplicationVersion include ::Clusters::Concerns::ApplicationData + include AfterCommitQueue + + state_machine :status do + before_transition any => [:installed] do |application| + application.run_after_commit do + ClusterWaitForIngressIpAddressWorker.perform_in( + FETCH_IP_ADDRESS_DELAY, application.name, application.id) + end + end + end default_value_for :version, VERSION @@ -36,19 +44,23 @@ module Clusters rbac: cluster.platform_kubernetes_rbac?, chart: chart, files: files, - repository: REPOSITORY, - preinstall: install_script + repository: REPOSITORY ) end - def client - cluster.platform_kubernetes.kubeclient.knative_client + def schedule_status_update + return unless installed? + return if external_ip + + ClusterWaitForIngressIpAddressWorker.perform_async(name, id) end - private + def ingress_service + cluster.kubeclient.get_service('knative-ingressgateway', 'istio-system') + end - def install_script - ["/usr/bin/kubectl apply -f #{ISTIO_CRDS}"] + def client + cluster.platform_kubernetes.kubeclient.knative_client end end end diff --git a/app/services/clusters/applications/check_ingress_ip_address_service.rb b/app/services/clusters/applications/check_ingress_ip_address_service.rb index f32e73e8b1c..0ec06e776a7 100644 --- a/app/services/clusters/applications/check_ingress_ip_address_service.rb +++ b/app/services/clusters/applications/check_ingress_ip_address_service.rb @@ -30,7 +30,7 @@ module Clusters def service strong_memoize(:ingress_service) do - kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE) + app.ingress_service end end end |