Setting up your environment - Arthyon/microservice-poc GitHub Wiki
Clone repository
- SSH:
git clone [email protected]:Arthyon/microservice-poc.git - HTTPS:
git clone https://github.com/Arthyon/microservice-poc.git
Install tools
This proof of concept needs these applications to run:
- Docker
- Some version of local Kubernetes
- Helm
- [Optional]: Visual Studio Code
Docker
Follow the official guide.
Note for windows-users
This PoC uses volume mounting while developing to reduce the need for image rebuilding. To get this working, you need to share the drive you cloned the repository to. Follow this guide to share the whole drive.
You will most likely encounter issues when mounting the drive. Check out this section of the troubleshooting-guide for help.
Kubernetes
For windows users, the easiest way is to enable Kubernetes in the Docker-client (`Settings -> Kubernetes -> Enable Kubernetes).
If you are not using the built in Kubernetes, Minikube is the best tool.
Note: The rest of the documentation assumes your local Kubernetes-installation has direct access to the locally built docker images without needing to push them to a container registry. Check out this guide for connecting Minikube and Docker together.
Helm
You do not need a local Tiller-installation.
If you installed Helm from the binary releases you need to add Helm to the system Path (Control Panel->System->Advance system settings->Environment variables). Restart your computer after you've done this to ensure all applications have loaded the recent changes. Run the command "helm help" from cdm or powershell to verify that helm is working.
Visual Studio Code
It is of course possible to use any editor, but the debugging capability in this repo is written for VSCode. You have to figure out how to debug node and .Net in docker for your editor of choice.
Follow this guide for your OS to set up VSCode. Note for Arch-users: I have not been able to get all features to work correctly using the OSS version of code from the repositories. Use the AUR-package for the MS-branded version, visual-studio-code-bin
Optional extensions (install from inside the editor):
C#will give proper intellisense for the .Net-projectsDockerprovides syntax highlighting to DockerfilesKubernetesprovides syntax highlighting to kubernetes yaml-filesSwagger Viewermakes it easy to preview changes to the open api specification files
Since we're using a non-standard naming for cloud dockerfiles, this snippet is added to the workspace settings to get syntax highlighting (File->Preferences->Settings->Workspace Settings tab):
"files.associations": { "Dockerfile-cloud": "dockerfile" }
Test your setup
Open a new terminal and run these commands:
dockerkubectlhelm
If all commands are recognized you're good to go.
Initialization
To complete the setup, a few additional steps must be completed. We need to:
- Set up connection to Kubernetes
- Initialize Helm in your local Kubernetes installation
- Mount your local disk into Kubernetes
- Build all services so they are available for deploy
- Deploy the containers to Kubernetes
Connect to Kubernetes
Run kubectl config view to get a list of contexts (i.e. known Kubernetes clusters). You should see an entry called current-context. If you are using Docker for desktop the 'current-context' should be 'docker-for-desktop'. If you're using something else and the 'current-context' is not set to your local cluster, run kubectl config use-context <clustername>.
Initialize Helm in local cluster
Run helm init to prepare your cluster for deployments.
Mount local disk
We need to mount a local disk into Kubernetes. For Kubernetes in Docker for windows, it is already done when you shared your drive with Docker. It is mounted on the path /host_mnt/<drive letter>.
We need to tell Kubernetes about this path, so create a file named local.yaml in Infrastructure/kubernetes/charts/default/ with this content:
mountBasePath: <mount path to repository>
An example using Docker for Windows could be:
mountBasePath: /host_mnt/c/Source/microservice-poc/ for a project in C:\Source\microservice-poc
Build all services
In the root directory run docker build <path-to-dockerfile> -t microservices/<servicename> for each service to build the images.
Note: The name specified by -t must match the image name in the file Infrastructure/kubernetes/charts/default/values.dev.yaml.
Deploy to local Kubernetes
Run helm upgrade --install develop -f Infrastructure/kubernetes/charts/default/values.dev.yaml -f Infrastructure/kubernetes/charts/default/local.yaml ./Infrastructure/kubernetes/charts/default/
You will get a deployment named develop for this deploy. Make note of this, as it will be used during development. You can also get it by running helm list to get a list of all deploys.
Next steps
Refer to the section Development workflow to start developing or Architecture overview for a description of the architecture.