flea/_deploy/k8s/00_initial.sh
2024-04-14 15:22:41 +04:00

81 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# This is a history like script to memorise all actions
# needed to deploy the microservice applications into
# kubernetes cluster.
#
# nocr
#
# 01. First initialize the namespace
kubectl create namespace nocr
# 02. Infrustructure
#
# Create secret for accessing registry hub with application
# artifacts.
kubectl create secret docker-registry hubcred --docker-server=https://hub.musk.fun/v1/ --docker-username=<username> --docker-password=<password> --docker-email=some@email.com --namespace nocr
# Create the persistent volume for the whole application
# and do the claims all that needs and shares the volume.
# kubectl apply -f pv.yaml
# bubectl apply -f pvc.yaml
# NB. There is very URGENT consideration, that even running local
# single noded k9s cluster, should avoid of beeing tainted, rather
# and deployment wont start automatical.
# THis done by the next command:
#
# kubectl taint nodes --all node-role.kubernetes.io/control-plane-
#
# 03. Install rabbitmq
#
# Initialize the rabitmq kubernetes cluster and deployment followed by:
# https://www.rabbitmq.com/kubernetes/operator/install-operator
#
# Then apply rabbitmq.yaml
# 04. Application secrets
#
# First secret file for telegram session authentication
kubectl create secret generic secretfiles --from-file=<location_to>/WTelegram.session --namespace=nocr
# Next secret got WTelegram client lib auth.
kubectl create secret generic wtelegram-client \
--from-literal=apiid=<value> \
--from-literal=apihash=<value> \
--from-literal=phonenumber=<value> \
--namespace nocr
# 05. installing persistant rdbs engine
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
#
# note that you should create a values.yaml file with db credentials at least.
#
helm install mdb-tm --set auth.database=nocr_text_matcher bitnami/mariadb --namespace nocr
helm install mdb-u --set auth.database=nocr_users bitnami/mariadb --namespace nocr
# to update helm release please use
# helm upgrade my-release oci://REGISTRY_NAME/REPOSITORY_NAME/mariadb --set auth.rootPassword=[ROOT_PASSWORD]
# 05. Main deployment
#
# Make the main deployment.
kubectl apply -f deployment.yaml