Using the GitLab kas chart

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed

The kas sub-chart provides a configurable deployment of the GitLab agent server (KAS). The agent server is a component you install together with GitLab. It is required to manage the GitLab agent for Kubernetes.

This chart depends on access to the GitLab API and the Gitaly Servers. When you enable this chart, an Ingress is deployed.

To consume minimal resources, the kas container uses a distroless image. The deployed services are exposed by an Ingress, which uses WebSocket proxying for communication. This proxy allows long-lived connections with the external component, agentk. agentk is the Kubernetes cluster-side agent counterpart.

The route to access the service depends on your Ingress configuration.

For more information, see the GitLab agent for Kubernetes architecture.

Disable the agent server

The GitLab agent server (kas) is enabled by default. To disable it on your GitLab instance, set the Helm property global.kas.enabled to false.

For example:

helm upgrade --install kas --set global.kas.enabled=false

Specify an Ingress

When you use the chart’s Ingress with the default configuration, the service for the agent server is reachable on a subdomain. For example, for global.hosts.domain: example.com, the agent server is reachable at kas.example.com.

The KAS Ingress can use a different domain than the global.hosts.domain.

Set global.hosts.kas.name, for example:

global.hosts.kas.name: kas.my-other-domain.com

This example uses kas.my-other-domain.com as the host for the KAS Ingress alone. The rest of the services (including GitLab, Registry, MinIO, etc.) use the domain specified in global.hosts.domain.

Installation command line options

You can pass these parameters to the helm install command by using the --set flags.

ParameterDefaultDescription
affinity{}Affinity rules for pod assignment
annotations{}Pod annotations.
common.labels{}Supplemental labels that are applied to all objects created by this chart.
securityContext.runAsUser65532User ID under which the pod should be started
securityContext.runAsGroup65534Group ID under which the pod should be started
securityContext.fsGroup65532Group ID under which the pod should be started
securityContext.fsGroupChangePolicyPolicy for changing ownership and permission of the volume (requires Kubernetes 1.23)
securityContext.seccompProfile.typeRuntimeDefaultSeccomp profile to use
containerSecurityContext.runAsUser65532Override container securityContext user ID under which the container is started
containerSecurityContext.allowPrivilegeEscalationfalseControls whether a process of the container can gain more privileges than its parent process
containerSecurityContext.runAsNonRoottrueControls whether the container runs with a non-root user
containerSecurityContext.capabilities.drop[ "ALL" ]Removes Linux capabilities for the Gitaly container
extraContainersMultiline literal style string containing a list of containers to include.
extraEnvList of extra environment variables to expose
extraEnvFromList of extra environment variables from other data sources to expose
init.containerSecurityContextinit container securityContext overrides
init.containerSecurityContext.allowPrivilegeEscalationfalseinitContainer specific: Controls whether a process can gain more privileges than its parent process
init.containerSecurityContext.runAsNonRoottrueinitContainer specific: Controls whether the container runs with a non-root user
init.containerSecurityContext.capabilities.drop[ "ALL" ]initContainer specific: Removes Linux capabilities for the container
image.repositoryregistry.gitlab.com/gitlab-org/build/cng/gitlab-kasImage repository.
image.tagv13.7.0Image tag.
hpa.behavior{scaleDown: {stabilizationWindowSeconds: 300 }}Behavior contains the specifications for up- and downscaling behavior (requires autoscaling/v2beta2 or higher).
hpa.customMetrics[]Custom metrics contains the specifications for which to use to calculate the desired replica count (overrides the default use of Average CPU Utilization configured in targetAverageUtilization).
hpa.cpu.targetTypeAverageValueSet the autoscaling CPU target type, must be either Utilization or AverageValue.
hpa.cpu.targetAverageValue100mSet the autoscaling CPU target value.
hpa.cpu.targetAverageUtilizationSet the autoscaling CPU target utilization.
hpa.memory.targetTypeSet the autoscaling memory target type, must be either Utilization or AverageValue.
hpa.memory.targetAverageValueSet the autoscaling memory target value.
hpa.memory.targetAverageUtilizationSet the autoscaling memory target utilization.
hpa.targetAverageValueDEPRECATED Set the autoscaling CPU target value
ingress.enabledtrue if global.kas.enabled=trueYou can use kas.ingress.enabled to explicitly turn it on or off. If not set, you can optionally use global.ingress.enabled for the same purpose.
ingress.apiVersionValue to use in the apiVersion field.
ingress.annotations{}Ingress annotations.
ingress.tls{}Ingress TLS configuration.
ingress.agentPath/Ingress path for the agent API endpoint.
ingress.k8sApiPath/k8s-proxyIngress path for Kubernetes API endpoint.
keda.enabledfalseUse KEDA ScaledObjects instead of HorizontalPodAutoscalers
keda.pollingInterval30The interval to check each trigger on
keda.cooldownPeriod300The period to wait after the last trigger reported active before scaling the resource back to 0
keda.minReplicaCountMinimum number of replicas KEDA will scale the resource down to, defaults to minReplicas
keda.maxReplicaCountMaximum number of replicas KEDA will scale the resource up to, defaults to maxReplicas
keda.fallbackKEDA fallback configuration, see the documentation
keda.hpaNameThe name of the HPA resource KEDA will create, defaults to keda-hpa-{scaled-object-name}
keda.restoreToOriginalReplicaCountSpecifies whether the target resource should be scaled back to original replicas count after the ScaledObject is deleted
keda.behaviorThe specifications for up- and downscaling behavior, defaults to hpa.behavior
keda.triggersList of triggers to activate scaling of the target resource, defaults to triggers computed from hpa.cpu and hpa.memory
metrics.enabledtrueIf a metrics endpoint should be made available for scraping.
metrics.path/metricsMetrics endpoint path.
metrics.serviceMonitor.enabledfalseIf a ServiceMonitor should be created to enable Prometheus Operator to manage the metrics scraping. Enabling removes the prometheus.io scrape annotations. It cannot be enabled together with metrics.podMonitor.enabled.
metrics.serviceMonitor.additionalLabels{}Additional labels to add to the ServiceMonitor.
metrics.serviceMonitor.endpointConfig{}Additional endpoint configuration for the ServiceMonitor.
metrics.podMonitor.enabledfalseIf a PodMonitor should be created to enable Prometheus Operator to manage the metrics scraping. Enabling removes the prometheus.io scrape annotations. It cannot be enabled together with metrics.serviceMonitor.enabled.
metrics.podMonitor.additionalLabels{}Additional labels to add to the PodMonitor.
metrics.podMonitor.endpointConfig{}Additional endpoint configuration for the PodMonitor.
maxReplicas10HPA maxReplicas.
maxUnavailable1HPA maxUnavailable.
minReplicas2HPA maxReplicas.
nodeSelectorDefine a nodeSelector for the Pods of this Deployment, if present.
observability.port8151Observability endpoint port. Used for metrics and probe endpoints.
observability.livenessProbe.path/livenessURI for the liveness probe endpoint. This value has to match the observability.liveness_probe.url_path value from the KAS service configuration.
observability.readinessProbe.path/readinessURI for the readiness probe endpoint. This value has to match the observability.readiness_probe.url_path value from the KAS service configuration.
serviceAccount.annotations{}Service account annotations.
podLabels{}Supplemental Pod labels. Not used for selectors.
serviceLabels{}Supplemental service labels.
common.labelsSupplemental labels that are applied to all objects created by this chart.
redis.enabledtrueAllows opting-out of using Redis for KAS features. Warnings: Redis will become a hard dependency soon, so this key is already deprecated.
resources.requests.cpu100mMinimum CPU request per KAS pod
resources.requests.memory256MiMinimum memory request per KAS pod memory.
service.externalPort8150External port (for agentk connections).
service.internalPort8150Internal port (for agentk connections).
service.apiInternalPort8153Internal port for the internal API (for GitLab backend).
service.loadBalancerIPnilA custom load balancer IP when service.type is LoadBalancer.
service.loadBalancerSourceRangesnilA list of custom load balancer source ranges when service.type is LoadBalancer.
service.kubernetesApiPort8154External port to expose proxied Kubernetes API on.
service.privateApiPort8155Internal port to expose kas’ private API on (for kas -> kas communication).
serviceAccount.annotations{}ServiceAccount annotations.
serviceAccount.automountServiceAccountTokenfalseIndicates whether or not the default ServiceAccount access token should be mounted in pods.
serviceAccount.createfalseIndicates whether or not a ServiceAccount should be created.
serviceAccount.enabledfalseIndicates whether or not to use a ServiceAccount.
serviceAccount.nameName of the ServiceAccount. If not set, the full chart name is used.
websocketToken.secretAutogeneratedThe name of the secret to use for WebSocket Token signing and verification.
websocketToken.keyAutogeneratedThe name of the key in websocketToken.secret to use.
privateApi.secretAutogeneratedThe name of the secret to use for authenticating with the database.
privateApi.keyAutogeneratedThe name of the key in privateApi.secret to use.
global.kas.service.apiExternalPort8153External port for the internal API (for GitLab backend).
service.typeClusterIPService type.
tolerations[]Toleration labels for pod assignment.
customConfig{}When given, merges the default kas configuration with these values giving precedence to those defined here.
deployment.minReadySeconds0Minimum number of seconds that must pass before a kas pod is considered ready.
deployment.strategy{}Allows one to configure the update strategy utilized by the deployment.
deployment.terminationGracePeriodSeconds300How much time in seconds a Pod is allowed to spend shutting down after receiving SIGTERM.
priorityClassNamePriority class assigned to pods.

