Chapter 05Lesson 01~120 minutes

Kubernetes and OpenShift Deployment Patterns: Core Concepts and Mental Model

Understand SonarQube on Kubernetes and OpenShift as a stateful platform integration whose namespace, chart, secrets, storage, database, Service/routing, security context, node prerequisites, probes, and upgrade state remain separate operational boundaries.

HelmKubernetesOpenShiftPVCPod Security

Learning objectives

  • Trace a SonarQube deployment from pinned Helm chart and values through rendered Kubernetes objects to a running Pod and durable database state.
  • Separate Pod lifecycle, PVC/storage lifecycle, database state, Secret/configuration state, Service/routing state, and node/kernel prerequisites.
  • Explain why OpenShift SCC behavior changes security-context assumptions without changing SonarQube persistence or database requirements.
  • Inspect chart/app versions, namespaces, values, Secrets, PVCs, Services, security contexts, resources, probes, and node prerequisites before mutation.
  • Distinguish Community Build/Developer/Enterprise single-node chart behavior from the separate commercial Data Center chart and from SonarQube Cloud.

1. Current orchestration baseline: Pods are replaceable, state is not

The current reproducible baseline is SonarQube Community Build 26.9.0.129388 rendered by released Helm chart 2026.4.1. The chart release supports Kubernetes 1.32–1.35 and OpenShift 4.17–4.20. Its default Community Build is older than the current product release, so this chapter always records both the chart version and the explicit community.buildNumber.

Cluster boundary: mandatory exercises are render/dry-run oriented and do not require access to a shared or production cluster. Optional deployment is permitted only in an isolated local/disposable cluster and namespace with explicit resource headroom and cleanup guards.

2. Mental model: chart input to durable service

SonarQube on an orchestrator

Read left to right. Every arrow crosses an ownership boundary that can fail independently.

flowchart TD
R[Chart release + values] --> H[Helm render]
S[Secrets] --> H
SC[StorageClass / PVC policy] --> H
DB[(External database)] --> N[Cluster network / DNS]
H --> O[Kubernetes objects]
O --> P[SonarQube Pod]
O --> V[(PVC)]
O --> SV[Service]
O --> RP[Ingress / Route / HTTPRoute]
NODE[Node/kernel prerequisites] --> P
N --> P
P --> DB
P --> V
SV --> P
RP --> SV
P --> Q[Readiness / liveness / logs]
Q --> OPS[Operational evidence]

Helm is a renderer and release manager, not a persistence layer. A Pod is replaceable runtime state. A PVC is a claim on storage whose durability depends on its StorageClass and backing system. A Secret stores sensitive configuration but is not automatically an external secret manager. A Service provides stable in-cluster addressing. Ingress, OpenShift Route, and Gateway API objects are separate edge-routing choices. The supported database remains the durable SonarQube application store.

3. State stores you must not collapse into “the cluster”

State Primary owner Evidence Failure if confused
Chart/app identity Helm repository/release values helm show chart, helm get values Unknown upgrade input
Runtime Pod/ReplicaSet or workload kubectl get pod -o yaml, events, logs Restart treated as recovery
Search/index filesystem PVC/storage backend when enabled PVC/PV/StorageClass objects Ephemeral reschedule surprises
Application history Supported external DB in production JDBC endpoint + DB backup/health evidence PVC mistaken for DB backup
Credentials Kubernetes Secret / external secret mechanism Secret references and RBAC, not secret values Credentials baked into values/Git
Network entry Service + chosen edge controller/API Service/Ingress/Route/HTTPRoute Port 9000 exposed without TLS/proxy policy
Host prerequisites Cluster/node administrator node/kernel baseline Pod YAML looks valid but search bootstrap fails

4. Pod Security and OpenShift are configuration, not magic

The maintained chart classifies SonarQube application and ordinary init containers as compatible with the Kubernetes restricted Pod Security level. The init-sysctl helper is privileged and init-fs needs root-oriented filesystem repair behavior. For a full restricted namespace, SonarSource recommends disabling both helpers and making node/kernel and storage ownership prerequisites an administrator responsibility.

initSysctl:
  enabled: false
initFs:
  enabled: false
containerSecurityContext:
  allowPrivilegeEscalation: false
  runAsNonRoot: true
  runAsUser: 1000
  seccompProfile:
    type: RuntimeDefault
  capabilities:
    drop: ["ALL"]

With OpenShift, set OpenShift.enabled=true and keep OpenShift.createSCC=false. The chart adapts to default SCCv2 behavior and disables helpers that conflict with the restricted model. Do not invent custom SCC grants merely to make an old manifest start.

