microk8sの環境セットアップメモ
microk8sの構築手順メモ
microk8sのインストール
コンテナ仮想化のツールであるmicrok8sの構築手順メモになります。
インストール
snap install microk8s --classic
初期設定
権限の設定
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~/.kube
起動
microk8s start
機能の有効化
microk8s enable dns registry storage
マニフェストファイルの書き方メモ
Service
apiVersion: v1
kind: Service
metadata:
name: misskey-web-svc
spec:
ports:
- name: "xxxx"
port: xxxx
targetPort: xxxx
selector:
app: misskey-web
Deployment1
apiVersion: apps/v1
kind: Deployment
metadata:
name: misskey-web
spec:
replicas: 1
selector:
matchLabels:
app: misskey-web
strategy:
type: Recreate
template:
metadata:
labels:
app: misskey-web
spec:
containers:
- name: web
image: misskey/misskey:latest
ports:
- containerPort: xxxx
volumeMounts:
- mountPath: /misskey/files
name: misskey-web-data1
- mountPath: /misskey/.config
name: misskey-web-data2
readOnly: true
restartPolicy: Always
volumes:
- name: misskey-web-data1
persistentVolumeClaim:
claimName: misskey-web-data1-claim
- name: misskey-web-data2
persistentVolumeClaim:
claimName: misskey-web-data2-claim
readOnly: true
Deployment2
apiVersion: apps/v1
kind: Deployment
metadata:
name: misskey-db
spec:
replicas: 1
selector:
matchLabels:
app: misskey-db
strategy:
type: Recreate
template:
metadata:
labels:
app: misskey-db
spec:
containers:
- name: db
image: postgres:15-alpine
env:
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
key: POSTGRES_DB
name: config-env
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
key: POSTGRES_PASSWORD
name: config-env
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
key: POSTGRES_USER
name: config-env
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: misskey-db
restartPolicy: Always
volumes:
- name: misskey-db
persistentVolumeClaim:
claimName: misskey-db-claim