From 07bcd46206ed3049c45dcaac3ce8e7f5b015381f Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Fri, 11 Aug 2023 12:30:05 +0530 Subject: [PATCH 1/6] README.md: fix a typo Fix a typo in a command to run `api` deployment. Fixes Signed-off-by: Jeny Sadadia --- kube/minikube/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/minikube/README.md b/kube/minikube/README.md index 1dca3a24..39e36ca0 100644 --- a/kube/minikube/README.md +++ b/kube/minikube/README.md @@ -132,7 +132,7 @@ kubectl logs As kernelci-api relies on other deployments, it is important to get them up and running first and get kernelci-api up and running afterwards. Thus after completing all the above steps, you can apply ```api-deployment.yaml``` file that is present in the root of kube/minikube folder. To apply the YAML file in the minikube cluster, simply run ``` -kubectly apply -f api-deployment.yaml +kubectl apply -f api-deployment.yaml ``` ## Cleaning up everything afterwards From f2ede18ed1faa613b2b301063a0c8c2bd570c02f Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Fri, 11 Aug 2023 11:52:48 +0530 Subject: [PATCH 2/6] kube/minikube: create `ConfigMap` for API Use `ConfigMap` to provide configuration for redis host and DB service URL. Add a manifest file to generate `configmap` named `kernelci-api-config`. API deployment will reference `REDIS_HOST` and `MONGO_SERVICE` from the configmap. Signed-off-by: Jeny Sadadia --- kube/minikube/configmap/api-configmap.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 kube/minikube/configmap/api-configmap.yaml diff --git a/kube/minikube/configmap/api-configmap.yaml b/kube/minikube/configmap/api-configmap.yaml new file mode 100644 index 00000000..81a1c8ad --- /dev/null +++ b/kube/minikube/configmap/api-configmap.yaml @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2023 Collabora Limited +# Author: Jeny Sadadia + +apiVersion: v1 +kind: ConfigMap +metadata: + name: kernelci-api-config + namespace: default +data: + redis_host: "kernelci-api-redis.default.svc.cluster.local" + mongo_service: "mongodb://kernelci-api-db.default.svc.cluster.local:27017" From 3c3412e1a15310b6fc5cc75d394ab6d2a255a132 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Fri, 11 Aug 2023 11:58:25 +0530 Subject: [PATCH 3/6] kube/minikube/api-deployment: use configmap variables Reference configmap `kernelci-api-config` to get environment variables for redis hostname and DB service URL. Signed-off-by: Jeny Sadadia --- kube/minikube/api-deployment.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kube/minikube/api-deployment.yaml b/kube/minikube/api-deployment.yaml index 362e04b8..280baf0c 100644 --- a/kube/minikube/api-deployment.yaml +++ b/kube/minikube/api-deployment.yaml @@ -29,9 +29,15 @@ spec: name: kernelci-api-secret key: secret-key - name: REDIS_HOST - value: "kernelci-api-redis.default.svc.cluster.local" + valueFrom: + configMapKeyRef: + name: kernelci-api-config + key: redis_host - name: MONGO_SERVICE - value: "mongodb://kernelci-api-db.default.svc.cluster.local:27017" + valueFrom: + configMapKeyRef: + name: kernelci-api-config + key: mongo_service volumeMounts: - name: api-volume mountPath: /home/kernelci/api From bb60977f526180e08d2d367c63328aa86c8fd70b Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Fri, 11 Aug 2023 13:04:53 +0530 Subject: [PATCH 4/6] apply-all.sh: add command to create configmap Add `kubectl` command to generate `ConfigMap` for API deployment. Signed-off-by: Jeny Sadadia --- kube/minikube/hack/apply-all.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kube/minikube/hack/apply-all.sh b/kube/minikube/hack/apply-all.sh index 36dfa561..3fcc51b6 100755 --- a/kube/minikube/hack/apply-all.sh +++ b/kube/minikube/hack/apply-all.sh @@ -86,6 +86,10 @@ check_job_completed "github-cloning-job" kubectl create secret generic kernelci-api-secret --from-literal=secret-key=$(openssl rand -hex 32) check_resource_exist "Secret" "kernelci-api-secret" +# Generate configmap +kubectl create -f ../configmap/api-configmap.yaml +check_resource_exist "configmaps" "kernelci-api-config" + # Set up persistent volume claim kubectl apply -f ../pvc/db-pvc.yaml check_pvc_bound "mongo-data-pvc" From 2b6839df07d30cb32751077b9333a4a9be5d2227 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Fri, 1 Sep 2023 13:10:46 +0530 Subject: [PATCH 5/6] kube/minikube: rename hack directory Rename directory name containing scripts to automate deployment from `hack` to `scripts`. Update `README.md` accordingly. Signed-off-by: Jeny Sadadia --- kube/minikube/README.md | 4 ++-- kube/minikube/{hack => scripts}/apply-all.sh | 0 kube/minikube/{hack => scripts}/clean-all.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename kube/minikube/{hack => scripts}/apply-all.sh (100%) rename kube/minikube/{hack => scripts}/clean-all.sh (100%) diff --git a/kube/minikube/README.md b/kube/minikube/README.md index 39e36ca0..5a0139ad 100644 --- a/kube/minikube/README.md +++ b/kube/minikube/README.md @@ -137,14 +137,14 @@ kubectl apply -f api-deployment.yaml ## Cleaning up everything afterwards -To clean up everything simply use the ```clean-all.sh``` script provided in the root of the kube/minikube/hack folder by running +To clean up everything simply use the ```clean-all.sh``` script provided in the root of the kube/minikube/scripts folder by running ``` ./clean-all.sh ``` ## Deploying all the resources at once -To apply all the resources at once, you can use the ```apply-all.sh``` script provided in the root of the kube/minikube/hack folder by running +To apply all the resources at once, you can use the ```apply-all.sh``` script provided in the root of the kube/minikube/scripts folder by running ``` ./apply-all.sh ``` diff --git a/kube/minikube/hack/apply-all.sh b/kube/minikube/scripts/apply-all.sh similarity index 100% rename from kube/minikube/hack/apply-all.sh rename to kube/minikube/scripts/apply-all.sh diff --git a/kube/minikube/hack/clean-all.sh b/kube/minikube/scripts/clean-all.sh similarity index 100% rename from kube/minikube/hack/clean-all.sh rename to kube/minikube/scripts/clean-all.sh From ca87e47f6cd24b4b7974fd754b8547a5f2ad1319 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Fri, 1 Sep 2023 13:13:37 +0530 Subject: [PATCH 6/6] kube/minikube/scripts: rename apply-all.sh script Rename script from `apply-all.sh` to `deploy.sh`. The script can be used to automate API deployment in k8s. Signed-off-by: Jeny Sadadia --- kube/minikube/README.md | 4 ++-- kube/minikube/scripts/{apply-all.sh => deploy.sh} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename kube/minikube/scripts/{apply-all.sh => deploy.sh} (100%) diff --git a/kube/minikube/README.md b/kube/minikube/README.md index 5a0139ad..0c08ef88 100644 --- a/kube/minikube/README.md +++ b/kube/minikube/README.md @@ -144,8 +144,8 @@ To clean up everything simply use the ```clean-all.sh``` script provided in the ## Deploying all the resources at once -To apply all the resources at once, you can use the ```apply-all.sh``` script provided in the root of the kube/minikube/scripts folder by running +To apply all the resources at once, you can use the ```deploy.sh``` script provided in the root of the kube/minikube/scripts folder by running ``` -./apply-all.sh +./deploy.sh ``` This script would also do the clean up and will deploy everything afresh. But it can be time-consuming to deploy everything afresh, so if you want to reconfigure some deployment maybe because the image is updated, just reapply that deployment or do the rolling update instead of running this script. diff --git a/kube/minikube/scripts/apply-all.sh b/kube/minikube/scripts/deploy.sh similarity index 100% rename from kube/minikube/scripts/apply-all.sh rename to kube/minikube/scripts/deploy.sh