K8s/MinIO: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Created page with "==K8s » Config== {|class='wikitable mw-collapsible' !scope='col' colspan='2' style='width:1000px'| K8s » Config |- |valign='top'| <syntaxhighlight lang="bash"> export KUBECONFIG=${HOME}/.kube/aws-kubeconfig.yaml export KUBECONFIG=${HOME}/.kube/dev-kubeconfig.yaml export KUBECONFIG=${HOME}/.kube/gcp-kubeconfig.yaml </syntaxhighlight> |valign='top'| <syntaxhighlight lang="bash"> export KUBECONFIG=${HOME}/.kube/shahed-aa-kubeconfig.yaml export KUBECONFIG=${HOME}/.kube/sh..."
 
Line 349: Line 349:
|valign='top' style='width:490px'|
|valign='top' style='width:490px'|
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl -n minio exec -it svc/minio -c minio -- ash
kubectl -n minio exec -it svc/minio -c minio -- bash
kubectl -n minio exec -it svc/minio -- ash
kubectl -n minio exec -it svc/minio -- bash
kubectl -n minio exec -it svc/minio -- id
kubectl -n minio exec -it svc/minio -- id
kubectl -n minio logs -f  svc/minio
kubectl -n minio logs -f  svc/minio

Revision as of 02:40, 18 July 2025

K8s » Config

K8s » Config

export KUBECONFIG=${HOME}/.kube/aws-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/dev-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/gcp-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/shahed-aa-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/shahed-ab-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/shahed-ac-kubeconfig.yaml
export KUBECONFIG=${HOME}/.kube/hetzner-ab-kubeconfig.yaml
kubectl config get-contexts
kubectl config view

K8s » Storage

K8s » Storage

cat << EXE | sudo bash
mkdir -p           /var/minikube/pvc/minio/data-minio-0/
chown -R 1000:1000 /var/minikube/pvc/minio/data-minio-0/
chmod -R 750       /var/minikube/pvc/minio/
EXE
cat <<'YML'| kubectl apply -f -
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: minio-data-minio-0
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: hostpath
  hostPath:
    path: /var/hostpath_pv/minio/data-minio-0
    type: DirectoryOrCreate
YML



K8s » Deploy

K8s » Deploy

kubectl config get-contexts
kubectl config view
kubectl create ns   minio
kubectl get ns|grep minio
cat <<ENV | kubectl -n minio create configmap minio --from-env-file=/dev/stdin
MINIO_SERVER_URL=https://s3.minio.hetzner.shahed.biz
MINIO_BROWSER_REDIRECT_URL=https://minio.hetzner.shahed.biz
ENV

cat <<ENV | kubectl -n minio create secret generic minio --from-env-file=/dev/stdin
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=sadaqah!
ENV
cat <<'YML'| kubectl apply -n minio -f -
---
apiVersion: v1
kind: Service
metadata:
  name: minio
  namespace: minio
  labels:
    app.kubernetes.io/name: minio
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/instance: minio
    app.kubernetes.io/managed-by: kubectl
spec:
  selector:
    app: minio
  ports:
    - targetPort: 9001
      protocol: TCP
      port: 9001
      name: minio
  type: ClusterIP
YML
cat <<'YML'| kubectl apply -n minio -f -
---
apiVersion: v1
kind: Service
metadata:
  name: s3
  namespace: minio
  labels:
    app.kubernetes.io/name: minio
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/instance: minio
    app.kubernetes.io/managed-by: kubectl
spec:
  selector:
    app: minio
  ports:
    - targetPort: 9000
      protocol: TCP
      port: 9000
      name: s3
  type: ClusterIP
YML
cat <<'YML'| kubectl apply -n minio -f -
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data-minio-0
  namespace: minio
  labels:
    app.kubernetes.io/name: minio
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/instance: minio
    app.kubernetes.io/managed-by: kubectl
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: hostpath
  volumeName: minio-data-minio-0
YML



cat <<'YML'| kubectl apply -n minio -f -
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: minio
  namespace: minio
  labels:
    app: minio
    app.kubernetes.io/name: minio
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/instance: minio
    app.kubernetes.io/managed-by: kubectl
  annotations:
    kubernetes.io/change-cause: "CKI-1| Initial Deployment"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: minio
  template:
    metadata:
      labels:
        app: minio
    spec:
      securityContext:
        runAsUser: 1000
        fsGroup: 1000
      containers:
        - name: minio
          image: minio/minio:RELEASE.2025-06-13T11-33-47Z
          args:
            - server
            - "/data"
            - "--address"
            - ":9000"
            - "--console-address"
            - ":9001"
          ports:
          - containerPort: 9001
            protocol: TCP
            name: minio
          - containerPort: 9000
            protocol: TCP
            name: s3
          resources:
            limits:
              cpu: 250m
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 256Mi
          envFrom:
            - secretRef:
                name: minio
            - configMapRef:
                name: minio
          volumeMounts:
          - mountPath: /data
            name: data-minio-0
      volumes:
        - name: data-minio-0
          persistentVolumeClaim:
            claimName: data-minio-0
