-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the home-stack wiki!
Home Project Stack
The stack is deployed using Kubernetes cluster enabled using microk8s. microk8s is installed using snap package manger. Package is provided by Canonical (publisher of Ubuntu).
- Resources: quad-core ARMx64 processor with 8GB RAM
- Kernel: GNU/Linux 5.4.0-1058-raspi aarch64
- OS: Ubuntu 20.04.4
As of now it is deployed on single node cluster.
- Alok Singh
-
home-stack
- Table of contents
-
Deployment of home-stack Kubernetes Stack
- Create Namespaces
- Create ConfigMap
- Create Secrets
- Create Network policy
- MySQL Service - Pod/Deployment/Service
- Home API Service - Pod/Deployment/Service
- Home Auth Service - Pod/Deployment/Service
- Home ETL Service - Pod/Statefulset/Service
- Home GIT Commit CronJob
- Statement Parser Service - Pod/Deployment/Service
- Dashboard Service - Pod/Deployment/Service
- Jaeger Service
- Delete Stack
- Kubernetes Dashboard
- Ingress
- RBAC
- Horizon Autoscaling
- Miscellaneous commands
- Service Mesh - Istio
- Deployment Architecture
kubectl apply -f yaml/namespace.yaml
kubectl apply -f yaml/config-map.yaml
kubectl apply -f yaml/secrets.yaml
kubectl apply -f yaml/networkpolicy.yaml
kubectl apply --validate=true --dry-run=client -f yaml/mysql-service.yaml
kubectl apply -f yaml/mysql-service.yaml --namespace=home-stack
kubectl delete -f yaml/mysql-service.yaml --namespace=home-stack
kubectl exec -it pod/mysql-0 --namespace home-stack -- mysql -u root -p home-stack
kubectl logs pod/mysql-0 --namespace home-stack
mysql -u root -p home-stack --host 127.0.0.1 --port 32306
Note:
Follow the link to configure sqldeveloper on Mac to connect to MySQL server remotely
kubectl apply --validate=true --dry-run=client -f yaml/home-api-service.yaml
kubectl apply -f yaml/home-api-service.yaml --namespace=home-stack
kubectl delete -f yaml/home-api-service.yaml --namespace=home-stack
kubectl exec -it pod/home-api-deployment-0 --namespace home-stack -- bash
kubectl exec -it pod/home-api-deployment-0 --namespace home-stack -- tail -f /opt/logs/application.log
kubectl logs pod/home-api-deployment-0 --namespace home-stack
kubectl rollout restart statefulset.apps/home-api-deployment -n home-stack
kubectl apply --validate=true --dry-run=client -f yaml/home-auth-service.yaml
kubectl apply -f yaml/home-auth-service.yaml --namespace=home-stack
kubectl delete -f yaml/home-auth-service.yaml --namespace=home-stack
kubectl exec -it pod/home-auth-deployment-0 --namespace home-stack -- bash
kubectl exec -it pod/home-auth-deployment-0 --namespace home-stack -- tail -f /opt/logs/application.log
kubectl logs pod/home-auth-deployment-0 --namespace home-stack
kubectl rollout restart statefulset.apps/home-api-deployment -n home-stack
kubectl apply --validate=true --dry-run=client -f yaml/home-etl-service.yaml
kubectl apply -f yaml/home-etl-service.yaml --namespace=home-stack
kubectl delete -f yaml/home-etl-service.yaml --namespace=home-stack
kubectl exec -it pod/home-etl-deployment-0 --namespace home-stack -- bash
kubectl exec -it pod/home-etl-deployment-0 --namespace home-stack -- tail -f /opt/logs/application.log
kubectl logs pod/home-etl-deployment-0 --namespace home-stack
kubectl rollout restart statefulset.apps/home-api-deployment -n home-stack
kubectl apply --validate=true --dry-run=client -f yaml/git-commit-cronjob.yaml
kubectl apply -f yaml/git-commit-cronjob.yaml --namespace=home-stack
kubectl delete -f yaml/git-commit-cronjob.yaml --namespace=home-stack
kubectl apply --validate=true --dry-run=client -f yaml/stmt-parser-service.yaml
kubectl apply -f yaml/stmt-parser-service.yaml --namespace=home-stack
kubectl delete -f yaml/stmt-parser-service.yaml --namespace=home-stack
kubectl exec -it pod/stmtparser-deployment-0 --namespace home-stack -- bash
kubectl exec -it pod/stmtparser-deployment-0 --namespace home-stack -- tail -f /opt/logs/spring-batch.log
kubectl logs pod/stmtparser-deployment-0 --namespace home-stack
kubectl rollout restart statefulset.apps/stmtparser-deployment -n home-stack
kubectl apply --validate=true --dry-run=client -f yaml/dashboard-service.yaml
kubectl apply -f yaml/dashboard-service.yaml --namespace=home-stack
kubectl delete -f yaml/dashboard-service.yaml --namespace=home-stack
kubectl exec -it deployment.apps/dashboard-deployment --namespace home-stack -- /bin/sh
kubectl logs deployment.apps/dashboard-deployment --namespace home-stack
kubectl apply --validate=true --dry-run=client -f yaml/jaeger-all-in-one-template.yml
kubectl apply -f yaml/jaeger-all-in-one-template.yml --namespace=home-stack
kubectl delete -f yaml/jaeger-all-in-one-template.yml --namespace=home-stack
kubectl delete namespace home-stack
kubectl apply -f yaml/kubernetes-dashboard.yaml
kubectl delete -f yaml/kubernetes-dashboard.yaml
kubectl get all --namespace kubernetes-dashboard
kubectl apply -f yaml/kubernetes-dashboard-rback-cluster-admin-user.yaml
kubectl create token k8s-dashboard-cluster-admin-user --duration=999999h -n kubernetes-dashboard
Note: use this token for Kubernetes Dashboard login
kubectl apply -f yaml/metrix-server.yaml
kubectl delete -f yaml/metrix-server.yaml
kubectl get deployment metrics-server -n kube-system
kubectl top nodes
This will deploy a daemonset nginx-ingress-microk8s-controller
microk8s enable ingress
kubectl apply -f yaml/ingress.yaml --namespace=home-stack
microk8s enable rbac
So that remotely cluster opertaion can be performed
kubectl apply -f yaml/home-user-rback-cluster-admin-user.yaml
cd ~/cert/k8s
openssl genrsa -out alok.key 2048
openssl req -new -key alok.key -out alok-csr.pem -subj "/CN=alok/O=home-stack/O=ingress"
scp alok-csr.pem alok@jgte:cert/
openssl x509 -req -in ~/cert/alok-csr.pem -CA /var/snap/microk8s/current/certs/ca.crt -CAkey /var/snap/microk8s/current/certs/ca.key -CAcreateserial -out ~/cert/alok-crt.pem -days 365
scp alok@jgte:cert/alok-crt.pem ~/cert/k8s
scp alok@jgte:/var/snap/microk8s/current/certs/ca.crt ~/cert/k8s
Note: add below entry in /etc/hosts
192.168.1.200 jgte kubernetes
kubectl config set-cluster home-cluster --server=https://kubernetes:16443 --certificate-authority=/Users/aloksingh/cert/k8s/ca.crt --embed-certs=true
cat ~/.kube/config
kubectl config set-credentials alok --client-certificate=/Users/aloksingh/cert/k8s/alok-crt.pem --client-key=/Users/aloksingh/cert/k8s/alok.key --embed-certs=true
kubectl config set-context alok-home --cluster=home-cluster --namespace=home-stack --user alok
kubectl config use-context alok-home
kubectl autoscale deployment dashboard-deployment --min=2 --max=3 -n home-stack
kubectl get hpa --namespace home-stack
kubectl edit hpa dashboard-deployment --namespace home-stack
kubectl scale -n home-stack deployment dashboard-deployment --replicas=1
kubectl get all --all-namespaces
kubectl logs pod/dashboard-deployment-65cf5b8858-7x8z8 --namespace home-stack
kubectl describe pod/dashboard-deployment-65cf5b8858-7x8z8 --namespace=home-stack
kubectl get -A pods
kubectl explain --api-version="batch/v1beta1" cronjobs.spec
To be explored - seems microk8s isteo addon not supported for ARMx64 architecture. Where the same is supported for minikube.
Application | Description | Service Type | Deployment/StatefulSet/CronJob/DaemonSet | URL | Comments |
---|---|---|---|---|---|
Home ETL Service | ETL for bank statement and other sources | ClusterIP (Headless) | StatefulSet | /home/etl | NA |
Home API Service | API for Bank/Expense/Tax/Investment/etc... | ClusterIP | Deployment | /home/api | GraalVM based native Image |
Home Dashboard | ReactJS App on Nginx | NodePort | Deployment | http://jgte:30080 or https://jgte | - For multinode deployment Interface has to be changed to ClusterIP and put behind Ingress - externalTrafficPolicy: Local to disable SNATing |
Home GIT Cronjob | Cronjob to update GIT with uploaded statement | None | CronJob | NA | NA |
Database | MySQL | NodePort | StatefulSet | jdbc:mysql://mysql:3306/home-stack | - NodePort because I want to access SQL from outside of the cluster |
Kubernetes Dashboard | LoadBalancer (static IP) | Deployment | https://jgte:8443/ | ||
Kubernetes Matrix | Generating resource utilization matrix | ClusterIP | Deployment | NA | |
Kubernetes Matrix Scraper | Matrix scrapper from pods | ClusterIP | Deployment | NA | |
Jaeger Dashboard | NodePort | Deployment | http://jgte:31686/ | ||
Ingress Controller | Nginx Ingress Controller | NodePort | DaemonSet | Port: 443 | API/ETL/Dashboard are behind Nginx but still we have Dashboard accessible directly (from mobile cant access host name - require local DNS server) |
graph LR
A[Write Code] --> B{Does it work?}
B -- Yes --> C[Great!]
B -- No --> D[Google]
D --> A