Enable TLS communication

Enable TLS communication between your kas pods and other GitLab chart components, through the global KAS attribute.

Test the kas chart

To install the chart:

  1. Create your own Kubernetes cluster.

  2. Check out the merge request’s working branch.

  3. Install (or upgrade) GitLab with kas enabled by default from your local chart branch:

    helm upgrade --force --install gitlab . \
      --timeout 600s \
      --set global.hosts.domain=your.domain.com \
      --set global.hosts.externalIP=XYZ.XYZ.XYZ.XYZ \
      --set certmanager-issuer.email=your@email.com
  4. Use the GDK to run the process to configure and use the GitLab agent for Kubernetes: (You can also follow the steps to configure and use the agent manually.)

    1. From your GDK GitLab repository, move into the QA folder: cd qa.

    2. Run the following command to run the QA test:

      GITLAB_USERNAME=$ROOT_USER
      GITLAB_PASSWORD=$ROOT_PASSWORD
      GITLAB_ADMIN_USERNAME=$ROOT_USER
      GITLAB_ADMIN_PASSWORD=$ROOT_PASSWORD
      bundle exec bin/qa Test::Instance::All https://your.gitlab.domain/ -- --tag orchestrated --tag quarantine qa/specs/features/ee/api/7_configure/kubernetes/kubernetes_agent_spec.rb

      You can also customize the agentk version to install with an environment variable: GITLAB_AGENTK_VERSION=v13.7.1

Configuring KEDA

This keda section enables the installation of KEDA ScaledObjects instead of regular HorizontalPodAutoscalers. This configuration is optional and can be used when there is a need for autoscaling based on custom or external metrics.

Most settings default to the values set in the hpa section where applicable.

If the following are true, CPU and memory triggers are added automatically based on the CPU and memory thresholds set in the hpa section:

  • triggers is not set.
  • The corresponding request.cpu.request or request.memory.request setting is also set to a non-zero value.

If no triggers are set, the ScaledObject is not created.

Refer to the KEDA documentation for more details about those settings.

NameTypeDefaultDescription
enabledBooleanfalseUse KEDA ScaledObjects instead of HorizontalPodAutoscalers
pollingIntervalInteger30The interval to check each trigger on
cooldownPeriodInteger300The period to wait after the last trigger reported active before scaling the resource back to 0
minReplicaCountIntegerMinimum number of replicas KEDA will scale the resource down to, defaults to minReplicas
maxReplicaCountIntegerMaximum number of replicas KEDA will scale the resource up to, defaults to maxReplicas
fallbackMapKEDA fallback configuration, see the documentation
hpaNameStringThe name of the HPA resource KEDA will create, defaults to keda-hpa-{scaled-object-name}
restoreToOriginalReplicaCountBooleanSpecifies whether the target resource should be scaled back to original replicas count after the ScaledObject is deleted
behaviorMapThe specifications for up- and downscaling behavior, defaults to hpa.behavior
triggersArrayList of triggers to activate scaling of the target resource, defaults to triggers computed from hpa.cpu and hpa.memory

serviceAccount

This section controls if a ServiceAccount should be created and if the default access token should be mounted in pods.

NameTypeDefaultDescription
annotationsMap{}ServiceAccount annotations.
automountServiceAccountTokenBooleanfalseControls if the default ServiceAccount access token should be mounted in pods. You should not enable this unless it is required by certain sidecars to work properly (for example, Istio).
createBooleanfalseIndicates whether or not a ServiceAccount should be created.
enabledBooleanfalseIndicates whether or not to use a ServiceAccount.
nameStringName of the ServiceAccount. If not set, the full chart name is used.

affinity

For more information, see affinity.

Enable debug logging

To enable debug logging for the KAS sub-chart, add the following to the kas section of your values.yaml file:

customConfig:
   observability:
      logging:
         level: debug
         grpc_level: debug