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