Data Repository サーバーを Kubernetes にデプロイするには、以下で説明するプロセスに従ってください。
要件
まず、Persistent Volume と Persistent Volume Claim が必要です。300GB の容量をプロビジョニングし、ReadWriteOnce のアクセス モードを設定する必要があります。この領域は、Data Repository サーバーのデータを格納するために使用されます。
デフォルトの Persistent Volume Claim 名は datarepo-pvc であり、soavirt サーバーの yaml 定義を更新することでカスタマイズできます。以下に示すサンプルは、NFS Persistent Volume と Persistent Volume Claim を設定する構成です。この例では NFS を使用していますが、これは必須ではありません。ニーズに合った Persistent Volume タイプを使用してください。
警告: NFS の場合、エクスポートされたディレクトリには、コンテナを実行する Parasoft ユーザーと同じ UID および GID が必要です。たとえば、コマンド chown 1000:1000 <SHARED_PATH> を実行します。
apiVersion: v1
kind: PersistentVolume
metadata:
name: datarepo-pv
spec:
capacity:
storage: 300Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
mountOptions:
- hard
- nfsvers=4.1
nfs:
path: <path>
server: <ip_address>
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: datarepo-pvc
spec:
storageClassName: nfs
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 300Gi
yaml ファイルを使用して、Persistent Volume と Persistent Volume Claim を作成します。
kubectl create -f datarepo-pv.yaml
Data Repository ログイン用のユーザー名とパスワードを含むシークレットを作成します。このようなシークレットを作成する 1 つの方法は、次のコマンドを使用することです。
kubectl create secret generic datarepo-login \ --from-literal=username=<username> \ --from-literal=password=<password>
Data Repository サーバーのセットアップ
以下の yaml の例は、Data Repository サーバーのポッドを構成し、ポート 30017 経由で外部に公開します。以前に Persistent Volume Claim にカスタム名を使用した場合は、カスタム名と一致するように claimName フィールドを更新してください。NFS が永続ボリュームに使用されている場合は、yaml ファイル内のコメントの指示に従って、'runAsUser' UID を構成します。
apiVersion: v1
kind: Pod
metadata:
name: datarepo
labels:
app: datarepo
spec:
# If using NFS for the persistent volume, uncomment the following lines and run the pod with the UID of the owner of the <shared_path>.
# securityContext:
# runAsUser: <UID>
volumes:
- name: datarepo-volume
persistentVolumeClaim:
claimName: datarepo-pvc
# To run the Data Repository server with SSL, uncomment the following lines
# - name: datarepo-sslcert-file
# configMap:
# name: datarepo-sslcert
containers:
- name: datarepo
image: mongo:latest
imagePullPolicy: IfNotPresent
volumeMounts:
- name: datarepo-volume
mountPath: /data/db
# To run the Data Repository server with SSL, uncomment the following lines
# - name: datarepo-sslcert-file
# mountPath: /etc/sslCert.pem
# subPath: sslCert.pem
# command: ["mongod", "--ipv6", "--bind_ip_all", "--sslMode", "requireSSL", "--sslPEMKeyFile", "/etc/sslCert.pem", "--auth"]
startupProbe:
exec:
# To check the health of the Data Repository server, choose one of the following lines to uncomment based on if the server is running with or without SSL
# command: ["/bin/sh", "-c" "mongosh --host 127.0.0.1 --port 27017 --ssl --sslAllowInvalidCertificates --quiet test --eval 'quit(0)'"]
command: ["/bin/sh", "-c" "mongosh --host 127.0.0.1 --port 27017 --quiet test --eval 'quit(0)'"]
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
livenessProbe:
exec:
# To run the Data Repository server with SSL or not, choose one of the following lines to uncomment
# command: ["/bin/sh", "-c" "mongosh --host 127.0.0.1 --port 27017 --ssl --sslAllowInvalidCertificates --quiet test --eval 'quit(0)'"]
command: ["/bin/sh", "-c" "mongosh --host 127.0.0.1 --port 27017 --quiet test --eval 'quit(0)'"]
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 10
env:
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: datarepo-login
key: username
optional: false
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: datarepo-login
key: password
optional: false
---
apiVersion: v1
kind: Service
metadata:
name: datarepo
labels:
run: datarepo
spec:
type: NodePort
ports:
- port: 27017
protocol: TCP
targetPort: 27017
nodePort: 30017
selector:
app: datarepo
yaml ファイルを使用してポッドとサービスを開始します。
kubectl create -f datarepo.yaml
SSL を使用した Data Repository サーバーの再起動
Kubernetes で Data Repository サーバーをセットアップしたら、SSL を使用して再起動できます。まず、既存のポッドとサービスを破棄します。
kubectl delete -f datarepo.yaml
次に、SSL 証明書ファイルを Kubernetes にデプロイします。
kubectl create configmap datarepo-sslcert \ --from-file=sslCert.pem=<path-to-file>
上記の datarepo.yaml ファイルをファイル中にある指示に従って再構成し、SSL を使用して Data Repository サーバーを起動します。次に、その yaml を使用してポッドとサービスを開始します。
kubectl create -f datarepo.yaml
CTP を使用した Data Repository サーバーの登録
Data Repository サーバーを CTP の Parasoft Test Data に登録するには、次のコマンドを実行します。
curl -H "Content-Type: application/json" -H "Accept: application/json" \
-d "{\"alias\":\"<ALIAS>\",\"host\":\"<NODE>\",\"port\":<PORT>,\"user\":\"<DR_USERNAME>\",\"password\":\"<DR_PASSWORD>\",\"ssl\":<USE_SSL>}" \
--user "<CTP_USERNAME>:<CTP_PASSWORD>" "<CTP_URL>/em/tdm/api/v2/servers"
以下の表では、curl コマンドの変数について説明します。これらをセットアップに適した構成に置き換えてください。
| 変数 | 説明 |
|---|---|
| <ALIAS> | この Data Repository サーバーを表すために CTP に表示される名前 |
| <NODE> | この Data Repository サーバーが実行されている Kubernetes ノード |
| <PORT> | この Data Repository サーバーが公開されるノードのポート番号 |
| <DR_USERNAME> | この Data Repository サーバーの初期化に使用されるログイン ユーザー名 |
| <DR_PASSWORD> | この Data Repository サーバーの初期化に使用されるログイン パスワード |
| <USE_SSL> | この Data Repository サーバーに SSL が必要かどうか (true または false) |
| <CTP_USERNAME> | CTP ログインのユーザー名 |
| <CTP_PASSWORD> | CTP ログインのパスワード |
| <CTP_URL> | https://[CTP Server Host]:[Port] 形式の CTP への URL |