info:To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
comments:false
description:'GitLabtoKubernetescommunication'
---
# GitLab to Kubernetes communication
The goal of this document is to define how GitLab can communicate with Kubernetes
and in-cluster services through the GitLab Kubernetes Agent.
## Challenges
### Lack of network connectivity
For various features that exist today, GitLab communicates with Kubernetes by directly
or indirectly calling its API endpoints. This works well, as long as a network
path from GitLab to the cluster exists, which isn't always the case:
- GitLab.com and a self-managed cluster, where the cluster is not exposed to the Internet.
- GitLab.com and a cloud-vendor managed cluster, where the cluster is not exposed to the Internet.
- Self-managed GitLab and a cloud-vendor managed cluster, where the cluster is not
exposed to the Internet and there is no private peering between the cloud network
and the customer's network.
This last item is the hardest to address, as something must give to create a network
path. This feature gives the customer an extra option (exposing the `gitlab-kas` domain but
not the whole GitLab) in addition to the existing options (peering the networks,
or exposing one of the two sides).
Even if technically possible, it's almost always undesirable to expose a Kubernetes
cluster's API to the Internet for security reasons. As a result, our customers
are reluctant to do so, and are faced with a choice of security versus the features
GitLab provides for connected clusters.
This choice is true not only for Kubernetes' API, but for all APIs exposed by services
running on a customer's cluster that GitLab may need to access. For example,
Prometheus running in a cluster must be exposed for the GitLab integration to access it.
### Cluster-admin permissions
Both current integrations - building your own cluster (certificate-based) and GitLab-managed
cluster in a cloud - require granting full `cluster-admin` access to GitLab. Credentials
are stored on the GitLab side and this is yet another security concern for our customers.
# This class is used for non ActiveRecord models but this method is not
# applicable for that so we raise.
raise"elastic_index_dependant_association is not applicable as this class is not an ActiveRecord model."unlessself<ActiveRecord::Base
# Validate these are actually correct associations before sending to
# Sidekiq to avoid errors occuring when the job is picked up.
raise"Invalid association to index. \"#{association_name}\" is either not a collection or not an association. Hint: You must declare the has_many before declaring elastic_index_dependant_association."unlessreflect_on_association(association_name)&.collection?
.toraise_error("Invalid association to index. \"foo_bars\" is either not a collection or not an association. Hint: You must declare the has_many before declaring elastic_index_dependant_association.")
end
end
context'when the class is not an ApplicationRecord'do