本文主要是介绍在k8s中以deployment方式部署minio,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
minio官网给的demo是通过pod方式部署的,我碰到了好几次因为k8s集群断电重启后,以单pod方式部署部署的minio消失。因此这里改用deplyment的方式部署minio。
以下是完整的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: apps/v1
kind: Deployment
metadata:name: minionamespace: devops
spec:replicas: 1selector:matchLabels:app: miniotemplate:metadata:labels:app: miniospec:containers:- name: minioimage: 192.168.10.30:9000/minio:latestcommand:- /bin/bash- -cargs:- minio server /data --console-address :9001env:- name: MINIO_SERVER_URLvalue: 'http://minio.rockstics.com'- name: MINIO_BROWSER_REDIRECT_URLvalue: 'http://minio.rockstics.com/minio/ui'volumeMounts:- mountPath: /dataname: localvolume # Corresponds to the `spec.volumes` Persistent VolumehostAliases:- ip: "192.168.10.188"hostnames:- "minio.rockstics.com"volumes:- name: localvolumehostPath: # MinIO generally recommends using locally-attached volumespath: /data/minio # Specify a path to a local drive or volume on the Kubernetes worker nodetype: DirectoryOrCreate # The path to the last directory must existnodeSelector:kubernetes.io/hostname: kubernetesw02---
kind: Service
apiVersion: v1
metadata:name: minio-servernamespace: devopslabels:app: minio-server
spec:ports:- name: http-consoleprotocol: TCPport: 9001targetPort: 9001- name: http-apiprotocol: TCPport: 9000targetPort: 9000selector:app: minio
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:annotations:labels:app: minioname: minionamespace: devops
spec:routes:- kind: Rulematch: Host(`minio.isiact.com`)services:- kind: Servicename: minio-servernamespace: devopsport: http-api- kind: Rulematch: Host(`minio.isiact.com`) && PathPrefix(`/minio/ui`)middlewares:- name: minio-consoleservices:- kind: Servicename: minio-servernamespace: devopsport: http-console
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:annotations:name: minio-consolenamespace: devops
spec:stripPrefix:prefixes:- /minio/ui
题外话:由于我通过MINIO_SERVER_URL指定了minio的内网访问域名,导致登录minio报"invalid login"的问题,刚开始以为是挂载的数据路径中有.minio.sys 相关信息(包括minio配置信息包括用户密码,assce_key等信息)被其他容器挂载无效,实践证明不是这样的,后来才发现是因为容易内无法解析我的内网域名导致的,解决方案就是直接进行host绑定。
这篇关于在k8s中以deployment方式部署minio的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!