Skip to content
Snippets Groups Projects
Commit 47cb5a26 authored by Chris Baumbauer's avatar Chris Baumbauer
Browse files

Require Knative to be installed only on an RBAC kubernetes cluster

parent b97b85c3
No related branches found
No related tags found
No related merge requests found
Showing
with 89 additions and 3 deletions
Loading
Loading
@@ -32,6 +32,7 @@ export default class Clusters {
installKnativePath,
installPrometheusPath,
managePrometheusPath,
hasRbac,
clusterType,
clusterStatus,
clusterStatusReason,
Loading
Loading
@@ -45,6 +46,7 @@ export default class Clusters {
this.store.setManagePrometheusPath(managePrometheusPath);
this.store.updateStatus(clusterStatus);
this.store.updateStatusReason(clusterStatusReason);
this.store.updateRbac(hasRbac);
this.service = new ClustersService({
endpoint: statusPath,
installHelmEndpoint: installHelmPath,
Loading
Loading
@@ -102,6 +104,7 @@ export default class Clusters {
ingressHelpPath: this.state.ingressHelpPath,
managePrometheusPath: this.state.managePrometheusPath,
ingressDnsHelpPath: this.state.ingressDnsHelpPath,
rbac: this.state.rbac,
},
});
},
Loading
Loading
Loading
Loading
@@ -52,6 +52,11 @@ export default {
required: false,
default: '',
},
rbac: {
type: Boolean,
required: false,
default: false,
},
},
data: () => ({
elasticsearchLogo,
Loading
Loading
@@ -442,6 +447,18 @@ export default {
title-link="https://github.com/knative/docs"
>
<div slot="description">
<span v-if="!rbac">
<p v-if="!rbac" class="bs-callout bs-callout-info append-bottom-0">
{{
s__(`ClusterIntegration|You must have an RBAC-enabled cluster
to install Knative.`)
}}
<a :href="helpPath" target="_blank" rel="noopener noreferrer">
{{ __('More information') }}
</a>
</p>
<br />
</span>
<p>
{{
s__(`ClusterIntegration|Knative extends Kubernetes to provide
Loading
Loading
@@ -465,7 +482,7 @@ export default {
/>
</div>
</template>
<template v-else-if="helmInstalled">
<template v-else-if="helmInstalled && rbac">
<div class="form-group">
<label for="knative-domainname">
{{ s__('ClusterIntegration|Knative Domain Name:') }}
Loading
Loading
import { s__ } from '../../locale';
import { parseBoolean } from '../../lib/utils/common_utils';
import { INGRESS, JUPYTER, KNATIVE, CERT_MANAGER } from '../constants';
 
export default class ClusterStore {
Loading
Loading
@@ -7,6 +8,7 @@ export default class ClusterStore {
helpPath: null,
ingressHelpPath: null,
status: null,
rbac: false,
statusReason: null,
applications: {
helm: {
Loading
Loading
@@ -81,6 +83,10 @@ export default class ClusterStore {
this.state.status = status;
}
 
updateRbac(rbac) {
this.state.rbac = parseBoolean(rbac);
}
updateStatusReason(reason) {
this.state.statusReason = reason;
}
Loading
Loading
Loading
Loading
@@ -19,6 +19,13 @@ module Clusters
 
self.reactive_cache_key = ->(knative) { [knative.class.model_name.singular, knative.id] }
 
def set_initial_status
return unless not_installable?
return unless verify_cluster?
self.status = 'installable'
end
state_machine :status do
after_transition any => [:installed] do |application|
application.run_after_commit do
Loading
Loading
@@ -99,6 +106,10 @@ module Clusters
def install_knative_metrics
["kubectl apply -f #{METRICS_CONFIG}"] if cluster.application_prometheus_available?
end
def verify_cluster?
cluster&.application_helm_available? && cluster&.platform_kubernetes_rbac?
end
end
end
end
Loading
Loading
@@ -16,6 +16,7 @@
install_jupyter_path: clusterable.install_applications_cluster_path(@cluster, :jupyter),
install_knative_path: clusterable.install_applications_cluster_path(@cluster, :knative),
toggle_status: @cluster.enabled? ? 'true': 'false',
has_rbac: @cluster.platform_kubernetes_rbac? ? 'true': 'false',
cluster_type: @cluster.cluster_type,
cluster_status: @cluster.status_name,
cluster_status_reason: @cluster.status_reason,
Loading
Loading
---
title: Require Knative to be installed only on an RBAC kubernetes cluster
merge_request: 23807
author: Chris Baumbauer
type: changed
Loading
Loading
@@ -1842,6 +1842,9 @@ msgstr ""
msgid "ClusterIntegration|You must first install Helm Tiller before installing the applications below"
msgstr ""
 
msgid "ClusterIntegration|You must have an RBAC-enabled cluster to install Knative."
msgstr ""
msgid "ClusterIntegration|Your account must have %{link_to_kubernetes_engine}"
msgstr ""
 
Loading
Loading
Loading
Loading
@@ -44,6 +44,10 @@ FactoryBot.define do
provider_gcp factory: [:cluster_provider_gcp, :creating]
end
 
trait :rbac_disabled do
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured, :rbac_disabled]
end
trait :disabled do
enabled false
end
Loading
Loading
Loading
Loading
@@ -16,8 +16,8 @@ FactoryBot.define do
end
end
 
trait :rbac_enabled do
authorization_type :rbac
trait :rbac_disabled do
authorization_type :abac
end
end
end
Loading
Loading
@@ -70,6 +70,34 @@ describe 'Clusters Applications', :js do
end
end
 
context 'when user installs Knative' do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
end
context 'on an abac cluster' do
let(:cluster) { create(:cluster, :provided_by_gcp, :rbac_disabled, projects: [project])}
it 'should show info block and not be installable' do
page.within('.js-cluster-application-row-knative') do
expect(page).to have_css('.bs-callout-info')
expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
end
end
end
context 'on an rbac cluster' do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project])}
it 'should not show callout block and be installable' do
page.within('.js-cluster-application-row-knative') do
expect(page).not_to have_css('.bs-callout-info')
expect(page).to have_css('.js-cluster-application-install-button:not([disabled])')
end
end
end
end
context 'when user installs Cert Manager' do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
Loading
Loading
Loading
Loading
@@ -62,6 +62,7 @@ describe('Clusters Store', () => {
ingressHelpPath: null,
status: mockResponseData.status,
statusReason: mockResponseData.status_reason,
rbac: false,
applications: {
helm: {
title: 'Helm Tiller',
Loading
Loading
Loading
Loading
@@ -15,6 +15,13 @@ describe Clusters::Applications::Knative do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
end
 
describe 'when rbac is not enabled' do
let(:cluster) { create(:cluster, :provided_by_gcp, :rbac_disabled) }
let(:knative_no_rbac) { create(:clusters_applications_knative, cluster: cluster) }
it { expect(knative_no_rbac).to be_not_installable }
end
describe '.installed' do
subject { described_class.installed }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment