Browse Source

+ praytime, NC@GCP /A

Anton 8 tháng trước cách đây
mục cha
commit
0ebb14ff40
2 tập tin đã thay đổi với 236 bổ sung0 xóa
  1. 35 0
      console-terminal/praytime.sh
  2. 201 0
      storage/NextCloud-as-container@GCP.md

+ 35 - 0
console-terminal/praytime.sh

@@ -0,0 +1,35 @@
+### ## #
+#
+# show Islamic prayer times
+#
+# 2018 10 08  + initial /A
+# 2019 12 14  * fix /A
+# 2019 03 17  * updated installation instructions /A
+# 2020 12 24  * updated /A
+# 2024-02-11  * updated for Debian 11.8 /A
+#
+### ## #
+
+## Fedora 29,31
+# yum install libitl
+# from link get the latest package
+#    http://www.rpm-find.net/linux/rpm2html/search.php?query=itools
+# and install it
+#    rpm -ivh itools-1.0-7.fc15.x86_64.rpm
+# or
+#    dnf install itools-1.0-6.fc14.x86_64.rpm
+
+## Debian 11.8
+#    apt install itools
+
+echo "---------------------------------------------------------"
+echo "Now is:"
+date
+echo ""
+echo "For Riyadh, KSA:"
+ipraytime --brief -lat 24.4827 -lon 46.3945 -u 3 -a 6 -h24
+echo ""
+
+echo "For Mersin, Turkey:"
+ipraytime --brief -lat 36.63890968272466 -lon 34.36292102081904 -u 3 -a 1 -h24
+echo "---------------------------------------------------------"

+ 201 - 0
storage/NextCloud-as-container@GCP.md

@@ -0,0 +1,201 @@
+# installing NextCloud container to GCP GKE
+
+
+
+
+Preparations
+```shell
+gcloud ini
+gcloud config set accessibility/screen_reader false
+gcloud auth list
+gcloud config list project
+gcloud config set compute/region europe-north1
+gcloud config set compute/zone europe-north1-c
+gcloud config set project spry-analyzer-xxxxxx
+```
+
+
+
+## Create DB, DB user in Cloud SQL:
+```
+34.88.xx.xx
+172.21.xx.xx
+DB: hub2_2dz_fi_nextcloud
+u: hub2_2dz_fi_nextcloud
+p: (StrongPass)
+```
+
+
+
+## Create repostory in Artifact Registry
+```
+Docker
+Remote
+Docker Hub
+Unauthenticated
+```
+
+
+
+Create, check
+```bash
+gcloud artifacts repositories create nc-docker-local \
+   --repository-format=docker \
+   --mode=standard-repository \
+   --location=europe-north1
+gcloud artifacts repositories list
+```
+
+
+Get URL for repository
+```bash
+gcloud artifacts repositories describe nc-docker-local --location=europe-north1
+```
+
+
+Make local tmp dir, clone repo
+```bash
+mkdir delme11
+cd delme11/docker
+git clone https://github.com/nextcloud/docker.git
+```
+
+Copy templates
+```bash
+cp .examples/dockerfiles/full/apache/Dockerfile .
+cp .examples/dockerfiles/full/apache/supervisord.conf .
+cp .examples/docker-compose/insecure/mariadb/apache/db.env .
+```
+
+Provide ecredentials
+```bash
+vi db.env
+cp .examples/docker-compose/insecure/mariadb/apache/docker-compose.yml .
+vi docker-compose.yml
+```
+
+Build application, tag it and push it to repository
+```bash
+docker build -t europe-north1-docker.pkg.dev/spry-analyzer-xxxxxx/nc-docker-local/nc-docker-app:v1 .
+docker images
+```
+
+Give permissions. Get project iD number.
+```bash
+gcloud projects list
+853xxxxxxx034
+
+gcloud artifacts repositories add-iam-policy-binding nc-docker-local \
+    --location=europe-north1 \
+    --member=serviceAccount:853xxxxxxx34-compute@developer.gserviceaccount.com \
+    --role="roles/artifactregistry.reader"
+
+gcloud artifacts repositories add-iam-policy-binding nc-docker-local \
+    --location=europe-north1 \
+    --member=serviceAccount:853xxxxxxx34-compute@developer.gserviceaccount.com \
+    --role="roles/artifactregistry.writer"
+```
+
+Issue:
+```bash
+ERROR: (gcloud.artifacts.repositories.add-iam-policy-binding) PERMISSION_DENIED: The caller does not have permission
+```
+
+
+Run docker locally (will be exposed to 8080)
+```bash
+docker run --rm -p 8080:80 europe-north1-docker.pkg.dev/spry-analyzer-xxxxxx/nc-docker-local/nc-docker-app:v1
+```
+
+
+
+Pushing docker image into Artifact Registry
+```bash
+gcloud auth configure-docker europe-north1-docker.pkg.dev
+docker push europe-north1-docker.pkg.dev/spry-analyzer-xxxxxx/nc-docker-local/nc-docker-app:v1
+```
+
+
+List content of repostiory
+```bash
+gcloud artifacts files list --location=europe-north1 --project=spry-analyzer-xxxxxx --repository=nc-docker-local
+```
+
+
+Create a GKE cluster
+```shell
+gcloud components install kubectl
+gcloud container clusters create --machine-type=e2-micro --zone=europe-north1-c twodz-nc-demo
+gcloud container clusters list
+```
+
+
+Get authentication credentials for the cluster (in order to manage it)
+```shell
+gcloud container clusters get-credentials twodz-nc-demo --zone=europe-north1-c
+kubectl cluster-info
+```
+
+
+
+Deploy an application to the cluster
+```shell
+kubectl create deployment nc-demo-app --image=europe-north1-docker.pkg.dev/spry-analyzer-xxxxxx/nc-docker-local/nc-docker-app:v3
+kubectl get deployments
+kubectl scale deployment nc-demo-app --replicas=1
+kubectl autoscale deployment nc-demo-app --cpu-percent=80 --min=1 --max=1
+kubectl get pods --output=wide
+kubectl exec --stdin --tty nc-demo-app-54dc479f5-crvhx -- /bin/bash
+```
+
+
+
+## Publish to Internet (create load balancer)
+```bash
+kubectl expose deployment nc-demo-app --name=nc-demo-app-service --type=LoadBalancer --port 80 --target-port 80
+# wait for external IP be assigned from '<pending> state'
+kubectl get services --output=wide
+firefox http://[EXTERNAL-IP]:80
+```
+
+
+
+## Cleaning
+```shell
+kubectl delete  deployment nc-demo-app
+gcloud container clusters delete twodz-nc-demo --zone=europe-north1-c
+docker rmi -f 0fa923cc879e
+```
+
+
+
+
+
+
+Issue:
+```
+Memory limit of 512 MiB exceeded with 512 MiB used. Consider increasing the memory limit, see https://cloud.google.com/run/docs/configuring/memory-limits
+```
+Solution: increase RAM size.
+
+
+
+
+
+Create Volume in Cloud Storage (Bucket).
+
+
+
+
+
+
+
+
+troubleshooting
+```bash
+kubectl get pods --output=wide
+kubectl exec --stdin --tty nc-demo-app-54dc479f5-crvhx -- /bin/bash
+apt update
+apt install net-tools
+netstat -ntap
+```