- Have skaffold installed and run
skaffold dev
in the root directory of the project - for running in ubuntu install minikube and run
minikube start
and thenskaffold dev
- Use
skaffold dev --port-forward
to forward the ports to the host machine
OR
4. run minukube service -all
to get the url of the service and open it in the browser
5. run minikube dashboard
to see the dashboard of the cluster
6. run minikube stop
to stop the cluster
7. run minikube delete
to delete the cluster
8. run minikube addons list
to see the addons installed
- Create a secret in the cluster using the command
kubectl create secret generic jwt-secret --from-literal=JWT_KEY=your_secret_key
- using
getServerSideProps
to get the currentUser on the initial page load don't work if we hit/api/users/currentuser
becausegetServerSideProps
runs on the server and the request to/api/users/currentuser
is made on the client pod which throws error of not found. - To solve this we need to make a forward that request to the ingress-nginx controller which will then forward the request with the cookie from the browser to the correct service (auth service) and then return the response to the client.
- So we need to make a proxy request to the ingress-nginx controller which will then forward the request to the correct service.
- The request need to made on
"http://SERVICENAME.NAMESPACE.svc.cluster.local/api/users/currentuser"
which in our case is,"http://ingress-nginx-controller.ingress-nginx.svc.cluster.local/api/users/currentuser"
. and pass the headers as well. To get the namespace runkubectl get namespace
and to get the service name runkubectl get services -n NAMESPACE
- we created a common shared library to be used between different services.
- it is published on npm under organization and name common -
@cgticketingproject/common
- to avoid any typescript version issues with other projects, we have typescript code in the common code but its compiled to js before publishing.
- to use the common library in other projects, we need to install it using
npm install @cgticketingproject/common
and then import it in the code. - After updating the common library, we need to publish it again using
npm publish --access public
to make the changes available to other projects. For this project we can usenpm run pub
to add and commit to git, increment patch version, build the changes and publish it to npm. - To update the version in the other projects, we need to run
npm update @cgticketingproject/common
npm install @cgticketingproject/common@latest
to get the latest version of the common library.