実行手順
1. KanboardとPostgreSQLデータ格納用ディレクトリを作成以下のコマンドでKanboardとPostgreSQLデータ格納用ディレクトリを作成します。
minikube ssh
sudo mkdir -p /var/pgdata
sudo mkdir -p /var/kanboard_data
sudo mkdir -p /var/kanboard_plugins
sudo mkdir -p /var/kanboard_ssl
exit
2. local永続ボリュームの作成
以下のコマンドでlocal永続ボリュームを作成します。
※PostgreSQLデータ用
cat << EOF > local-pg-pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pg-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
storageClassName: local-storage
local:
path: /var/pgdata
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube
EOF
kubectl apply -f ./local-pg-pv.yml
※Kanboardデータ用
cat << EOF > local-kanboard-data-pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-kanboard-data-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
storageClassName: local-storage
local:
path: /var/kanboard_data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube
EOF
kubectl apply -f ./local-kanboard-data-pv.yml
※Kanboardプラグイン用
cat << EOF > local-kanboard-plugins-pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-kanboard-plugins-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
storageClassName: local-storage
local:
path: /var/kanboard_data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube
EOF
kubectl apply -f ./local-kanboard-plugins-pv.yml
※KanboardのSSL用
cat << EOF > local-kanboard-ssl-pv.yml
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-kanboard-ssl-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
storageClassName: local-storage
local:
path: /var/kanboard_ssl
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube
EOF
kubectl apply -f ./local-kanboard-ssl-pv.yml
3. 永続ボリューム要求の作成
以下のコマンドで永続ボリューム要求を作成します。
※PostgreSQLデータ用
cat << EOF > local-pg-pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-pg-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 5Gi
volumeName: local-pg-pv
EOF
kubectl apply -f ./local-pg-pvc.yml
※Kanboardデータ用
cat << EOF > local-kanboard-data-pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-kanboard-data-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 5Gi
volumeName: local-kanboard-data-pv
EOF
kubectl apply -f ./local-kanboard-data-pvc.yml
※Kanboardプラグイン用
cat << EOF > local-kanboard-plugins-pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-kanboard-plugins-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 5Gi
volumeName: local-kanboard-plugins-pv
EOF
kubectl apply -f ./local-kanboard-plugins-pvc.yml
※KanboardのSSL用
cat << EOF > local-kanboard-ssl-pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-kanboard-ssl-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 5Gi
volumeName: local-kanboard-ssl-pv
EOF
kubectl apply -f ./local-kanboard-ssl-pvc.yml
4. KanboardとPostgreSQLのDeploymentの作成
以下のコマンドでkanboardとpostgresqlを含むポッドと作成したlocal永続ボリュームを使用するDeploymentを作成します。
cat << EOF > kanboard-pg-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: kanboard-pg-deployment
labels:
app: kanboard-pg
spec:
replicas: 1
selector:
matchLabels:
app: kanboard-pg
strategy:
type: Recreate
template:
metadata:
labels:
app: kanboard-pg
spec:
containers:
- name: mypg
image: postgres:14-alpine
env:
- name: POSTGRES_DB
value: kanboard
- name: POSTGRES_USER
value: kanboard
- name: POSTGRES_PASSWORD
value: kanboard
ports:
- containerPort: 5432
volumeMounts:
- name: pg-data
mountPath: /var/lib/postgresql/data
- name: kanboard
image: kanboard/kanboard:latest
env:
- name: DATABASE_URL
value: postgres://kanboard:kanboard@127.0.0.1:5432/kanboard
ports:
- containerPort: 80
name: http
- containerPort: 443
name: https
volumeMounts:
- name: kanboard-data
mountPath: /var/www/app/data
- name: kanboard-plugins
mountPath: /var/www/app/plugins
- name: kanboard-ssl
mountPath: /etc/nginx/ssl
volumes:
- name: pg-data
persistentVolumeClaim:
claimName: local-pg-pvc
- name: kanboard-data
persistentVolumeClaim:
claimName: local-kanboard-data-pvc
- name: kanboard-plugins
persistentVolumeClaim:
claimName: local-kanboard-plugins-pvc
- name: kanboard-ssl
persistentVolumeClaim:
claimName: local-kanboard-ssl-pvc
EOF
kubectl apply -f ./kanboard-pg-deployment.yml
5. KanboardとPostgreSQLのサービスの作成
以下のコマンドでサービスを作成します。
cat << EOF > kanboard-pg-service.yml
apiVersion: v1
kind: Service
metadata:
name: kanboard-pg-service
spec:
selector:
app: kanboard-pg
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 80
- name: https
protocol: TCP
port: 443
targetPort: 8443
- name: db
protocol: TCP
port: 3306
targetPort: 3306
EOF
kubectl apply -f ./kanboard-pg-service.yml
6. Port-Fowardingで外部からアクセスできるようにする
kubectl port-forward --address 0.0.0.0 service/kanboard-pg-service 8080:8080 3306:3306
ブラウザから以下のURLからKanboardにアクセスします。
http://<MinikubeをインストールしたホストのIP>:8080/
初期ログインはユーザadmin、パスワードadminでログインしてください。
0 件のコメント:
コメントを投稿