5. Persistence: a PVC is a contract with a storage system

The current single-node chart has persistence.enabled=false by default. Enabling it creates or consumes a PVC; the chart defaults to a 5Gi ReadWriteOnce claim when you do not supply an existing claim. The actual durability, latency, snapshot, expansion, zone, and recovery semantics come from the selected StorageClass/backend.

Production principle: do not use hostPath as a portable production persistence strategy. A Pod can move while a host path cannot. Treat search/index persistence separately from the external SonarQube database and from database backup.

6. Service, Ingress, Route, and Gateway API own different edges

The chart’s default Service is a ClusterIP on port 9000. That is an internal stable endpoint. External exposure is a separate decision. On OpenShift, a Route may be created when explicitly enabled. On Kubernetes, an Ingress resource can target a controller you manage. Current SonarSource material warns against treating a bundled ingress controller as production infrastructure and points toward Gateway API as the modern direction.

Mandatory labs keep routing internal or use kubectl port-forward only against an isolated local namespace. They do not publish a public hostname or teach TLS verification bypasses.

7. Read-only inspection before cluster mutation

helm version
kubectl version --client
helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube
helm repo update
helm show chart sonarqube/sonarqube --version 2026.4.1
helm show values sonarqube/sonarqube --version 2026.4.1 > sq-chart-2026.4.1-values.yaml

grep -nE 'community:|persistence:|initSysctl:|initFs:|OpenShift:|resources:|jdbcOverwrite:' sq-chart-2026.4.1-values.yaml

If a cluster is available, inspect it without mutation: kubectl get ns, kubectl get storageclass, kubectl auth can-i create deployments -n sq-ch05-lab, and available node capacity. Do not assume a local kubeconfig points to a disposable cluster.

8. Edition boundary: one chart is not every SonarQube topology

The sonarqube/sonarqube chart supports Community Build plus commercial Developer and Enterprise editions. The commercial Data Center Edition uses the separate sonarqube-dce chart with multiple application/search-node concepts and additional cluster secrets/topology. Community Build labs must not simulate “HA” by setting multiple replicas on the single-node chart.

SonarQube Cloud is a SaaS product and is not something you deploy with these charts.

9. Foundation mistakes to reject early

  • “A Deployment manifest is the whole system.” It omits DB, storage, Secret, Service/routing, node and upgrade ownership.
  • “Pod restart means recovery.” A restart can hide state loss, storage corruption, DB unavailability, or unresolved node prerequisites.
  • “PVC means backup.” It does not create an independently restorable database backup.
  • “OpenShift just needs a privileged SCC.” Current chart behavior is designed around restricted SCCv2 when configured correctly.
  • “More replicas means Data Center.” DCE is a distinct commercial architecture and chart.

10. Why this matters in DevOps

Kubernetes adds automation but also adds control planes and indirection. A trustworthy deployment record must connect source/chart version, rendered values, Secret references, namespace/RBAC, storage class, database identity, network edge, security context, resource/probe state, and rollback inputs. That evidence lets an operator distinguish “the Pod is red” from the actual failed layer.

Knowledge check

Why is a Pod not the durable SonarQube system?

What changes when OpenShift.enabled=true?

Does persistence.enabled=true create a database backup?

Which chart should a Community Build lab use?

Why record both chart version and Community Build number?

Next lesson

From mental model to a rendered deployment

Lesson 2 pins the maintained chart, creates a namespace-scoped values file, renders manifests before apply, inspects security/persistence/network objects, and optionally deploys only to a disposable local cluster.

Official references and version notes

Version and compatibility note

Version-sensitive statements were rechecked against current SonarSource, Helm-chart repository, and Kubernetes primary material on 2026-09-07. Mandatory examples use SonarQube Community Build 26.9.0.129388 with the latest released SonarQube Helm chart 2026.4.1. That chart release originally defaults Community Build to 26.7.0.124771, so examples deliberately set community.buildNumber=26.9.0.129388. The released chart documents non-OpenShift Kubernetes support for 1.32–1.35 and OpenShift support for 4.17–4.20. SonarQube Server Developer/Enterprise and the separate Data Center chart are commercial boundaries and are not required. No SonarScanner execution, CI provider, third-party plugin, enterprise identity provider, managed Kubernetes service, public DNS, or paid infrastructure is required by the mandatory Chapter 05 path. Re-check the chart release, supported platform matrix, Community Build number, database compatibility, and upgrade notes before using these examples later.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.