Gerrit Operator - API Reference

  1. Gerrit Operator - API Reference
    1. General Remarks
      1. Inheritance
    2. GerritCluster
    3. Gerrit
    4. Receiver
    5. GitGarbageCollection
    6. GerritClusterSpec
    7. GerritClusterStatus
    8. GerritStorageConfig
    9. StorageClassConfig
    10. NfsWorkaroundConfig
    11. SharedStorage
    12. OptionalSharedStorage
    13. ContainerImageConfig
    14. BusyBoxImage
    15. GerritRepositoryConfig
    16. GerritClusterIngressConfig
    17. IngressType
    18. GerritIngressTlsConfig
    19. GerritTemplate
    20. GerritTemplateSpec
    21. GerritProbe
    22. GerritServiceConfig
    23. GerritSite
    24. GerritPlugin
    25. GerritMode
    26. GerritSpec
    27. GerritStatus
    28. IngressConfig
    29. ReceiverSpec
    30. ReceiverStatus
    31. ReceiverProbe
    32. ReceiverServiceConfig
    33. GitGarbageCollectionSpec
    34. GitGarbageCollectionStatus
    35. GitGcState

General Remarks

Inheritance

Some objects inherit the fields of other objects. In this case the section will contain an Extends: label to link to the parent object, but it will not repeat inherited fields.

GerritCluster


Group: gerritoperator.google.com
Version: v1alpha2
Kind: GerritCluster


FieldTypeDescription
apiVersionStringAPIVersion of this resource
kindStringKind of this resource
metadataObjectMetaMetadata of the resource
specGerritClusterSpecSpecification for GerritCluster
statusGerritClusterStatusStatus for GerritCluster

Example:

apiVersion: "gerritoperator.google.com/v1alpha2"
kind: GerritCluster
metadata:
  name: gerrit
spec:
  containerImages:
    imagePullSecrets: []
    imagePullPolicy: Always
    gerritImages:
      registry: docker.io
      org: k8sgerrit
      tag: latest
    busyBox:
      registry: docker.io
      tag: latest

  storage:
    storageClasses:
      readWriteOnce: default
      readWriteMany: shared-storage
      nfsWorkaround:
        enabled: false
        chownOnStartup: false
        idmapdConfig: |-
          [General]
            Verbosity = 0
            Domain = localdomain.com

          [Mapping]
            Nobody-User = nobody
            Nobody-Group = nogroup

    gitRepositoryStorage:
      size: 1Gi
      volumeName: ""
      selector:
        matchLabels:
          volume-type: ssd
          aws-availability-zone: us-east-1

    logsStorage:
      size: 1Gi
      volumeName: ""
      selector:
        matchLabels:
          volume-type: ssd
          aws-availability-zone: us-east-1

    pluginCacheStorage:
      enabled: false
      size: 1Gi
      volumeName: ""
      selector:
        matchLabels:
          volume-type: ssd
          aws-availability-zone: us-east-1

  ingress:
    enabled: true
    type: INGRESS
    host: example.com
    annotations: {}
    tls:
      enabled: false
      secret: ""

  gerrits:
  - metadata:
      name: gerrit
      labels:
        app: gerrit
    spec:
      tolerations:
      - key: key1
        operator: Equal
        value: value1
        effect: NoSchedule

      affinity:
        nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: disktype
              operator: In
              values:
              - ssd

      topologySpreadConstraints: []
      - maxSkew: 1
        topologyKey: zone
        whenUnsatisfiable: DoNotSchedule
        labelSelector:
          matchLabels:
            foo: bar

      priorityClassName: ""

      replicas: 1
      updatePartition: 0

      resources:
        requests:
          cpu: 1
          memory: 5Gi
        limits:
          cpu: 1
          memory: 6Gi

      startupProbe:
        initialDelaySeconds: 0
        periodSeconds: 10
        timeoutSeconds: 1
        successThreshold: 1
        failureThreshold: 3

      readinessProbe:
        initialDelaySeconds: 0
        periodSeconds: 10
        timeoutSeconds: 1
        successThreshold: 1
        failureThreshold: 3

      livenessProbe:
        initialDelaySeconds: 0
        periodSeconds: 10
        timeoutSeconds: 1
        successThreshold: 1
        failureThreshold: 3

      gracefulStopTimeout: 30

      service:
        type: NodePort
        httpPort: 80
        sshPort: 29418

      mode: PRIMARY

      site:
        size: 1Gi

      plugins:
      # Installs a packaged plugin
      - name: delete-project

      # Downloads and installs a plugin
      - name: javamelody
        url: https://gerrit-ci.gerritforge.com/view/Plugins-stable-3.6/job/plugin-javamelody-bazel-master-stable-3.6/lastSuccessfulBuild/artifact/bazel-bin/plugins/javamelody/javamelody.jar
        sha1: 40ffcd00263171e373a24eb6a311791b2924707c

      # If the `installAsLibrary` option is set to `true` the plugin's jar-file will
      # be symlinked to the lib directory and thus installed as a library as well.
      - name: saml
        url: https://gerrit-ci.gerritforge.com/view/Plugins-stable-3.6/job/plugin-saml-bazel-master-stable-3.6/lastSuccessfulBuild/artifact/bazel-bin/plugins/saml/saml.jar
        sha1: 6dfe8292d46b179638586e6acf671206f4e0a88b
        installAsLibrary: true

      configFiles:
        gerrit.config: |-
            [gerrit]
              serverId = gerrit-1
              disableReverseDnsLookup = true
            [index]
              type = LUCENE
            [auth]
              type = DEVELOPMENT_BECOME_ANY_ACCOUNT
            [httpd]
              requestLog = true
              gracefulStopTimeout = 1m
            [transfer]
              timeout = 120 s
            [user]
              name = Gerrit Code Review
              email = gerrit@example.com
              anonymousCoward = Unnamed User
            [container]
              javaOptions = -Xms200m
              javaOptions = -Xmx4g

      secrets:
      - gerrit-secure-config

Gerrit


Group: gerritoperator.google.com
Version: v1alpha2
Kind: Gerrit


FieldTypeDescription
apiVersionStringAPIVersion of this resource
kindStringKind of this resource
metadataObjectMetaMetadata of the resource
specGerritSpecSpecification for Gerrit
statusGerritStatusStatus for Gerrit

Example:

apiVersion: "gerritoperator.google.com/v1alpha2"
kind: Gerrit
metadata:
  name: gerrit
spec:
  tolerations:
    - key: key1
      operator: Equal
      value: value1
      effect: NoSchedule

    affinity:
      nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: disktype
            operator: In
            values:
            - ssd

    topologySpreadConstraints: []
    - maxSkew: 1
      topologyKey: zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          foo: bar

    priorityClassName: ""

    replicas: 1
    updatePartition: 0

    resources:
      requests:
        cpu: 1
        memory: 5Gi
      limits:
        cpu: 1
        memory: 6Gi

    startupProbe:
      initialDelaySeconds: 0
      periodSeconds: 10
      timeoutSeconds: 1
      successThreshold: 1
      failureThreshold: 3

    readinessProbe:
      initialDelaySeconds: 0
      periodSeconds: 10
      timeoutSeconds: 1
      successThreshold: 1
      failureThreshold: 3

    livenessProbe:
      initialDelaySeconds: 0
      periodSeconds: 10
      timeoutSeconds: 1
      successThreshold: 1
      failureThreshold: 3

    gracefulStopTimeout: 30

    service:
      type: NodePort
      httpPort: 80
      sshPort: 29418

    mode: PRIMARY

    site:
      size: 1Gi

    plugins:
    # Installs a plugin packaged into the gerrit.war file
    - name: delete-project

    # Downloads and installs a plugin
    - name: javamelody
      url: https://gerrit-ci.gerritforge.com/view/Plugins-stable-3.6/job/plugin-javamelody-bazel-master-stable-3.6/lastSuccessfulBuild/artifact/bazel-bin/plugins/javamelody/javamelody.jar
      sha1: 40ffcd00263171e373a24eb6a311791b2924707c

    # If the `installAsLibrary` option is set to `true` the plugin jar-file will
    # be symlinked to the lib directory and thus installed as a library as well.
    - name: saml
      url: https://gerrit-ci.gerritforge.com/view/Plugins-stable-3.6/job/plugin-saml-bazel-master-stable-3.6/lastSuccessfulBuild/artifact/bazel-bin/plugins/saml/saml.jar
      sha1: 6dfe8292d46b179638586e6acf671206f4e0a88b
      installAsLibrary: true

    configFiles:
      gerrit.config: |-
          [gerrit]
            serverId = gerrit-1
            disableReverseDnsLookup = true
          [index]
            type = LUCENE
          [auth]
            type = DEVELOPMENT_BECOME_ANY_ACCOUNT
          [httpd]
            requestLog = true
            gracefulStopTimeout = 1m
          [transfer]
            timeout = 120 s
          [user]
            name = Gerrit Code Review
            email = gerrit@example.com
            anonymousCoward = Unnamed User
          [container]
            javaOptions = -Xms200m
            javaOptions = -Xmx4g

    secrets:
    - gerrit-secure-config

  containerImages:
    imagePullSecrets: []
    imagePullPolicy: Always
    gerritImages:
      registry: docker.io
      org: k8sgerrit
      tag: latest
    busyBox:
      registry: docker.io
      tag: latest

  storage:
    storageClasses:
      readWriteOnce: default
      readWriteMany: shared-storage
      nfsWorkaround:
        enabled: false
        chownOnStartup: false
        idmapdConfig: |-
          [General]
            Verbosity = 0
            Domain = localdomain.com

          [Mapping]
            Nobody-User = nobody
            Nobody-Group = nogroup

    gitRepositoryStorage:
      size: 1Gi
      volumeName: ""
      selector:
        matchLabels:
          volume-type: ssd
          aws-availability-zone: us-east-1

    logsStorage:
      size: 1Gi
      volumeName: ""
      selector:
        matchLabels:
          volume-type: ssd
          aws-availability-zone: us-east-1

    pluginCacheStorage:
      enabled: false
      size: 1Gi
      volumeName: ""
      selector:
        matchLabels:
          volume-type: ssd
          aws-availability-zone: us-east-1

  ingress:
    type: INGRESS
    host: example.com
    tlsEnabled: false

