- 创建namespace
apiVersion: v1
kind: Namespace
metadata:
name: "minio"
labels:
name: "minio"
- 创建PV pvc
kind: PersistentVolume
apiVersion: v1
metadata:
name: minio-pv
namespace: minio
labels:
app: minio-storage-claim
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/home/ellis/k8s/minio/storage"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: minio-pvc-claim
namespace: minio
labels:
app: minio-storage-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
- 部署deployment
apiVersion: apps/v1
kind: Deployment
metadata:
# This name uniquely identifies the Deployment
name: minio
namespace: minio
spec:
selector:
matchLabels:
app: minio # has to match .spec.template.metadata.labels
strategy:
# Specifies the strategy used to replace old Pods by new ones
# Refer: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
type: Recreate
template:
metadata:
labels:
# This label is used as a selector in Service definition
app: minio
spec:
# Volumes used by this deployment
volumes:
- name: data
# This volume is based on PVC
persistentVolumeClaim:
# Name of the PVC created earlier
claimName: minio-pvc-claim
containers:
- name: minio
# Volume mounts for this container
volumeMounts:
# Volume 'data' is mounted to path '/data'
- name: data
mountPath: /data
# Pulls the latest Minio image from Docker Hub
image: minio/minio
args:
- server
- --console-address
- :9001
- /data
env:
# MinIO access key and secret key
- name: MINIO_ROOT_USER
value: "minio"
- name: MINIO_ROOT_PASSWORD
value: "minio123"
- name: MINIO_SERVER_URL
value: "http://192.168.214.133:30009"
ports:
- containerPort: 9000
- containerPort: 9001
# Readiness probe detects situations when MinIO server instance
# is not ready to accept traffic. Kubernetes doesn't forward
# traffic to the pod while readiness checks fail.
readinessProbe:
httpGet:
path: /minio/health/ready
port: 9000
initialDelaySeconds: 120
periodSeconds: 20
# Liveness probe detects situations where MinIO server instance
# is not working properly and needs restart. Kubernetes automatically
# restarts the pods if liveness checks fail.
livenessProbe:
httpGet:
path: /minio/health/live
port: 9000
initialDelaySeconds: 120
periodSeconds: 20
注意
- 添加 - --console-address - :9001这两个参数,是将console界面暴露到9001端口,后续通过service 暴露出去
- 添加 MINIO_SERVER_URL参数,其中ip是主机host,端口是9000映射出去的service的端口
- service
apiVersion: v1
kind: Service
metadata:
name: minio-service
namespace: minio
spec:
type: NodePort
ports:
- name: server-port
port: 9000
targetPort: 9000
protocol: TCP
nodePort: 30009
- name: console-port
port: 9001
targetPort: 9001
protocol: TCP
nodePort: 30010
selector:
app: minio
https://computingforgeeks.com/deploy-and-manage-minio-storage-on-kubernetes/
https://stackoverflow.com/questions/70785172/k8s-deployment-minio-how-to-access-the-console