0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

helmのインストールからsonarqubeをデプロイまで

0
Posted at

まずはhelmのインストール

helm-v3.22.1-linux-amd64.tar.gzをダウンロード

tar zxvf helm-v3.22.1-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm

sonarqubeをインストール

まずはリポジトリ設定

helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube
結果
"sonarqube" has been added to your repositories

helm repo update
結果
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "sonarqube" chart repository
Update Complete. ?Happy Helming!?

sonarqubeのPod作成まで

sonarqube用の

kubectl create namespace sonarqube

podのインストール

helm upgrade -install -n sonarqube --version ~8 sonarqube sonarqube/sonaqube

Podが起動しない

kubectl get pods -n sonarqube
NAME                     READY   STATUS     RESTARTS   AGE
sonarqube-postgresql-0   0/1     Pending    0          8m46s
sonarqube-sonarqube-0    0/1     Init:0/3   0          8m46s

ログを確認

kubectl describe pod sonarqube-postgresql-0 -n sonarqube


 Warning  FailedScheduling  4m1s (x2 over 9m19s)  default-scheduler  0/3 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/3 nodes are available: 3 Preemption is not helpful for scheduling.

AI回答
予想通り、データを保存するためのストレージ(PersistentVolumeClaim)がクラスター内に用意されていないことが原因

ディスク容量が枯渇中のため一度2GBでPVを作成

vi pv-2gb.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: sonarqube-pv
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: ""
  hostPath:
    path: /mnt/data/sonarqube
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: postgresql-pv
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: ""
  hostPath:
    path: /mnt/data/postgresql

kubectl apply -f pv-2gb.yaml

再実行するもえらー

helm upgrade --install -n sonarqube --version "~8" \
  --set postgresql.persistence.storageClass="" \
  --set postgresql.persistence.size=1Gi \
  --set persistence.storageClass="" \
  --set persistence.size=1Gi \
  sonarqube sonarqube/sonarqube


エラー
Error: UPGRADE FAILED: cannot patch "sonarqube-postgresql" with kind StatefulSet: StatefulSet.apps "sonarqube-postgresql" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden

一度削除が必要な模様

helm uninstall sonarqube -n sonarqube
結果
release "sonarqube" uninstalled
kubectl delete pvc --all -n sonarqube
結果
persistentvolumeclaim "data-sonarqube-postgresql-0" deleted

削除後あたらめて

helm upgrade --install -n sonarqube --version "~8" \
  --set postgresql.persistence.storageClass="" \
  --set postgresql.persistence.size=1Gi \
  --set persistence.storageClass="" \
  --set persistence.size=1Gi \
  sonarqube sonarqube/sonarqube
Release "sonarqube" does not exist. Installing it now.
NAME: sonarqube
LAST DEPLOYED: Sat Oct 17 15:52:45 2026
NAMESPACE: sonarqube
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace sonarqube -l "app=sonarqube,release=sonarqube" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:9000 -n sonarqube

今回使用したコマンドの説明

結論から言うと、このコマンドはHelmにおいて「無ければ新規作成(Install)、あれば設定を上書き更新(Upgrade)する」という、超強力で安全な「一発両用コマンド」だからです。

helm upgrade --install 

コマンドの最後の2つの意味

sonarqube sonarqube/sonarqube

1つ目はリリース名

リリース名名確認方法

helm list -n sonarqube
または
helm list -A

リリース名がわかると
値を確認できる

helm get values sonarqube -n sonarqube

削除もリリース名に対して実施

helm uninstall sonarqube -n sonarqube

2つ名はチャート名(<リポジトリ名>/<パッケージ名>)

一番左のNAMEがチャート名です。

helm search repo sonarqube
NAME                    CHART VERSION   APP VERSION     DESCRIPTION
sonarqube/sonarqube     2026.5.1002     2026.5.2        SonarQube is a self-managed, automatic code rev...
sonarqube/sonarqube-dce 2026.5.1002     2026.5.2        SonarQube is a self-managed, automatic code rev...
sonarqube/sonarqube-lts 2.0.0+463       8.9.10          DEPRECATED SonarQube offers Code Quality and Co...
helm list -n sonarqube
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
sonarqube       sonarqube       6               2026-10-17 17:02:04.813572365 +0900 JST deployed        sonarqube-8.0.9+4357    9.9.9
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?