k8s部署单点的minio集群
前言
记录一下根据minio官网的范本部署一个单节点单磁盘的minio服务端。
一、基础环境准备
准备一个k8s集群,配置好存储类
二、准备yaml文件
准备yaml文件,文件内定义了namespace、pvc、service、pod
minio-deployment.yaml
# https://min.io/docs/minio/kubernetes/upstream/index.html
# Deploys a new Namespace for the MinIO Pod
apiVersion: v1
kind: Namespace
metadata:
name: minio-dev # Change this value if you want a different namespace name
labels:
name: minio-dev # Change this value to match metadata.name
---
# Deploy pvc for minio
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minio-data-one-pv-claim
namespace: minio-dev
spec:
# 我这里使用的存储类型是cephrbd
storageClassName: rook-ceph-block
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10G
---
# Deploy service for minio
apiVersion: v1
kind: Service
metadata:
name: minio
namespace: minio-dev
spec:
type: NodePort
ports:
- name: 9090-tcp
protocol: TCP
port: 9090
targetPort: 9090
nodePort: 32307
- name: 9000-tcp
protocol: TCP
port: 9000
targetPort: 9000
nodePort: 32308
selector:
app: minio
---
# Deploys a new MinIO Pod into the metadata.namespace Kubernetes namespace
#
# The `spec.containers[0].args` contains the command run on the pod
# The `/data` directory corresponds to the `spec.containers[0].volumeMounts[0].mountPath`
# That mount path corresponds to a Kubernetes HostPath which binds `/data` to a local drive or volume on the worker node where the pod runs
#
apiVersion: v1
kind: Pod
metadata:
labels:
app: minio
name: minio
namespace: minio-dev
spec:
containers:
- name: minio
image: 192.168.150.35:10002/library/minio:RELEASE.2022-12-07T00-56-37Z
env:
- name: MINIO_ACCESS_KEY
value: "admin"
- name: MINIO_SECRET_KEY
value: "admin123456"
command:
- /bin/bash
- -c
args:
- minio server /data --console-address :9090 --address :9000
# add port for pod
ports:
- containerPort: 9090
name: console-address
- containerPort: 9000
name: address
volumeMounts:
- name: minio-data-one
mountPath: /data
#nodeSelector:
# kubernetes.io/hostname: kubealpha.local
volumes:
- name: minio-data-one
persistentVolumeClaim:
claimName: minio-data-one-pv-claim
三、执行部署
kubectl apply -f minio-deployment.yaml
#输出
namespace/minio-dev created
persistentvolumeclaim/minio-data-one-pv-claim created
service/minio created
pod/minio created
四、命令行查看部署结果
kubectl get pod -o wide -n minio-dev
kubectl get svc -o wide -n minio-dev
kubectl get pvc -o wide -n minio-dev
输出
[root@kubeadmin minio]# kubectl get pod -o wide -n minio-dev
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
minio 1/1 Running 0 2m7s 10.233.68.42 kubeworker01 <none> <none>
[root@kubeadmin minio]# kubectl get svc -o wide -n minio-dev
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
minio NodePort 10.233.29.16 <none> 9090:32307/TCP,9000:32308/TCP 2m25s app=minio
[root@kubeadmin minio]# kubectl get pvc -o wide -n minio-dev
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODE
minio-data-one-pv-claim Bound pvc-58d0d5f2-4071-46b8-825b-4feffbc6db28 10Gi RWO rook-ceph-block 4m57s Filesystem
五、登陆页面访问
登陆页面访问minio平台,IP+32307
使用yaml文件中配置的账号密码成功登陆
总结
单点的模式适合实验和前期开发使用,真实场景下不建议使用