提问人:StackHeap 提问时间:11/6/2023 最后编辑:StackHeap 更新时间:11/9/2023 访问量:80
使用 Kubernetes 部署 Minio
Deployment of Minio using Kubernetes
问:
Kubernetes Docker Minio 未按文档工作。
如何将浏览器连接到 MinIO Server?
问题 1:minio-service URL http://127.0.0.1:52506 被重定向到 http://127.0.0.1:37085/
问题编号 2:尝试更改 minio-service 端口但徒劳无功:
% minikube service minio-service
|-----------|---------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|---------------|-------------|---------------------------|
| default | minio-service | 45895 | http://192.168.49.2:32140 |
|-----------|---------------|-------------|---------------------------|
🏃 Starting tunnel for service minio-service.
|-----------|---------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|---------------|-------------|------------------------|
| default | minio-service | | http://127.0.0.1:52534 |
|-----------|---------------|-------------|------------------------|
🎉 Opening service default/minio-service in default browser...
❗ Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
铌当天早些时候,通过 docker run 将浏览器连接到 MinIO 服务器 (http://127.0.0.1:9090) 已成功,如以下终端输出详细信息所示:
% docker run \
-p 9000:9000 \
-p 9090:9090 \
--name minio \
-v /Users/macbookprom1apple/Desktop/Working/Docker/minio/data:/data \
-e "MINIO_ROOT_USER=ROOTNAME" \
-e "MINIO_ROOT_PASSWORD=CHANGEME123" \
quay.io/minio/minio server /data --console-address ":9090"
[
Unable to find image 'quay.io/minio/minio:latest' locally
latest: Pulling from minio/minio
b650cfbb2837: Pull complete
e9d5ce196263: Pull complete
c1b201109fa1: Pull complete
26d5f7e47938: Pull complete
e3dbc49ce3d2: Pull complete
a6bfa4552f85: Pull complete
1ff33655e246: Pull complete
Digest: sha256:8871650797a40e6094828e86709f3e7180615f03d72ea9d385a720dfb2b63510
Status: Downloaded newer image for quay.io/minio/minio:latest
Formatting 1st pool, 1 set(s), 1 drives per set.
WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable.
MinIO Object Storage Server
Copyright: 2015-2023 MinIO, Inc.
License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
Version: RELEASE.2023-11-01T18-37-25Z (go1.21.3 linux/arm64)
Status: 1 Online, 0 Offline.
S3-API: http://172.17.0.2:9000 http://127.0.0.1:9000
Console: http://172.17.0.2:9090 http://127.0.0.1:9090
Documentation: https://min.io/docs/minio/linux/index.html
Warning: The standard parity is set to 0. This can lead to data loss.
步骤 1:创建持久卷声明Minio 需要持久存储来存储对象。如果没有持久化存储,Minio 实例中存储的数据将存储在容器文件系统中,并在容器重启后立即擦除。
创建持久性卷声明 (PVC) 以请求 Minio 实例的存储。Kubernetes 会在集群中寻找与 PVC 请求匹配的 PV,并自动将其绑定到 PVC。
步骤 2:创建 Minio 部署部署封装了副本集和 Pod,因此,如果一个 Pod 出现故障,复制控制器会确保另一个 Pod 自动启动。这样一来,你就不需要为Pod故障而烦恼了,并且有一个稳定的Minio服务可用。
第 3 步:创建 Minio 服务现在,您已经运行了 Minio 部署,您可能希望在内部(在集群内)访问它,或者将其作为服务公开到外部(集群外部,可能是公共 Internet)IP 地址,具体取决于您的用例。您可以使用服务来实现此目的。有 3 种主要服务类型 — 默认类型是 ClusterIP,它向集群内部的连接公开服务。NodePort 和 LoadBalancer 是两种类型,它们将服务暴露给外部流量,并通过创建 LoadBalancer 服务来暴露 Minio 部署。
这是 PVC/deployment/service 说明。
minio.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
# This name uniquely identifies the PVC. Will be used in deployment below.
name: minio-pv-claim
labels:
app: minio-storage-claim
spec:
# Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
# This is the request for storage. Should be available in the cluster.
requests:
# storage: 256Mi
storage: 10Gi
---
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
# This name uniquely identifies the Deployment
name: minio-deployment
spec:
selector:
matchLabels:
app: minio
strategy:
type: Recreate
template:
metadata:
labels:
# Label is used as selector in the service.
app: minio
spec:
# Refer to the PVC created earlier
volumes:
- name: storage
persistentVolumeClaim:
# Name of the PVC created earlier
claimName: minio-pv-claim
containers:
- name: minio
# Pulls the default Minio image from Docker Hub
image: minio/minio:latest
args:
- server
- /storage
env:
# Minio access key and secret key
- name: MINIO_ACCESS_KEY
value: "minio"
- name: MINIO_SECRET_KEY
value: "minio123"
ports:
- containerPort: 9000
hostPort: 9000
# Mount the volume into the pod
volumeMounts:
- name: storage # must match the volume name, above
mountPath: "/storage"
---
apiVersion: v1
kind: Service
metadata:
name: minio-service
spec:
type: LoadBalancer
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
app: minio
端子输出:
Last login: Mon Nov 6 18:04:37 on ttys000
% sw_vers
ProductName: macOS
ProductVersion: 14.0
BuildVersion: 23A344
% arch
arm64
% docker version
Client:
Cloud integration: v1.0.35+desktop.5
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:28:49 2023
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.25.0 (126437)
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:31:36 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
% minikube version
minikube version: v1.31.2
commit: fd7ecd9c4599bef9f04c0986c4a0187f98a4396e
% minikube start
😄 minikube v1.31.2 on Darwin 14.0 (arm64)
✨ Automatically selected the docker driver
📌 Using Docker Desktop driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.27.4 preload ...
> preloaded-images-k8s-v18-v1...: 327.74 MiB / 327.74 MiB 100.00% 2.32 Mi
> gcr.io/k8s-minikube/kicbase...: 404.50 MiB / 404.50 MiB 100.00% 2.60 Mi
🔥 Creating docker container (CPUs=2, Memory=4000MB) ...
🐳 Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
% kubectl version
Client Version: v1.28.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.4
% nano kubernetes-minio.yaml
% cat kubernetes-minio.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
# This name uniquely identifies the PVC. Will be used in deployment below.
name: minio-pv-claim
labels:
app: minio-storage-claim
spec:
# Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
# This is the request for storage. Should be available in the cluster.
requests:
storage: 10Gi
---
apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
# This name uniquely identifies the Deployment
name: minio-deployment
spec:
selector:
matchLabels:
app: minio
strategy:
type: Recreate
template:
metadata:
labels:
# Label is used as selector in the service.
app: minio
spec:
# Refer to the PVC created earlier
volumes:
- name: storage
persistentVolumeClaim:
# Name of the PVC created earlier
claimName: minio-pv-claim
containers:
- name: minio
# Pulls the default Minio image from Docker Hub
image: minio/minio:latest
args:
- server
- /storage
env:
# Minio access key and secret key
- name: MINIO_ACCESS_KEY
value: "minio"
- name: MINIO_SECRET_KEY
value: "minio123"
ports:
- containerPort: 9000
hostPort: 9000
# Mount the volume into the pod
volumeMounts:
- name: storage # must match the volume name, above
mountPath: "/storage"
---
apiVersion: v1
kind: Service
metadata:
name: minio-service
spec:
type: LoadBalancer
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
app: minio
% kubectl apply -f kubernetes-minio.yaml
persistentvolumeclaim/minio-pv-claim created
deployment.apps/minio-deployment created
service/minio-service created
% kubectl get pods --watch
NAME READY STATUS RESTARTS AGE
minio-deployment-588b47b7c6-ss6ws 0/1 ContainerCreating 0 13s
minio-deployment-588b47b7c6-ss6ws 1/1 Running 0 16s
^C% % kubectl get pvc minio-pv-claim
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
minio-pv-claim Bound pvc-a0c1734c-e995-45ce-afb9-869ac9520458 10Gi RWO standard 29s
% kubectl get deployment minio-deployment
NAME READY UP-TO-DATE AVAILABLE AGE
minio-deployment 1/1 1 1 43s
% kubectl get svc minio-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
minio-service LoadBalancer 10.109.120.194 <pending> 9000:30334/TCP 51s
% kubectl get all
NAME READY STATUS RESTARTS AGE
pod/minio-deployment-588b47b7c6-ss6ws 1/1 Running 0 59s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7m27s
service/minio-service LoadBalancer 10.109.120.194 <pending> 9000:30334/TCP 59s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/minio-deployment 1/1 1 1 59s
NAME DESIRED CURRENT READY AGE
replicaset.apps/minio-deployment-588b47b7c6 1 1 1 59s
% minikube service minio-service
|-----------|---------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|---------------|-------------|---------------------------|
| default | minio-service | 9000 | http://192.168.49.2:30334 |
|-----------|---------------|-------------|---------------------------|
🏃 Starting tunnel for service minio-service.
|-----------|---------------|-------------|------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|---------------|-------------|------------------------|
| default | minio-service | | http://127.0.0.1:52314 |
|-----------|---------------|-------------|------------------------|
🎉 Opening service default/minio-service in default browser...
❗ Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
答: 暂无答案
评论
kubectl port-forward svc/minio-service 32140