Commit 18344feb authored by Thong Kuah's avatar Thong Kuah

Merge branch 'remove-kubernetes-service-deployment-platform' into 'master'

Remove Kubernetes service from deployment platform

See merge request gitlab-org/gitlab-ce!29786
parents c92a1e53 d5a0ee92
......@@ -14,9 +14,7 @@ module DeploymentPlatform
def find_deployment_platform(environment)
find_cluster_platform_kubernetes(environment: environment) ||
find_group_cluster_platform_kubernetes_with_feature_guard(environment: environment) ||
find_instance_cluster_platform_kubernetes_with_feature_guard(environment: environment) ||
find_kubernetes_service_integration ||
build_cluster_and_deployment_platform
find_instance_cluster_platform_kubernetes_with_feature_guard(environment: environment)
end
# EE would override this and utilize environment argument
......@@ -48,39 +46,4 @@ module DeploymentPlatform
Clusters::Instance.new.clusters.enabled.default_environment
.first&.platform_kubernetes
end
def find_kubernetes_service_integration
services.deployment.reorder(nil).find_by(active: true)
end
def build_cluster_and_deployment_platform
return unless kubernetes_service_template
cluster = ::Clusters::Cluster.create(cluster_attributes_from_service_template)
cluster.platform_kubernetes if cluster.persisted?
end
def kubernetes_service_template
@kubernetes_service_template ||= KubernetesService.active.find_by_template
end
def cluster_attributes_from_service_template
{
name: 'kubernetes-template',
projects: [self],
cluster_type: :project_type,
provider_type: :user,
platform_type: :kubernetes,
platform_kubernetes_attributes: platform_kubernetes_attributes_from_service_template
}
end
def platform_kubernetes_attributes_from_service_template
{
api_url: kubernetes_service_template.api_url,
ca_pem: kubernetes_service_template.ca_pem,
token: kubernetes_service_template.token,
namespace: kubernetes_service_template.namespace
}
end
end
......@@ -170,12 +170,11 @@ class KubernetesService < Service
def deprecation_message
content = if project
_("Kubernetes service integration has been deprecated. %{deprecated_message_content} your Kubernetes clusters using the new <a href=\"%{url}\"/>Kubernetes Clusters</a> page") % {
deprecated_message_content: deprecated_message_content,
_("Kubernetes service integration has been disabled. Fields on this page are not used by GitLab, you can configure your Kubernetes clusters using the new <a href=\"%{url}\"/>Kubernetes Clusters</a> page") % {
url: Gitlab::Routing.url_helpers.project_clusters_path(project)
}
else
_("The instance-level Kubernetes service integration is deprecated. Your data has been migrated to an <a href=\"%{url}\"/>instance-level cluster</a>.") % {
_("The instance-level Kubernetes service integration is disabled. Your data has been migrated to an <a href=\"%{url}\"/>instance-level cluster</a>.") % {
url: Gitlab::Routing.url_helpers.admin_clusters_path
}
end
......@@ -260,8 +259,4 @@ class KubernetesService < Service
errors[:base] << deprecation_message
end
end
def deprecated_message_content
_("Fields on this page are now uneditable, you can configure")
end
end
---
title: Remove Kubernetes service integration and Kubernetes service template from available deployment platforms
merge_request: 29786
author:
type: removed
......@@ -4408,9 +4408,6 @@ msgstr ""
msgid "February"
msgstr ""
msgid "Fields on this page are now uneditable, you can configure"
msgstr ""
msgid "File"
msgid_plural "Files"
msgstr[0] ""
......@@ -5645,7 +5642,7 @@ msgstr ""
msgid "Kubernetes error: %{error_code}"
msgstr ""
msgid "Kubernetes service integration has been deprecated. %{deprecated_message_content} your Kubernetes clusters using the new <a href=\"%{url}\"/>Kubernetes Clusters</a> page"
msgid "Kubernetes service integration has been disabled. Fields on this page are not used by GitLab, you can configure your Kubernetes clusters using the new <a href=\"%{url}\"/>Kubernetes Clusters</a> page"
msgstr ""
msgid "LFS"
......@@ -10002,7 +9999,7 @@ msgstr ""
msgid "The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination."
msgstr ""
msgid "The instance-level Kubernetes service integration is deprecated. Your data has been migrated to an <a href=\"%{url}\"/>instance-level cluster</a>."
msgid "The instance-level Kubernetes service integration is disabled. Your data has been migrated to an <a href=\"%{url}\"/>instance-level cluster</a>."
msgstr ""
msgid "The invitation could not be accepted."
......
......@@ -8,40 +8,7 @@ describe DeploymentPlatform do
describe '#deployment_platform' do
subject { project.deployment_platform }
context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service and a Kubernetes template configured' do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
it 'returns a platform kubernetes' do
expect(subject).to be_a_kind_of(Clusters::Platforms::Kubernetes)
end
it 'creates a cluster and a platform kubernetes' do
expect { subject }
.to change { Clusters::Cluster.count }.by(1)
.and change { Clusters::Platforms::Kubernetes.count }.by(1)
end
it 'includes appropriate attributes for Cluster' do
cluster = subject.cluster
expect(cluster.name).to eq('kubernetes-template')
expect(cluster.project).to eq(project)
expect(cluster.provider_type).to eq('user')
expect(cluster.platform_type).to eq('kubernetes')
end
it 'creates a platform kubernetes' do
expect { subject }.to change { Clusters::Platforms::Kubernetes.count }.by(1)
end
it 'copies attributes from Clusters::Platform::Kubernetes template into the new Cluster::Platforms::Kubernetes' do
expect(subject.api_url).to eq(kubernetes_service.api_url)
expect(subject.ca_pem).to eq(kubernetes_service.ca_pem)
expect(subject.token).to eq(kubernetes_service.token)
expect(subject.namespace).to eq(kubernetes_service.namespace)
end
end
context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service and no Kubernetes template configured' do
context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service' do
it { is_expected.to be_nil }
end
......@@ -126,23 +93,5 @@ describe DeploymentPlatform do
end
end
end
context 'when user configured kubernetes integration from project services' do
let!(:kubernetes_service) { create(:kubernetes_service, project: project) }
it 'returns the Kubernetes service' do
expect(subject).to eq(kubernetes_service)
end
end
context 'when the cluster creation fails' do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
before do
allow_any_instance_of(Clusters::Cluster).to receive(:persisted?).and_return(false)
end
it { is_expected.to be_nil }
end
end
end
......@@ -7,7 +7,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
include ReactiveCachingHelpers
let(:project) { create(:kubernetes_project) }
let(:service) { project.deployment_platform }
let(:service) { create(:kubernetes_service, project: project) }
describe 'Associations' do
it { is_expected.to belong_to :project }
......@@ -78,7 +78,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it 'includes an error with a deprecation message' do
kubernetes_service.valid?
expect(kubernetes_service.errors[:base].first).to match(/Kubernetes service integration has been deprecated/)
expect(kubernetes_service.errors[:base].first).to match(/Kubernetes service integration has been disabled/)
end
end
......@@ -383,13 +383,13 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
let(:kubernetes_service) { create(:kubernetes_service) }
it 'indicates the service is deprecated' do
expect(kubernetes_service.deprecation_message).to match(/Kubernetes service integration has been deprecated/)
expect(kubernetes_service.deprecation_message).to match(/Kubernetes service integration has been disabled/)
end
context 'if the service is not active' do
it 'returns a message' do
kubernetes_service.update_attribute(:active, false)
expect(kubernetes_service.deprecation_message).to match(/Fields on this page are now uneditable/)
expect(kubernetes_service.deprecation_message).to match(/Fields on this page are not used by GitLab/)
end
end
end
......
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