Receiver


Group: gerritoperator.google.com
Version: v1alpha1
Kind: Receiver


FieldTypeDescription
apiVersionStringAPIVersion of this resource
kindStringKind of this resource
metadataObjectMetaMetadata of the resource
specReceiverSpecSpecification for Receiver
statusReceiverStatusStatus for Receiver

Example:

apiVersion: "gerritoperator.google.com/v1alpha1"
kind: Receiver
metadata:
  name: receiver
spec:
  cluster: gerrit
  tolerations:
  - key: key1
    operator: Equal
    value: value1
    effect: NoSchedule

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: disktype
            operator: In
            values:
            - ssd

  topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: zone
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        foo: bar

  priorityClassName: ""

  replicas: 1
  maxSurge: 1
  maxUnavailable: 1

  resources: {}
    requests:
      cpu: 1
      memory: 5Gi
    limits:
      cpu: 1
      memory: 6Gi

  readinessProbe:
    initialDelaySeconds: 0
    periodSeconds: 10
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3

  livenessProbe:
    initialDelaySeconds: 0
    periodSeconds: 10
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3

  service:
    type: NodePort
    httpPort: 80

  credentialSecretRef: apache-credentials

GitGarbageCollection


Group: gerritoperator.google.com
Version: v1alpha1
Kind: GitGarbageCollection


