Skip to content

Migrate existing data from KubernetesService to Clusters::Platforms::Kubernetes

What does this MR do?

V2

SELECT services.*
FROM services
INNER JOIN projects ON projects.id = services.project_id
WHERE services.category = 'deployment' AND services.type = 'KubernetesService' AND
    NOT EXISTS (
        SELECT 1 FROM cluster_platforms_kubernetes
        INNER JOIN cluster_projects ON cluster_projects.project_id = projects.id
        WHERE cluster_projects.cluster_id = cluster_platforms_kubernetes.cluster_id AND
            services.properties LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')
    );

Find target kubernetes_services

SELECT s.active, s.properties, projects.name, clusters.name, cluster_platforms_kubernetes.api_url
FROM services AS s
INNER JOIN projects ON projects.id = s.project_id
INNER JOIN cluster_projects ON projects.id = cluster_projects.project_id
INNER JOIN clusters ON cluster_projects.cluster_id = clusters.id
INNER JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = clusters.id
WHERE s.category = 'deployment' AND s.type = 'KubernetesService' 
    AND (
        cluster_projects.project_id IS NULL -- Cluster doesn't exist
        OR
        s.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')  -- Cluster exists but KubernetesService configured independently
    )
;

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #40418 (closed)

Edited by Yorick Peterse

Merge request reports

Loading