Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Deploy backend and mongodb service to Kubernetes #9

Merged
merged 9 commits into from
May 4, 2022

Conversation

Raffone17
Copy link
Collaborator

No description provided.

@gmacario
Copy link
Contributor

@Raffone17 thanks for your contribution.
In the next days I will give it a try on another Kubernetes cluster and will report my findings.

However for the time being would you be able to sanitize your PR and have Super-Linter pass?
It looks like most of the errors come from the Helm chart templates.
Please have a look at related #7

@gmacario
Copy link
Contributor

gmacario commented Apr 28, 2022

Testing PR on cluster rfid-staging

Logged in as root@rfid-staging

mkdir -p ~/github/aquariophilie
cd ~/github/aquariophilie
git clone https://github.com/aquariophilie/node-koa-boilerplate
cd node-koa-boilerplate
git checkout feature/5-deploy-application-to-kubernetes

Result:

root@rfid-webapp-staging:~# mkdir -p ~/github/aquariophilie
root@rfid-webapp-staging:~# cd ~/github/aquariophilie/
root@rfid-webapp-staging:~/github/aquariophilie# git clone https://github.com/aquariophilie/node-koa-boilerplate
Cloning into 'node-koa-boilerplate'...
remote: Enumerating objects: 176, done.
remote: Counting objects: 100% (176/176), done.
remote: Compressing objects: 100% (145/145), done.
remote: Total 176 (delta 52), reused 117 (delta 16), pack-reused 0
Receiving objects: 100% (176/176), 155.52 KiB | 9.15 MiB/s, done.
Resolving deltas: 100% (52/52), done.
root@rfid-webapp-staging:~/github/aquariophilie# cd node-koa-boilerplate/
root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate# git checkout feature/5-deploy-application-to-kubernetes
Branch 'feature/5-deploy-application-to-kubernetes' set up to track remote branch 'feature/5-deploy-application-to-kubernetes' from 'origin'.
Switched to a new branch 'feature/5-deploy-application-to-kubernetes'
root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate#

Install helm

snap install helm --classic

Now follow the instructions in toplevel README.md

cd chart
helm install my-release koa-mongo-k8s

Result:

root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate/chart# helm install my-release koa-mongo-k8s
NAME: my-release
LAST DEPLOYED: Thu Apr 28 18:23:47 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
  export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services my-release-koajs-k8s)
  export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT
root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate/chart#

Verify using k9s that service my-release-koajs-k8s is up and running

image

Notice that the URL (http://$NODE_IP:$NODE_PORT) returned by the commands shown in the terminal is different from what reported by k9s:

root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate/chart# export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services my-release-koajs-k8s)
root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate/chart#   export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate/chart#   echo http://$NODE_IP:$NODE_PORT
http://10.0.0.4:32498
root@rfid-webapp-staging:~/github/aquariophilie/node-koa-boilerplate/chart#

TODO: Figure out how to publicly access the backend API URL

@gmacario
Copy link
Contributor

gmacario commented Apr 30, 2022

TODO: Figure out how to publicly access the backend API URL

For The Records: I managed to access the backend API URL using Lens - The Kubernetes IDE using the following procedure:

  • Launch Lens and connect to the Kubernetes cluster (in our case,"rfid-staging")

    image

  • Select Network > Services

    image

  • Click on service "my-release-koajs-k8s" and look at section "Connection"

    image

  • Click on the port (in our case, "4000:32498/TCP". This will open a browser tab on http://localhost:63234 which is the API endpoint forwarded to localhost

    image

  • You may edit the URL in the browser to access other API on the same endpoint, for instance http://localhost:6234/api/status

    image

@gmacario
Copy link
Contributor

gmacario commented May 3, 2022

@Raffone17 I believe I sorted out the problems which made Super-Linter fail, please review and merge #11

@gmacario gmacario added the enhancement New feature or request label May 3, 2022
@gmacario gmacario self-requested a review May 3, 2022 07:26
Copy link
Contributor

@gmacario gmacario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a couple of cosmetic fixes.

Apart from that, LGTM.

@gmacario gmacario changed the title Deploy application to kubernetes [Feat] Deploy application to kubernetes May 4, 2022
@gmacario gmacario merged commit 72cfb09 into main May 4, 2022
@gmacario gmacario deleted the feature/5-deploy-application-to-kubernetes branch May 4, 2022 10:02
@gmacario gmacario changed the title [Feat] Deploy application to kubernetes [Feat] Deploy backend and mongodb service to Kubernetes May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants