nextcloudをkubernetesで立ち上げたかったので以下の手順で行ったみた。
①dbの作成を行う。
wget https://raw.githubusercontent.com/andremotz/nextcloud-kubernetes/master/kubernetes-yaml/db-deployment.yaml
vi db-deployment.yaml
==============================================
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: db
name: db
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: db
spec:
containers:
- env:
- name: MYSQL_DATABASE
value: nextcloud
- name: MYSQL_PASSWORD
value: パスワード
- name: MYSQL_USER
value: nextcloud
- name: MYSQL_ROOT_PASSWORD
value: パスワード
image: hypriot/rpi-mysql
name: db
volumeMounts:
- mountPath: /var/lib/mysql
name: db
restartPolicy: Always
volumes:
- name: db
hostPath:
path: "/home/pi/db-pv"
=======================================================
kubectl create -f db-deployment.yaml
②dbのserviceの作成を行う。
wget https://raw.githubusercontent.com/andremotz/nextcloud-kubernetes/master/kubernetes-yaml/db-svc.yaml
vi db-svc.yaml
============================
apiVersion: v1
kind: Service
metadata:
name: db
spec:
ports:
- port: 3306
targetPort: 3306
protocol: TCP
selector:
app: db
=============================
kubectl create -f db-svc.yaml
③nextcloudの作成
wget https://raw.githubusercontent.com/andremotz/nextcloud-kubernetes/master/kubernetes-yaml/nc-deployment.yaml
vi nc-deployment.yaml
==========================================================
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: nc
name: nc
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nc
spec:
containers:
- env:
- name: TZ
value: Europe/Berlin
- name: DEBUG
value: "false"
- name: NEXTCLOUD_URL
value: http://nextcloud-rasp.local <------URLを記載してみる
- name: NEXTCLOUD_ADMIN_USER
value: admin
- name: NEXTCLOUD_ADMIN_PASSWORD
value: パスワード
- name: NEXTCLOUD_UPLOAD_MAX_FILESIZE
value: 4G
- name: NEXTCLOUD_MAX_FILE_UPLOADS
value: "20"
- name: MYSQL_DATABASE
value: nextcloud
- name: MYSQL_HOST
value: db
- name: MYSQL_PASSWORD
value: パスワード
- name: MYSQL_USER
value: nextcloud
name: nc
image: nextcloud
ports:
- containerPort: 80
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/www/html
name: html
restartPolicy: Always
volumes:
- name: html
hostPath:
path: "/home/pi/nc-pv" <--------------------既存の/home配下を指定
===================================================================
kubectl create -f nc-deployment.yaml
④nextcloudのサービスを作成
wget https://raw.githubusercontent.com/andremotz/nextcloud-kubernetes/master/kubernetes-yaml/nc-svc.yaml
vi nc-svc.yaml
=========================
apiVersion: v1
kind: Service
metadata:
name: nc
spec:
#type: LoadBalancer
type: NodePort
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
selector:
app: nc
==========================
kubectl create -f nc-svc.yaml
⑤certificatesの作成を行う。
wget https://raw.githubusercontent.com/andremotz/nextcloud-kubernetes/master/kubernetes-yaml/omgwtfssl-pod.yaml
vi omgwtfssl-pod.yaml
=====================================================
apiVersion: v1
kind: Pod
metadata:
labels:
app: omgwtfssl
name: omgwtfssl
spec:
restartPolicy: Never
containers:
- env:
- name: SSL_SUBJECT
value: rasp-master
- name: CA_SUBJECT
value: e-mailアドレスを入力
- name: SSL_KEY
value: /certs/rasp-master.key <-------------任意の名前を記載
- name: SSL_CSR
value: /certs/rasp-master.csr <-------------任意の名前を記載
- name: SSL_CERT
value: /certs/rasp-master.crt <-------------任意の名前を記載
name: omgwtfssl
image: paulczar/omgwtfssl
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: certs
name: certs
volumes:
- name: certs
hostPath:
path: "/home/pi/certs-pv" <--------------------既存の/home配下を指定
===========================================================
kubectl create -f omgwtfssl-pod.yaml
◻️赤字の箇所がnextcloudのpodやserviceが作成されていることが分かる。
root@rasp-master:~/docker-nextcloud# kubectl get all
==============================================================================================
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ds/datadog-agent 2 2 0 2 0 <none> 2d
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/db 1 1 1 1 27m
deploy/mysql 1 1 1 1 13d
deploy/nc 1 1 1 1 18m
deploy/wordpress 1 1 1 1 13d
NAME DESIRED CURRENT READY AGE
rs/db-6d6bbc8c99 1 1 1 27m
rs/mysql-779865b5dd 1 1 1 13d
rs/nc-768894dd7b 1 1 1 18m
rs/wordpress-6f4fc59b99 1 1 1 13d
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/db 1 1 1 1 27m
deploy/mysql 1 1 1 1 13d
deploy/nc 1 1 1 1 18m
deploy/wordpress 1 1 1 1 13d
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
ds/datadog-agent 2 2 0 2 0 <none> 2d
NAME DESIRED CURRENT READY AGE
rs/db-6d6bbc8c99 1 1 1 27m
rs/mysql-779865b5dd 1 1 1 13d
rs/nc-768894dd7b 1 1 1 18m
rs/wordpress-6f4fc59b99 1 1 1 13d
NAME READY STATUS RESTARTS AGE
po/datadog-agent-cqgtw 0/1 CrashLoopBackOff 585 2d
po/datadog-agent-hnb2q 0/1 CrashLoopBackOff 579 2d
po/db-6d6bbc8c99-s8dmm 1/1 Running 0 27m
po/mysql-779865b5dd-zbfdz 1/1 Running 0 13d
po/mysql-master-tktsp 1/1 Running 0 8d
po/mysql-slave-l7j6w 1/1 Running 0 8d
po/mysql-slave-mlzn4 1/1 Running 0 8d
po/nc-768894dd7b-46s8w 1/1 Running 1 18m
po/wordpress-6f4fc59b99-gjm4q 1/1 Running 0 13d
NAME DESIRED CURRENT READY AGE
rc/mysql-master 1 1 1 8d
rc/mysql-slave 2 2 2 8d
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/db ClusterIP 10.97.104.25 <none> 3306/TCP 24m
svc/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 13d
svc/mysql ClusterIP 10.98.74.60 <none> 3306/TCP 13d
svc/mysql-master ClusterIP 10.103.46.31 <none> 3306/TCP 8d
svc/mysql-slave ClusterIP 10.110.108.3 <none> 3306/TCP 8d
svc/nc ClusterIP 10.97.92.200 <none> 80/TCP 16m
svc/wordpress NodePort 10.102.200.103 <none> 80:30915/TCP 13d
==========================================================================================