FieldTypeDescription
apiVersionStringAPIVersion of this resource
kindStringKind of this resource
metadataObjectMetaMetadata of the resource
specGitGarbageCollectionSpecSpecification for GitGarbageCollection
statusGitGarbageCollectionStatusStatus for GitGarbageCollection

Example:

apiVersion: "gerritoperator.google.com/v1alpha1"
kind: GitGarbageCollection
metadata:
  name: gitgc
spec:
  cluster: gerrit
  schedule: "*/5 * * * *"

  projects: []

  resources:
    requests:
      cpu: 100m
      memory: 256Mi
    limits:
      cpu: 100m
      memory: 256Mi

  tolerations:
  - key: key1
    operator: Equal
    value: value1
    effect: NoSchedule

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: disktype
            operator: In
            values:
            - ssd

GerritClusterSpec

FieldTypeDescription
storageGerritStorageConfigStorage used by Gerrit instances
containerImagesContainerImageConfigContainer images used inside GerritCluster
ingressGerritClusterIngressConfigIngress traffic handling in GerritCluster
gerritsGerritTemplate-ArrayA list of Gerrit instances to be installed in the GerritCluster. Only a single primary Gerrit is permitted.

GerritClusterStatus

FieldTypeDescription
membersMap<String, List<String>>A map listing all Gerrit and Receiver instances managed by the GerritCluster by name

GerritStorageConfig

FieldTypeDescription
storageClassesStorageClassConfigStorageClasses used in the GerritCluster
gitRepositoryStorageSharedStorageVolume used for storing Git repositories
logsStorageSharedStorageVolume used for storing logs
pluginCacheStorageOptionalSharedStorageVolume used for caching downloaded plugin JAR-files

StorageClassConfig

FieldTypeDescription
readWriteOnceStringName of a StorageClass allowing ReadWriteOnce access. (default: default)
readWriteManyStringName of a StorageClass allowing ReadWriteMany access. (default: shared-storage)
nfsWorkaroundNfsWorkaroundConfigNFS is not well supported by Kubernetes. These options provide a workaround to ensure correct file ownership and id mapping

NfsWorkaroundConfig

FieldTypeDescription
enabledbooleanIf enabled, below options might be used. (default: false)
chownOnStartupbooleanIf enabled, the ownership of the mounted NFS volumes will be set on pod startup. Note that this is not done recursively. It is expected that all data already present in the volume was created by the user used in accessing containers. (default: false)
idmapdConfigStringThe idmapd.config file can be used to e.g. configure the ID domain. This might be necessary for some NFS servers to ensure correct mapping of user and group IDs. (optional)

SharedStorage

FieldTypeDescription
sizeQuantitySize of the volume (mandatory)
volumeNameStringName of a specific persistent volume to claim (optional)
selectorLabelSelectorSelector to select a specific persistent volume (optional)

OptionalSharedStorage

Extends: SharedStorage

FieldTypeDescription
enabledbooleanWhether to enable this storage. (default: false)

ContainerImageConfig

FieldTypeDescription
imagePullPolicyStringImage pull policy (https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) to be used in all containers. (default: Always)
imagePullSecretsLocalObjectReference-ArrayList of names representing imagePullSecrets available in the cluster. These secrets will be added to all pods. (optional)
busyBoxBusyBoxImageThe busybox container is used for some init containers
gerritImagesGerritRepositoryConfigThe container images in this project are tagged with the output of git describe. All container images are published for each version, even when the image itself was not updated. This ensures that all containers work well together. Here, the data on how to get those images can be configured.

BusyBoxImage

FieldTypeDescription
registryStringThe registry from which to pull the “busybox” image. (default: docker.io)
tagStringThe tag/version of the “busybox” image. (default: latest)

GerritRepositoryConfig

FieldTypeDescription
registryStringThe registry from which to pull the images. (default: docker.io)
orgStringThe organization in the registry containing the images. (default: k8sgerrit)
tagStringThe tag/version of the images. (default: latest)