YML

K8s » Ingress

K8s » Ingress

cat << YML | kubectl apply -n minio -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minio
  namespace: minio
  labels:
    app.kubernetes.io/name: minio
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/instance: minio
    app.kubernetes.io/managed-by: kubectl
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
spec:
  ingressClassName: nginx
  rules:
    - host: minio.hetzner.shahed.biz
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: minio
                port:
                  number: 9001
YML
cat << YML | kubectl apply -n minio -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: s3
  namespace: minio
  labels:
    app.kubernetes.io/name: minio
    app.kubernetes.io/version: 1.0.0
    app.kubernetes.io/instance: minio
    app.kubernetes.io/managed-by: kubectl
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
spec:
  ingressClassName: nginx
  rules:
    - host: s3.minio.hetzner.shahed.biz
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: s3
                port:
                  number: 9000
YML

K8s » Verify

K8s » Verify

xdg-open https://www.cdn77.com/tls-test/result?domain=s3.minio.hetzner.shahed.biz
xdg-open https://s3.minio.hetzner.shahed.biz

xdg-open https://www.cdn77.com/tls-test/result?domain=minio.hetzner.shahed.biz
xdg-open https://minio.hetzner.shahed.biz
kubectl -n minio exec -it svc/minio -c minio -- bash
kubectl -n minio exec -it svc/minio -- bash
kubectl -n minio exec -it svc/minio -- id
kubectl -n minio logs -f  svc/minio
---
Page: https://minio.hetzner.shahed.biz
user: tool.tech@shahed.biz
pass: sadaqah!

K8s » Scaling

K8s » Scaling

cat <<YML | kubectl -n minio patch deploy/minio --patch-file=/dev/stdin
---
spec:
  replicas: 0
YML

cat <<YML | kubectl -n minio patch deploy/minio --patch-file=/dev/stdin
---
spec:
  replicas: 1
YML

cat <<YML | kubectl -n minio patch deploy/minio --patch-file=/dev/stdin
---
metadata:
  annotations:
    kubernetes.io/change-cause: "CKI-2| Resources Updated"
spec:
  template:
    spec:
      containers:
        - name: minio
          resources:
            limits:
              cpu: 500m
              memory: 1Gi
            requests:
              cpu: 250m
              memory: 250m
YML

K8s » Rolling

K8s » Rollout

kubectl -n minio rollout history deploy/minio
kubectl -n minio rollout pause   deploy/minio

cat <<YML | kubectl -n minio patch deploy/minio --patch-file=/dev/stdin
---
metadata:
  annotations:
    kubernetes.io/change-cause: "CKI-2| Container Updated"
spec:
  template:
    spec:
      containers:
        - name: minio
          resources:
            limits:
              cpu: 500m
              memory: 1Gi
            requests:
              cpu: 250m
              memory: 250m
YML

kubectl -n minio annotate        deploy/minio --overwrite \
 kubernetes.io/change-cause="CKI-2| Resources Updated"

kubectl -n minio rollout resume  deploy/minio
kubectl -n minio rollout history deploy/minio
kubectl -n minio rollout undo    deploy/minio --to-revision=1
kubectl -n minio rollout history deploy/minio

kubectl -n minio annotate        deploy/minio --overwrite \
 kubernetes.io/change-cause="CKI-3| Revert Back to CKI-1"

kubectl -n minio rollout history deploy/minio

K8s » Delete

K8s » Delete

kubectl delete svc    --all -n minio
kubectl delete deploy --all -n minio
kubectl delete pvc    --all -n minio
kubectl delete pv     minio-data-minio-0
kubectl delete all    --all -n minio
kubectl delete ns     minio

Playground

Playground

kubectl -n minio get secret minio -o json|jq -r '.data."MINIO_ROOT_PASSWORD"'|base64 -d;echo
kubectl -n minio get secret minio -o json|jq -r '.data."MINIO_ROOT_USER"'    |base64 -d;echo

kubectl -n minio exec -it svc/minio -- cat /minio-data/keystores/secret-key
kubectl -n minio exec -it svc/minio -- cat /minio-data/admin.password
kubectl -n minio rollout history deploy/minio
kubectl -n minio rollout restart deploy/minio
kubectl -n minio rollout undo    deploy/minio
kubectl -n minio rollout pause   deploy/minio
kubectl -n minio rollout resume  deploy/minio
kubectl -n minio rollout status  deploy/minio
kubectl delete svc    --all -n minio
kubectl delete deploy --all -n minio
kubectl delete pvc    --all -n minio
kubectl delete pv     minio-data-minio-0
kubectl delete all    --all -n minio
kubectl delete ns     minio
kubectl -n minio exec -it svc/minio -c minio -- ash
kubectl -n minio exec -it svc/minio -- ash
kubectl -n minio exec -it svc/minio -- id

kubectl -n minio logs -f  svc/minio -c minio
kubectl -n minio logs -f  svc/minio

References

References