Helm/RabbitMQ

From Chorke Wiki
Revision as of 00:08, 18 December 2024 by Shahed (talk | contribs) (Created page with " helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update && helm repo list kubectl config get-contexts ==Config== <syntaxhighlight lang="properties"> export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml" export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml" export KUBECONFIG="${HOME}/.kube/config" </syntaxhighlight> ==Install== {| |valign="top"| <syntaxhighlight lang="bash"> helm show values bitnami/rabbitmq --version=15.2.0|less helm show values b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update && helm repo list
kubectl config get-contexts

Config

export KUBECONFIG="${HOME}/.kube/dev-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/gcp-kubeconfig.yaml"
export KUBECONFIG="${HOME}/.kube/config"

Install

helm show values bitnami/rabbitmq --version=15.2.0|less
helm show values bitnami/rabbitmq --version=15.2.1|less

kubectl get ns|grep rabbitmq
kubectl delete ns   rabbitmq
kubectl create ns   rabbitmq
kubectl get ns|grep rabbitmq

kubectl -n=rabbitmq create secret generic rabbitmq-secret \
--from-literal=rabbitmq-password=sadaqah! \
--dry-run=client -o=yaml \
| kubectl apply -f=-

cat <<ENV | kubectl -n=rabbitmq create secret generic rabbitmq-secret --from-env-file=/dev/stdin
rabbitmq-password=sadaqah!
ENV

cat << YML | kubectl -n=rabbitmq apply -f=-
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-rabbitmq
spec:
  persistentVolumeReclaimPolicy: Retain
  storageClassName: standard
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /tmp/hostpath-provisioner/rabbitmq/pvc-rabbitmq
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app.kubernetes.io/name: rabbitmq
  name: pvc-rabbitmq
spec:
  storageClassName: standard
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: pv-rabbitmq
YML
cat << YML | kubectl -n=rabbitmq apply -f=-
---













---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app.kubernetes.io/name: rabbitmq
  name: pvc-rabbitmq
spec:
  storageClassName: standard
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

YML

PV_NAME="$(kubectl -n=rabbitmq get   pvc pvc-rabbitmq -o=yaml|yq -r .spec.volumeName)"
cat <<YML |kubectl -n=rabbitmq patch pv ${PV_NAME} --patch-file=/dev/stdin
---
spec:
  persistentVolumeReclaimPolicy: Retain
YML

cat <<YML | helm -n=rabbitmq install    rabbitmq bitnami/rabbitmq --version=15.2.1 -f=-
---
ingress:
  path: /
  enabled: true
  ingressClassName: nginx
  hostname: rabbitmq.k8s.local
auth:
  username: admin
  securePassword: true
  updatePassword: true
  existingPasswordSecret: rabbitmq-secret
  existingSecretPasswordKey: rabbitmq-password
replicaCount: 1
YML

  xdg-open http://rabbitmq.k8s.local &>/dev/null &
gnome-open http://rabbitmq.k8s.local &>/dev/null &
   x-www-browser http://rabbitmq.k8s.local &>/dev/null &
sensible-browser http://rabbitmq.k8s.local &>/dev/null &

Uninstall

helm uninstall -n=rabbitmq rabbitmq
kubectl delete namespace rabbitmq

Playground

helm -n=rabbitmq install    rabbitmq bitnami/rabbitmq --version=15.2.0
helm -n=rabbitmq upgrade -i rabbitmq bitnami/rabbitmq --version=15.2.1
helm show values bitnami/rabbitmq --version=15.2.1|less

kubectl -n=rabbitmq get secret rabbitmq-secret -o=yaml|yq -r .data."rabbitmq-password"|base64 -d && echo
kubectl -n=rabbitmq get secret rabbitmq -o=yaml|yq -r .data."rabbitmq-erlang-cookie"|base64 -d && echo

kubectl -n=rabbitmq exec -it svc/rabbitmq -c=rabbitmq -- bash
kubectl -n=rabbitmq exec -it svc/rabbitmq -c=rabbitmq -- sh

kubectl config --kubeconfig=${HOME}/.kube/aws-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/dev-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/gcp-kubeconfig.yaml view --flatten
kubectl config --kubeconfig=${HOME}/.kube/config view --flatten

kubectl -n=rabbitmq delete all --all
kubectl -n=rabbitmq delete ing --all
kubectl -n=rabbitmq delete sts --all
kubectl -n=rabbitmq delete svc --all
kubectl -n=rabbitmq delete pvc --all
kubectl -n=rabbitmq delete pv  --all

kubectl -n=rabbitmq rollout history sts rabbitmq
kubectl -n=rabbitmq rollout restart sts rabbitmq
kubectl -n=rabbitmq rollout status  sts rabbitmq
kubectl -n=rabbitmq exec -it svc/rabbitmq -c=rabbitmq -- bash
kubectl -n=rabbitmq logs -f  svc/rabbitmq -c=rabbitmq
kubectl -n=rabbitmq logs -f  svc/rabbitmq

References