DIGIT is a distributed microservice-based platform that comprises many services which are containerized, depending upon the required features we can run only those services on any container supported orchestration platform like docker compose, Kubernetes, etc.
Here in this Quickstart guide we'll install basic services to get the platform up and running along with the PGR module, before we setup DIGIT, we'll create a lightweight Kubernetes cluster called k3d on a local machine with specified H/W requirement. The H/W requirements are listed below to ensure before we proceed further.
To provision a lightweight Kubernetes cluster, please follow the instructions below in context to your OS and install the k3d on your machine.
min 4 vCPUs (recommended 8)
min 8GiB of RAM (recommended 16)
min 30GiB of HDD (recommended 30+)
Windows 10 or above
Docker Desktop for windows need to be installed
Install kubectl on Windows
Install Chocolatey package manager for windows
Install GitBash as an alternative command prompt that allows most of the Linux commands on windows.
Now open gitbash and Install k3d on Windows using the below command
choco install k3d
Once the above prerequisites are met, run the following tasks depending upon your OS.
**login/ssh into the machine, go to terminal/command prompt and run the following commands as an admin user.
Create /Kube directory and change permission. To use this directory for persistent data mount. This means all the container logs, data will be stored here.
mkdir /kubechmod 777 /kube#if you are unable to create the /kube folder in the root# you can create it your user directory and provide the absolue path below
Create a cluster with a single master node and 2 agents (Worker Nodes) and mount the pre-created directory (for data persistence).
When cluster creation is successful, Get the kubeconfig file, which will allow you to connect the to the cluster at any time.
k3d kubeconfig get k3s-default > k3dconfigkubectl config use-context k3d-k3s-default --kubeconfig=k3dconfig
Verify the Cluster creation by running the following commands from your local machine where the kubectl is installed. It gives you the sample output as below
[email protected]:/# kubectl cluster-infoOutPut:Kubernetes control plane is running at https://0.0.0.0:33931CoreDNS is running at https://0.0.0.0:33931/api/v1/namespaces/kube-system/services/kube-dns:dns/proxyMetrics-server is running at https://0.0.0.0:33931/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy[email protected]:/# k3d cluster listNAME SERVERS AGENTS LOADBALANCERk3s-default 1/1 2/2 true
You can verify the workers' nodes created by using the following command.
kubectl get nodesOutput:NAME STATUS ROLES AGE VERSIONk3d-k3s-default-agent-0 Ready <none> 3d18h v1.21.1+k3s1k3d-k3s-default-agent-1 Ready <none> 3d18h v1.21.1+k3s1k3d-k3s-default-server-0 Ready control-plane,master 3d18h v1.21.1+k3s1kubectl top nodesOutput:W0625 07:56:24.588781 12810 top_node.go:119] Using json format to get metrics. Next release will switch to protocol-buffers, switch early by passing --use-protocol-buffers flagNAME CPU(cores) CPU% MEMORY(bytes) MEMORY%k3d-k3s-default-agent-0 547m 6% 1505Mi 9%k3d-k3s-default-agent-1 40m 0% 2175Mi 13%k3d-k3s-default-server-0 59m 0% 2286Mi 14%
If the above steps are completed successfully, your Cluster is now up and running ready to proceed with the DIGIT Deployment.
Now that we have the Infra setup to proceed with the DIGIT Deployment. Following are the tools that need to be installed on the machine before proceeding with the DIGIT Services deployment.
What we'll deploy in Quickstart:
DIGIT's core platform services
All DIGIT services are packaged using helm charts Installing Helm
kubectl is a CLI to connect to the kubernetes cluster from your machine
Install CURL for making api calls
Install Visualstudio IDE Code for better code/configuration editing capabilities
Install Postman to run some digit bootstrap scripts
[email protected]:/# git clone -b quickstart https://github.com/egovernments/DIGIT-DevOps
After cloning the repo CD into the folder DIGIT-DevOps and type the "code ." command that will open the visual editor and opens all the files from the repo DIGIT-DevOps
Have look at the sample deployment config file that needs to be configured as per any specific values according to your needs. (For a quick start you can run as it is)
Add the following entries in your host file /etc/hosts depending on your OS, instructions can be found here.
Once all the prerequisites set up is complete, go to the following repo, run the command and follow the instructions.
[email protected]:# cd DIGIT-DevOps/deploy-as-code/egov-deployer[email protected]:# go run digit_setup.go#Be prepared for the following questions1. Do you have the Kubernetes Setup?2. Provide the path of the intented env kubeconfig file3. Which version of the DIGIT that you want to install - Choose "Quickstart"4. What DIGIT Modules that you choose to install5. All, done, Now do you want to preview the deployment manifests6. Are you good to proceed with the DIGIT InstallationAll Done.
You can now test the Digit application status in command prompt/terminal by using the below command.
curl -Is http://quickstart.local.digit/employee/login | head -n 1HTTP/2 200
Post deployment, now the application will be accessible from the configured domain.
To try out PGR employee login, Lets create a sample tenant, city, user to login and assign LME employee role through the seed script
We have to do the kubectl port-forwarding of the egov-user service running from kubernetes cluster to your localhost, this will now give you access to egov-user service directly and interact with the api directly.
kubectl port-forward svc/egov-user 8080:8080 -n egovForwarding from 127.0.0.1:8080 -> 8080Forwarding from [::1]:8080 -> 8080
Seed the sample data
Ensure you have the postman to run the following seed data api, if not Install postman on your local
Import the following postman collection into the postman and run it, this will have the seed data that enable sample test users and localisation data.
To test the kubernetes operations through kubectl from you local machine, please execute the below commands.
#get the pods running in the clusterkubectl get pods -n egovOutput:NAME READY STATUS RESTARTS AGEcitizen-79cf89659c-8glf4 1/1 Running 0 14degov-accesscontrol-78b78dddb9-tfbkf 1/1 Running 0 21degov-enc-service-574cd7b5b5-hmhh4 1/1 Running 0 36degov-idgen-84954b565b-xsnqj 1/1 Running 0 45degov-indexer-5f5fbb6f4b-58rtm 1/1 Running 0 43degov-localization-6cc5977bb9-gm7f9 1/1 Running 0 27degov-mdms-service-65d6d65d8c-t85d9 1/1 Running 0 21degov-user-6676968d76-8n6t6 1/1 Running 0 29degov-workflow-v2-5cdb96bcf5-dcgmf 1/1 Running 0 36demployee-749464fbfb-tptlh 1/1 Running 0 14dnginx-ingress-controller-b9678869c-mkslb 1/1 Running 0 49dpgr-services-b9f4ffdbf-5h5kd 1/1 Running 0 38dzuul-788bf8cd8b-9nxfl 1/1 Running 0 41d#Delete the pods so that it gets restarted automaticallykubectl delete pods zuul-788bf8cd8b-9nxfl nginx-ingress-controller-b9678869c-mkslb -n egovOutput:pod "zuul-788bf8cd8b-9nxfl" deletedpod "nginx-ingress-controller-b9678869c-mkslb" deleted
You have successfully completed the DIGIT application setup. You can now experience the DIGIT platform - PGR module.