From 7cda7fdb2718d9863c029ad02fbf2a50db023b88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Cunha?= <j.a.cunha@gmail.com>
Date: Sat, 22 May 2021 01:00:22 +0200
Subject: [PATCH 1/2] Pin the GKE version to 1.18 for cluster creation

Basic authentication was removed for GKE cluster versions 1.19
Our API call to create GKE clusters did not specify a cluster version,
thus the integration started breaking as soon as Google defined that
1.19 is the default version.

The quickest solution is to pin the k8s version to 1.18.

Changelog: fixed
---
 lib/google_api/cloud_platform/client.rb           | 5 +++++
 spec/lib/google_api/cloud_platform/client_spec.rb | 1 +
 2 files changed, 6 insertions(+)

diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index f16bd7c735bab4b7..20f9f238604c33d5 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -13,6 +13,10 @@ class Client < GoogleApi::Auth
       LEAST_TOKEN_LIFE_TIME = 10.minutes
       CLUSTER_MASTER_AUTH_USERNAME = 'admin'
       CLUSTER_IPV4_CIDR_BLOCK = '/16'
+      # Don't upgrade to > 1.18 before we move away from Basic Auth
+      # See problem: https://gitlab.com/gitlab-org/gitlab/-/issues/331582
+      # Possible solution: https://gitlab.com/groups/gitlab-org/-/epics/6049
+      GKE_VERSION = '1.18'
       CLUSTER_OAUTH_SCOPES = [
         "https://www.googleapis.com/auth/devstorage.read_only",
         "https://www.googleapis.com/auth/logging.write",
@@ -90,6 +94,7 @@ def make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac,
           cluster: {
             name: cluster_name,
             initial_node_count: cluster_size,
+            initial_cluster_version: GKE_VERSION,
             node_config: {
               machine_type: machine_type,
               oauth_scopes: CLUSTER_OAUTH_SCOPES
diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb
index d217699f79db4c6e..b674ae0218fe67b8 100644
--- a/spec/lib/google_api/cloud_platform/client_spec.rb
+++ b/spec/lib/google_api/cloud_platform/client_spec.rb
@@ -91,6 +91,7 @@
         cluster: {
           name: cluster_name,
           initial_node_count: cluster_size,
+          initial_cluster_version: '1.18',
           node_config: {
             machine_type: machine_type,
             oauth_scopes: [
-- 
GitLab


From 9b1cca7711fa1497c27ef3083005207ed3a21491 Mon Sep 17 00:00:00 2001
From: Alex Kalderimis <akalderimis@gitlab.com>
Date: Tue, 25 May 2021 07:47:33 +0000
Subject: [PATCH 2/2] Prefer 'issue' to 'problem'

---
 lib/google_api/cloud_platform/client.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index 20f9f238604c33d5..34e3be2320becb18 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -14,7 +14,7 @@ class Client < GoogleApi::Auth
       CLUSTER_MASTER_AUTH_USERNAME = 'admin'
       CLUSTER_IPV4_CIDR_BLOCK = '/16'
       # Don't upgrade to > 1.18 before we move away from Basic Auth
-      # See problem: https://gitlab.com/gitlab-org/gitlab/-/issues/331582
+      # See issue: https://gitlab.com/gitlab-org/gitlab/-/issues/331582
       # Possible solution: https://gitlab.com/groups/gitlab-org/-/epics/6049
       GKE_VERSION = '1.18'
       CLUSTER_OAUTH_SCOPES = [
-- 
GitLab