GerritClusterIngressConfig

FieldTypeDescription
enabledbooleanWhether to configure an ingress provider to manage the ingress traffic in the GerritCluster (default: false)
typeIngressTypeWhich type of ingress provider to use (default: NONE)
hoststringHostname to be used by the ingress. For each Gerrit deployment a new subdomain using the name of the respective Gerrit CustomResource will be used.
annotationsMap<String, String>Annotations to be set for the ingress. This allows to configure the ingress further by e.g. setting the ingress class. This will be only used for type INGRESS and ignored otherwise. (optional)
tlsGerritIngressTlsConfigConfiguration of TLS to be used in the ingress

IngressType

ValueDescription
NONENo ingress provider will be configured
INGRESSAn Ingress will be provisioned
ISTIOISTIO will be configured to add the GerritCluster to the ServiceMesh

GerritIngressTlsConfig

FieldTypeDescription
enabledbooleanWhether to use TLS (default: false)
secretStringName of the secret containing the TLS key pair. The certificate should be a wildcard certificate allowing for all subdomains under the given host.

GerritTemplate

FieldTypeDescription
metadataObjectMetaMetadata of the resource. A name is mandatory. Labels can optionally be defined. Other fields like the namespace are ignored.
specGerritTemplateSpecSpecification for GerritTemplate

GerritTemplateSpec

FieldTypeDescription
tolerationsToleration-ArrayPod tolerations (optional)
affinityAffinityPod affinity (optional)
topologySpreadConstraintsTopologySpreadConstraint-ArrayPod topology spread constraints (optional)
priorityClassNameStringPriorityClass to be used with the pod (optional)
replicasintNumber of pods running Gerrit in the StatefulSet (default: 1)
updatePartitionintOrdinal at which to start updating pods. Pods with a lower ordinal will not be updated. (default: 0)
resourcesResourceRequirementsResource requirements for the Gerrit container
startupProbeGerritProbeStartup probe. The action will be set by the operator. All other probe parameters can be set.
readinessProbeGerritProbeReadiness probe. The action will be set by the operator. All other probe parameters can be set.
livenessProbeGerritProbeLiveness probe. The action will be set by the operator. All other probe parameters can be set.
gracefulStopTimeoutlongSeconds the pod is allowed to shutdown until it is forcefully killed (default: 30)
serviceGerritServiceConfigConfiguration for the service used to manage network access to the StatefulSet
siteGerritSiteConfiguration concerning the Gerrit site directory
pluginsGerritPlugin-ArrayList of Gerrit plugins to install. These plugins can either be packaged in the Gerrit war-file or they will be downloaded. (optional)
configFilesMap<String, String>Configuration files for Gerrit that will be mounted into the Gerrit site's etc-directory (gerrit.config is mandatory)
secretsSet<String>Names of secrets containing configuration files, e.g. secure.config, that will be mounted into the Gerrit site's etc-directory (optional)
modeGerritModeIn which mode Gerrit should be run. (default: PRIMARY)

GerritProbe

Extends: Probe

The fields exec, grpc, httpGet and tcpSocket cannot be set manually anymore compared to the parent object. All other options can still be configured.

GerritServiceConfig

FieldTypeDescription
typeStringService type (default: NodePort)
httpPortintPort used for HTTP requests (default: 80)
sshPortIntegerPort used for SSH requests (optional; if unset, SSH access is disabled). If Istio is used, the Gateway will be automatically configured to accept SSH requests. If an Ingress controller is used, SSH requests will only be served by the Service itself!

GerritSite

FieldTypeDescription
sizeQuantitySize of the volume used to persist not otherwise persisted site components (e.g. git repositories are persisted in a dedicated volume) (mandatory)

GerritPlugin

