Skip to content
Snippets Groups Projects

Resolve "Gitlab doesn't detect the deployment pods after K8s cluster upgrade to v1.22"

All threads resolved!
3 files
+ 24
155
Compare changes
  • Side-by-side
  • Inline
Files
3
  • 42e5c35c
    The extensions/v1beta1 was removed on Kubernetes 1.22: https://kubernetes.io/blog/2021/07/14/upcoming-changes-in-kubernetes-1-22/
    Whenever we call extensions_client.discover the code raises a 404 not found and we fail to load deployments and ingresses.
    Consequently our deploy_boards also fail.
    
    The fix is simply to not use this client anymore, since we don't need to look for resources in this APIs anymore.
    We should simply use the new APIs as suggested by the Kubernetes 1.22 documentation.
    That is networking.k8s.io/v1 for ingresses and apps/v1 for deployments.
    
    Changelog: fixed
@@ -81,6 +81,10 @@ class KubeClient
:update_gateway,
to: :istio_client
delegate :get_ingresses, :patch_ingress, to: :networking_client
delegate :get_deployments, to: :apps_client
attr_reader :api_prefix, :kubeclient_options
DEFAULT_KUBECLIENT_OPTIONS = {
@@ -127,46 +131,6 @@ def initialize(api_prefix, **kubeclient_options)
validate_url!
end
# Deployments resource is currently on the apis/extensions api group
# until Kubernetes 1.15. Kubernetest 1.16+ has deployments resources in
# the apis/apps api group.
#
# As we still support Kubernetes 1.12+, we will need to support both.
def get_deployments(**args)
extensions_client.discover unless extensions_client.discovered
if extensions_client.respond_to?(:get_deployments)
extensions_client.get_deployments(**args)
else
apps_client.get_deployments(**args)
end
end
# Ingresses resource is currently on the apis/extensions api group
# until Kubernetes 1.21. Kubernetest 1.22+ has ingresses resources in
# the networking.k8s.io/v1 api group.
#
# As we still support Kubernetes 1.12+, we will need to support both.
def get_ingresses(**args)
extensions_client.discover unless extensions_client.discovered
if extensions_client.respond_to?(:get_ingresses)
extensions_client.get_ingresses(**args)
else
networking_client.get_ingresses(**args)
end
end
def patch_ingress(*args)
extensions_client.discover unless extensions_client.discovered
if extensions_client.respond_to?(:patch_ingress)
extensions_client.patch_ingress(*args)
else
networking_client.patch_ingress(*args)
end
end
def create_or_update_cluster_role_binding(resource)
update_cluster_role_binding(resource)
end
Loading