sonar-operator

by sergk

Helm chartv3.4.0App 3.4.0Apache-2.0Verified publisher

A Helm chart for KubeRocketCI Sonar Operator

About this chart

sonar-operator

A Helm chart for KubeRocketCI Sonar Operator

Homepage: https://docs.kuberocketci.io/

Overview

Sonar Operator is a KubeRocketCI operator that is responsible for configuring SonarQube.

NOTE: Operator is platform-independent, that is why there is a unified instruction for deploying.

Prerequisites

  1. Linux machine or Windows Subsystem for Linux instance with Helm 3 installed;
  2. Cluster admin access to the cluster;

Installation

In order to install the KubeRocketCI Sonar Operator, follow the steps below:

  1. To add the Helm EPAMEDP Charts for local client, run "helm repo add":

    helm repo add epamedp https://epam.github.io/edp-helm-charts/stable
    
  2. Choose available Helm chart version:

    helm search repo epamedp/sonar-operator -l
    NAME                    CHART VERSION   APP VERSION     DESCRIPTION
    epamedp/sonar-operator  3.1.1           3.1.1           A Helm chart for KubeRocketCI Sonar Operator
    

    NOTE: It is highly recommended to use the latest released version.

  3. Deploy operator:

    Full available chart parameters available in deploy-templates/README.md:

  4. Install operator in the arbitrary (sonar-operator) namespace with the helm command; find below the installation command example:

    helm install sonar-operator epamedp/sonar-operator --version <chart_version> --namespace sonar
    
  5. Check the sonar namespace that should contain operator deployment with your operator in a running status.

Quick Start

  1. Login into Sonarqube and create user. Attach permissions to user such as quality gates, profiles, user managment etc. Insert user credentials into Kubernetes secret.

    apiVersion: v1
    kind: Secret
    metadata:
      name:  sonar-access
    type: Opaque
    data:
      username: dXNlcg==  # base64-encoded value of "user"
      password: cGFzcw==  # base64-encoded value of "pass"
    
  2. Create Custom Resource kind: Sonar with Sonar instance URL and secret created on the previous step:

    apiVersion: edp.epam.com/v1alpha1
    kind: Sonar
    metadata:
      name: sonar-sample
    spec:
      url: https://sonar.example.com   # Sonar URL
      secret: sonar-access             # Secret name
    

    Wait for the .status field with status.connected: true

  3. Create Quality Gate using Custom Resources SonarQualityGate:

    apiVersion: edp.epam.com/v1alpha1
     kind: SonarQualityGate
     metadata:
       name: qualityGate-sample
     spec:
       sonarRef:
         name: sonar-sample # the name of `kind: Sonar`
       name: qualityGate-sample
       default: true
       conditions:
         new_coverage:
         op: LT
         error: "80"
    
    apiVersion: edp.epam.com/v1alpha1
    kind: SonarQualityProfile
    metadata:
      name: qualityProfile-sample
    spec:
      sonarRef:
        name: sonar-sample # the name of `kind: Sonar`
      name: qualityProfile-sample
      language: java
      default: true
      rules:
        checkstyle:com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck:
        severity: 'MAJOR'
    

    Inspect CR templates folder for more examples

Local Development

In order to develop the operator, first set up a local environment. For details, please refer to the Local Development page.

Development versions are also available, please refer to the snapshot helm chart repository page.

Related Articles

Maintainers

NameEmailUrl
epmd-edp[email protected]https://solutionshub.epam.com/solution/kuberocketci
sergkhttps://github.com/SergK

Source Code

Values

KeyTypeDefaultDescription
affinityobject{}
annotationsobject{}
extraVolumeMountslist[]Additional volumeMounts to be added to the container
extraVolumeslist[]Additional volumes to be added to the pod
image.repositorystring"epamedp/sonar-operator"KubeRocketCI sonar-operator Docker image name. The released image can be found on Dockerhub
image.tagstringnilKubeRocketCI sonar-operator Docker image tag. The released image can be found on Dockerhub
imagePullPolicystring"IfNotPresent"
imagePullSecretslist[]Optional array of imagePullSecrets containing private registry credentials # Ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry
namestring"sonar-operator"component name
nodeSelectorobject{}
podSecurityContextobject{"runAsNonRoot":true}Pod Security Context Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
resources.limits.memorystring"192Mi"
resources.requests.cpustring"50m"
resources.requests.memorystring"64Mi"
securityContextobject{"allowPrivilegeEscalation":false}Container Security Context Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
tolerationslist[]

Deploy sonar-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has sonar-operator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartsonar-operator is pinned at v3.4.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply