diff --git a/codemeta.json b/codemeta.json index 34d8cb3..6d59bc5 100644 --- a/codemeta.json +++ b/codemeta.json @@ -7,7 +7,7 @@ "datePublished": "2022-09-25", "dateModified": "2022-09-25", "name": "Water Bodies Detection", - "version": "1.0.0", + "version": "1.1.0", "description": "The Water Bodies Detection is an Application that uses the NDWI index and the Otsu threshold to detect water bodies using Sentinel-2 or Landsat-9 data", "developmentStatus": "active", "downloadUrl": "https://github.com/eoap/quickwin/releases/tag/1.0.0", diff --git a/coder-manifests/coder.yaml b/coder-manifests/coder.yaml new file mode 100644 index 0000000..afc5d43 --- /dev/null +++ b/coder-manifests/coder.yaml @@ -0,0 +1,185 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: code-server-deployment + labels: + app: code-server +spec: + replicas: 1 + selector: + matchLabels: + app: code-server + template: + metadata: + labels: + app: code-server + spec: + initContainers: + - name: init-file-on-volume + image: eoepca/pde-code-server:1.0.0 + command: + - sh + - '-c' + - sh /opt/init/.init.sh + volumeMounts: + - name: workspace-volume + mountPath: /workspace + - name: init + mountPath: /opt/init/.init.sh + subPath: init + resources: + limits: + cpu: '2' + memory: '4Gi' + requests: + cpu: '2' + memory: '2Gi' + imagePullPolicy: IfNotPresent + containers: + - name: code-server + image: eoepca/pde-code-server:1.0.0 + securityContext: + privileged: true + command: ["/bin/bash", "-c"] + args: + - > + code-server --auth none --bind-addr 0.0.0.0:8080 --user-data-dir /workspace /workspace/quickwin + ports: + - containerPort: 8080 + name: web + volumeMounts: + - name: workspace-volume + mountPath: /workspace + - name: bash-login + mountPath: /workspace/.bash_login + subPath: bash-login + - name: bash-rc + mountPath: /workspace/.bashrc + subPath: bash-rc + env: + - name: XDG_CONFIG_HOME + value: /workspace/.local + - name: XDG_DATA_HOME + value: /workspace/.local/share/ + - name: XDG_RUNTIME_DIR + value: /workspace/.local + - name: CWLTOOL_OPTIONS + value: "--podman" + - name: AWS_DEFAULT_REGION + value: "us-east-1" + - name: AWS_ACCESS_KEY_ID + value: "test" + - name: AWS_SECRET_ACCESS_KEY + value: "test" + resources: + limits: + cpu: '2' + memory: '6442450944' + requests: + cpu: '1' + memory: '4294967296' + volumes: + - name: workspace-volume + persistentVolumeClaim: + claimName: code-server-pvc + - name: init + configMap: + name: init + defaultMode: 420 + - name: bash-login + configMap: + name: bash-login + defaultMode: 420 + - name: bash-rc + configMap: + name: bash-rc + defaultMode: 420 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: code-server-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 20Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: code-server-service +spec: + selector: + app: code-server + ports: + - name: web + port: 8080 + targetPort: 8080 + type: ClusterIP +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: init +data: + init: >- + #!/bin/bash + + set -x + + cd /workspace + + git clone 'https://github.com/eoap/quickwin.git' + + code-server --install-extension ms-python.python + + code-server --install-extension redhat.vscode-yaml + + code-server --install-extension sbg-rabix.benten-cwl + + code-server --install-extension ms-toolsai.jupyter + + ln -s /workspace/.local/share/code-server/extensions /workspace/extensions + + mkdir -p /workspace/User/ + + echo '{"workbench.colorTheme": "Visual Studio Dark"}' > /workspace/User/settings.json + + python -m venv /workspace/.venv + + source /workspace/.venv/bin/activate + + /workspace/.venv/bin/python -m pip install --no-cache-dir rasterio click pystac loguru pyproj shapely scikit-image pystac rio_stac ipykernel stactools[validate] + + /workspace/.venv/bin/python -m ipykernel install --user --name quickwin_env --display-name "Python (Quickwin)" + + export AWS_DEFAULT_REGION="us-east-1" + + export AWS_ACCESS_KEY_ID="test" + + export AWS_SECRET_ACCESS_KEY="test" + + aws s3 mb s3://results --endpoint-url=http://localstack:4566 + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: bash-rc +data: + bash-rc: >- + alias ll="ls -l" + + alias aws="aws --endpoint-url=http://localstack:4566" + + source /workspace/.venv/bin/activate +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: bash-login +data: + bash-login: >- + source /workspace/.bashrc \ No newline at end of file diff --git a/coder-manifests/localstack.yaml b/coder-manifests/localstack.yaml new file mode 100644 index 0000000..d570078 --- /dev/null +++ b/coder-manifests/localstack.yaml @@ -0,0 +1,421 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: localstack +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: localstack +rules: +- apiGroups: [""] # "" indicates the core API group + resources: ["pods"] + verbs: ["*"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["get", "create"] +- apiGroups: [""] + resources: ["services"] + verbs: ["get", "list"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: localstack +subjects: +- kind: ServiceAccount + name: localstack +roleRef: + kind: Role + name: localstack + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: v1 +kind: Service +metadata: + name: localstack +spec: + type: ClusterIP + ports: + - name: edge + port: 4566 + targetPort: 4566 + - name: "external-service-port-4510" + port: 4510 + targetPort: "ext-svc-4510" + - name: "external-service-port-4511" + port: 4511 + targetPort: "ext-svc-4511" + - name: "external-service-port-4512" + port: 4512 + targetPort: "ext-svc-4512" + - name: "external-service-port-4513" + port: 4513 + targetPort: "ext-svc-4513" + - name: "external-service-port-4514" + port: 4514 + targetPort: "ext-svc-4514" + - name: "external-service-port-4515" + port: 4515 + targetPort: "ext-svc-4515" + - name: "external-service-port-4516" + port: 4516 + targetPort: "ext-svc-4516" + - name: "external-service-port-4517" + port: 4517 + targetPort: "ext-svc-4517" + - name: "external-service-port-4518" + port: 4518 + targetPort: "ext-svc-4518" + - name: "external-service-port-4519" + port: 4519 + targetPort: "ext-svc-4519" + - name: "external-service-port-4520" + port: 4520 + targetPort: "ext-svc-4520" + - name: "external-service-port-4521" + port: 4521 + targetPort: "ext-svc-4521" + - name: "external-service-port-4522" + port: 4522 + targetPort: "ext-svc-4522" + - name: "external-service-port-4523" + port: 4523 + targetPort: "ext-svc-4523" + - name: "external-service-port-4524" + port: 4524 + targetPort: "ext-svc-4524" + - name: "external-service-port-4525" + port: 4525 + targetPort: "ext-svc-4525" + - name: "external-service-port-4526" + port: 4526 + targetPort: "ext-svc-4526" + - name: "external-service-port-4527" + port: 4527 + targetPort: "ext-svc-4527" + - name: "external-service-port-4528" + port: 4528 + targetPort: "ext-svc-4528" + - name: "external-service-port-4529" + port: 4529 + targetPort: "ext-svc-4529" + - name: "external-service-port-4530" + port: 4530 + targetPort: "ext-svc-4530" + - name: "external-service-port-4531" + port: 4531 + targetPort: "ext-svc-4531" + - name: "external-service-port-4532" + port: 4532 + targetPort: "ext-svc-4532" + - name: "external-service-port-4533" + port: 4533 + targetPort: "ext-svc-4533" + - name: "external-service-port-4534" + port: 4534 + targetPort: "ext-svc-4534" + - name: "external-service-port-4535" + port: 4535 + targetPort: "ext-svc-4535" + - name: "external-service-port-4536" + port: 4536 + targetPort: "ext-svc-4536" + - name: "external-service-port-4537" + port: 4537 + targetPort: "ext-svc-4537" + - name: "external-service-port-4538" + port: 4538 + targetPort: "ext-svc-4538" + - name: "external-service-port-4539" + port: 4539 + targetPort: "ext-svc-4539" + - name: "external-service-port-4540" + port: 4540 + targetPort: "ext-svc-4540" + - name: "external-service-port-4541" + port: 4541 + targetPort: "ext-svc-4541" + - name: "external-service-port-4542" + port: 4542 + targetPort: "ext-svc-4542" + - name: "external-service-port-4543" + port: 4543 + targetPort: "ext-svc-4543" + - name: "external-service-port-4544" + port: 4544 + targetPort: "ext-svc-4544" + - name: "external-service-port-4545" + port: 4545 + targetPort: "ext-svc-4545" + - name: "external-service-port-4546" + port: 4546 + targetPort: "ext-svc-4546" + - name: "external-service-port-4547" + port: 4547 + targetPort: "ext-svc-4547" + - name: "external-service-port-4548" + port: 4548 + targetPort: "ext-svc-4548" + - name: "external-service-port-4549" + port: 4549 + targetPort: "ext-svc-4549" + - name: "external-service-port-4550" + port: 4550 + targetPort: "ext-svc-4550" + - name: "external-service-port-4551" + port: 4551 + targetPort: "ext-svc-4551" + - name: "external-service-port-4552" + port: 4552 + targetPort: "ext-svc-4552" + - name: "external-service-port-4553" + port: 4553 + targetPort: "ext-svc-4553" + - name: "external-service-port-4554" + port: 4554 + targetPort: "ext-svc-4554" + - name: "external-service-port-4555" + port: 4555 + targetPort: "ext-svc-4555" + - name: "external-service-port-4556" + port: 4556 + targetPort: "ext-svc-4556" + - name: "external-service-port-4557" + port: 4557 + targetPort: "ext-svc-4557" + - name: "external-service-port-4558" + port: 4558 + targetPort: "ext-svc-4558" + - name: "external-service-port-4559" + port: 4559 + targetPort: "ext-svc-4559" + selector: + app.kubernetes.io/name: localstack + app.kubernetes.io/instance: localstack +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: localstack +spec: + replicas: 1 + strategy: + type: RollingUpdate + selector: + matchLabels: + app.kubernetes.io/name: localstack + app.kubernetes.io/instance: localstack + template: + metadata: + labels: + app.kubernetes.io/name: localstack + app.kubernetes.io/instance: localstack + spec: + serviceAccountName: localstack + securityContext: + {} + containers: + - name: localstack + securityContext: + {} + image: "localstack/localstack:latest" + imagePullPolicy: IfNotPresent + ports: + - name: edge + containerPort: 4566 + protocol: TCP + - name: "ext-svc-4510" + containerPort: 4510 + protocol: TCP + - name: "ext-svc-4511" + containerPort: 4511 + protocol: TCP + - name: "ext-svc-4512" + containerPort: 4512 + protocol: TCP + - name: "ext-svc-4513" + containerPort: 4513 + protocol: TCP + - name: "ext-svc-4514" + containerPort: 4514 + protocol: TCP + - name: "ext-svc-4515" + containerPort: 4515 + protocol: TCP + - name: "ext-svc-4516" + containerPort: 4516 + protocol: TCP + - name: "ext-svc-4517" + containerPort: 4517 + protocol: TCP + - name: "ext-svc-4518" + containerPort: 4518 + protocol: TCP + - name: "ext-svc-4519" + containerPort: 4519 + protocol: TCP + - name: "ext-svc-4520" + containerPort: 4520 + protocol: TCP + - name: "ext-svc-4521" + containerPort: 4521 + protocol: TCP + - name: "ext-svc-4522" + containerPort: 4522 + protocol: TCP + - name: "ext-svc-4523" + containerPort: 4523 + protocol: TCP + - name: "ext-svc-4524" + containerPort: 4524 + protocol: TCP + - name: "ext-svc-4525" + containerPort: 4525 + protocol: TCP + - name: "ext-svc-4526" + containerPort: 4526 + protocol: TCP + - name: "ext-svc-4527" + containerPort: 4527 + protocol: TCP + - name: "ext-svc-4528" + containerPort: 4528 + protocol: TCP + - name: "ext-svc-4529" + containerPort: 4529 + protocol: TCP + - name: "ext-svc-4530" + containerPort: 4530 + protocol: TCP + - name: "ext-svc-4531" + containerPort: 4531 + protocol: TCP + - name: "ext-svc-4532" + containerPort: 4532 + protocol: TCP + - name: "ext-svc-4533" + containerPort: 4533 + protocol: TCP + - name: "ext-svc-4534" + containerPort: 4534 + protocol: TCP + - name: "ext-svc-4535" + containerPort: 4535 + protocol: TCP + - name: "ext-svc-4536" + containerPort: 4536 + protocol: TCP + - name: "ext-svc-4537" + containerPort: 4537 + protocol: TCP + - name: "ext-svc-4538" + containerPort: 4538 + protocol: TCP + - name: "ext-svc-4539" + containerPort: 4539 + protocol: TCP + - name: "ext-svc-4540" + containerPort: 4540 + protocol: TCP + - name: "ext-svc-4541" + containerPort: 4541 + protocol: TCP + - name: "ext-svc-4542" + containerPort: 4542 + protocol: TCP + - name: "ext-svc-4543" + containerPort: 4543 + protocol: TCP + - name: "ext-svc-4544" + containerPort: 4544 + protocol: TCP + - name: "ext-svc-4545" + containerPort: 4545 + protocol: TCP + - name: "ext-svc-4546" + containerPort: 4546 + protocol: TCP + - name: "ext-svc-4547" + containerPort: 4547 + protocol: TCP + - name: "ext-svc-4548" + containerPort: 4548 + protocol: TCP + - name: "ext-svc-4549" + containerPort: 4549 + protocol: TCP + - name: "ext-svc-4550" + containerPort: 4550 + protocol: TCP + - name: "ext-svc-4551" + containerPort: 4551 + protocol: TCP + - name: "ext-svc-4552" + containerPort: 4552 + protocol: TCP + - name: "ext-svc-4553" + containerPort: 4553 + protocol: TCP + - name: "ext-svc-4554" + containerPort: 4554 + protocol: TCP + - name: "ext-svc-4555" + containerPort: 4555 + protocol: TCP + - name: "ext-svc-4556" + containerPort: 4556 + protocol: TCP + - name: "ext-svc-4557" + containerPort: 4557 + protocol: TCP + - name: "ext-svc-4558" + containerPort: 4558 + protocol: TCP + - name: "ext-svc-4559" + containerPort: 4559 + protocol: TCP + livenessProbe: + failureThreshold: 3 + initialDelaySeconds: 0 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + httpGet: + path: /_localstack/health + port: edge + readinessProbe: + failureThreshold: 3 + initialDelaySeconds: 0 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + httpGet: + path: /_localstack/health + port: edge + resources: {} + env: + - name: DEBUG + value: "0" + - name: EXTERNAL_SERVICE_PORTS_START + value: "4510" + - name: EXTERNAL_SERVICE_PORTS_END + value: "4560" + - name: LOCALSTACK_K8S_SERVICE_NAME + value: localstack + - name: LOCALSTACK_K8S_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: LAMBDA_RUNTIME_EXECUTOR + value: "docker" + - name: LAMBDA_K8S_IMAGE_PREFIX + value: "localstack/lambda-" + - name: LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT + value: "60" + - name: OVERRIDE_IN_DOCKER + value: "1" + volumes: [] \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..392b000 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,106 @@ +# Installation + +This page provides guidance on how to run the hands-on modules using minikube. + +## Prerequisites + +* **Operating System**: A compatible OS (Linux, macOS, or Windows). If using Windows, WSL2 is recommended for compatibility. +* V**irtualization Support**: Ensure virtualization is enabled in the BIOS/UEFI settings, as it's required for running Minikube or Docker. + +## Installation Steps + +### Install Docker + +- Linux: Follow Docker's installation guide. +- macOS and Windows: Install Docker Desktop. + +### Install Minikube + +Download Minikube from the official site. + +Follow the installation instructions based on the OS. + +* macOS: `brew install minikube` +* Linux: Use the binary or package manager (e.g., apt for Ubuntu). +* Windows: Install using Chocolatey: `choco install minikube` + +### Install Kubectl + +Download the `kubectl` binary from Kubernetes' official site. + +Alternatively, use a package manager: + +* macOS: `brew install kubectl` +* Linux: `sudo apt-get install -y kubectl` (debian based) +* Windows: `choco install kubernetes-cli` + +### Install Skaffold + +Follow the installation steps from Skaffold’s official documentation. + +Examples: + +- macOS: `brew install skaffold` +- Linux: Download the binary and move it to /usr/local/bin/. +- Windows: Use Chocolatey: `choco install skaffold` + +### Install Helm + +Follow the installation steps from Helm's official documentation + +- macOS: `brew install helm` +- Linux: Follow Helm's installation guide. +- Windows: `choco install kubernetes-helm` + +### Set Up Minikube + +Start Minikube: `minikube start` + +Verify it’s running: `kubectl get nodes` + +If necessary, specify a driver (e.g., Docker): `minikube start --driver=docker` + +## Deploy the module + +Create the namespace with: + +``` +kubectl create ns eoap-quickwin +``` + +Type `skaffold dev -p coder` + +This prints: + +``` +No tags generated +Starting deploy... + - deployment.apps/code-server-deployment created + - persistentvolumeclaim/code-server-pvc created + - service/code-server-service created + - configmap/init created + - configmap/bash-rc created + - configmap/bash-login created + - serviceaccount/localstack created + - role.rbac.authorization.k8s.io/localstack created + - rolebinding.rbac.authorization.k8s.io/localstack created + - service/localstack created + - deployment.apps/localstack created +Waiting for deployments to stabilize... +Deployments stabilized in 26.042192ms +Starting post-deploy hooks... +Waiting for deployment and pod to be running... +Deployment replicas: +Pod status: Pending +Waiting for deployment and pod to be running... +Deployment replicas: 1 +Pod status: Running +Deployment with label app=code-server is running and a pod is in Running state +Completed post-deploy hooks +Port forwarding service/code-server-service in namespace eoap-quickwin, remote port 8080 -> http://127.0.0.1:8001 +No artifacts found to watch +Press Ctrl+C to exit +Watching for changes... +``` + +Open your browser on the link printed in the log \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index f7889c7..7993485 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -53,6 +53,7 @@ extra_javascript: nav: - Introduction: 'index.md' + - Installation: 'installation.md' - Prerequisites: - Introduction to YAML: prerequisites/yaml.md - Introduction to CWL: prerequisites/cwl.md diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 0000000..210fa94 --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,31 @@ +apiVersion: skaffold/v4beta9 +kind: Config +metadata: + name: eoap-quickwin +profiles: + - name: coder + + manifests: + rawYaml: + - coder-manifests/coder.yaml + - coder-manifests/localstack.yaml + + deploy: + + kubectl: + + flags: + global: # additional flags passed on every command. + - --namespace=eoap-quickwin + hooks: + after: + - host: + command: ["sh", "-c", "./wait-for-it.sh"] + os: [darwin, linux] + + portForward: + - resourceType: service + resourceName: code-server-service + namespace: eoap-quickwin + port: 8080 + localPort: 8000 # Port on your local machine diff --git a/wait-for-it.sh b/wait-for-it.sh new file mode 100755 index 0000000..66565fb --- /dev/null +++ b/wait-for-it.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Label to identify the deployment and pod +LABEL="app=code-server" +NAMESPACE="eoap-quickwin" + +# Function to get the status of the deployment +get_deployment_status() { + kubectl get deployment code-server-deployment -n $NAMESPACE -o "jsonpath={.status.availableReplicas}" +} + +# Function to get the status of the pod +get_pod_status() { + kubectl get pods -l $LABEL -n $NAMESPACE -o "jsonpath={.items[0].status.phase}" +} + +# Check if the deployment and pod are running +while true; do + # Get the current status of the deployment + DEPLOYMENT_STATUS=$(get_deployment_status) + echo "Deployment replicas: $DEPLOYMENT_STATUS" + + # Get the current status of the pod + POD_STATUS=$(get_pod_status) + echo "Pod status: $POD_STATUS" + + # Check if the deployment has 1 available replica and the pod is running + if [ "$DEPLOYMENT_STATUS" = "1" ] && [ "$POD_STATUS" = "Running" ]; then + echo "Deployment with label $LABEL is running and a pod is in Running state" + break + else + echo "Waiting for deployment and pod to be running..." + fi + + # Wait for 5 seconds before checking again + sleep 5 +done \ No newline at end of file diff --git a/water-bodies/command-line-tools/detect-water-body/Dockerfile b/water-bodies/command-line-tools/detect-water-body/Dockerfile index 1545553..9be3cba 100644 --- a/water-bodies/command-line-tools/detect-water-body/Dockerfile +++ b/water-bodies/command-line-tools/detect-water-body/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/python:3.10-slim +FROM docker.io/library/python:3.10-slim@sha256:80619a5316afae7045a3c13371b0ee670f39bac46ea1ed35081d2bf91d6c3dbd RUN pip install --no-cache-dir \ rasterio \ diff --git a/water-bodies/command-line-tools/detect-water-body/app.py b/water-bodies/command-line-tools/detect-water-body/app.py index 1007394..3c9a151 100644 --- a/water-bodies/command-line-tools/detect-water-body/app.py +++ b/water-bodies/command-line-tools/detect-water-body/app.py @@ -181,7 +181,7 @@ def main(item_url, aoi, bands, epsg): asset_href=os.path.basename(water_body), asset_name="data", with_proj=True, - with_raster=False, + with_raster=True, ) cat.add_items([out_item])