FieldTypeDescription
nameStringName of the plugin
urlURLURL of the plugin, if it should be downloaded. If the URL is not set, the plugin is expected to be packaged in the war-file (optional)
sha1StringSHA1-checksum of the plugin JAR-file. (mandatory, if url is set)
installAsLibrarybooleanSome plugins also need to be installed as a library. If set to true the plugin JAR will be symlinked to the lib-directory in the Gerrit site. (default: false)

GerritMode

ValueDescription
PRIMARYA primary Gerrit
REPLICAA Gerrit Replica, which only serves git fetch/clone requests

GerritSpec

Extends: GerritTemplateSpec

FieldTypeDescription
storageGerritStorageConfigStorage used by Gerrit instances
containerImagesContainerImageConfigContainer images used inside GerritCluster
ingressIngressConfigIngress configuration for Gerrit

GerritStatus

FieldTypeDescription
readybooleanWhether the Gerrit instance is ready
appliedSecretVersionsMap<String, String>Versions of each secret currently mounted into Gerrit pods

IngressConfig

FieldTypeDescription
typeIngressTypeWhich type of ingress provider is being used.
hoststringHostname that is being used by the ingress provider for this Gerrit instance.
tlsEnabledbooleanWhether the ingress provider enables TLS. (default: false)

ReceiverSpec

FieldTypeDescription
clusterstringName of the Gerrit cluster this Gerrit is a part of. (mandatory)
tolerationsToleration-ArrayPod tolerations (optional)
affinityAffinityPod affinity (optional)
topologySpreadConstraintsTopologySpreadConstraint-ArrayPod topology spread constraints (optional)
priorityClassNameStringPriorityClass to be used with the pod (optional)
replicasintNumber of pods running the receiver in the Deployment (default: 1)
maxSurgeIntOrStringOrdinal or percentage of pods that are allowed to be created in addition during rolling updates. (default: 1)
maxUnavailableIntOrStringOrdinal or percentage of pods that are allowed to be unavailable during rolling updates. (default: 1)
resourcesResourceRequirementsResource requirements for the Receiver container
readinessProbeReceiverProbeReadiness probe. The action will be set by the operator. All other probe parameters can be set.
livenessProbeReceiverProbeLiveness probe. The action will be set by the operator. All other probe parameters can be set.
serviceReceiverServiceConfigConfiguration for the service used to manage network access to the Deployment
credentialSecretRefStringName of the secret containing the .htpasswd file used to configure basic authentication within the Apache server (mandatory)

ReceiverStatus

FieldTypeDescription
readybooleanWhether the Receiver instance is ready
appliedCredentialSecretVersionStringVersion of credential secret currently mounted into Receiver pods

ReceiverProbe

Extends: Probe

The fields exec, grpc, httpGet and tcpSocket cannot be set manually anymore compared to the parent object. All other options can still be configured.

ReceiverServiceConfig

FieldTypeDescription
typeStringService type (default: NodePort)
httpPortintPort used for HTTP requests (default: 80)

GitGarbageCollectionSpec

FieldTypeDescription
clusterstringName of the Gerrit cluster this Gerrit is a part of. (mandatory)
tolerationsToleration-ArrayPod tolerations (optional)
affinityAffinityPod affinity (optional)
schedulestringCron schedule defining when to run git gc (mandatory)
projectsSet<String>List of projects to gc. If omitted, all projects not handled by other Git GC jobs will be gc‘ed. Only one job gc’ing all projects can exist. (default: [])
resourcesResourceRequirementsResource requirements for the GitGarbageCollection container

GitGarbageCollectionStatus

FieldTypeDescription
replicateAllbooleanWhether this GitGarbageCollection handles all projects
excludedProjectsSet<String>List of projects that were excluded from this GitGarbageCollection, since they are handled by other Jobs
stateGitGcStateState of the GitGarbageCollection

GitGcState

ValueDescription
ACTIVEGitGarbageCollection is scheduled
INACTIVEGitGarbageCollection is not scheduled
CONFLICTGitGarbageCollection conflicts with another GitGarbageCollection
ERRORController failed to schedule GitGarbageCollection