3.2 KiB
eShopOnContainers on Kubernetes
The k8s directory contains Kubernetes configuration for the eShopOnContainers app and a PowerShell script to deploy it to a cluster. Each eShopOnContainers microservice has a deployment configuration in deployments.yaml
, and is exposed to the cluster by a service in services.yaml
. The microservices are exposed externally on individual routes (/basket-api
, /webmvc
, etc.) by an nginx reverse proxy specified in frontend.yaml
and nginx.conf
.
Prerequisites
- A Kubernetes cluster. Follow Azure Container Service's walkthrough to create one.
- A private Docker registry. Follow Azure Container Registry's guide to create one.
- Optionally, previous steps can be skipped if you run gen-k8s-env.ps1 script to automatically create the azure environment needed for kubernetes deployment. Azure cli 2.0 must be previously installed installation guide. For example:
./gen-k8s-env -resourceGroupName k8sGroup -location westeurope -registryName k8sregistry -orchestratorName k8s-cluster -dnsName k8s-dns
- A Docker development environment with
docker
anddocker-compose
.- Visit docker.com to download the tools and set up the environment. Docker's installation guide covers verifying your Docker installation.
- The Kubernetes command line client,
kubectl
.- This can be installed with the
az
tool as described in the Azure Container Service walkthrough.az
is also helpful for getting the credentialskubectl
needs to access your cluster. For other installation options, and information about configuringkubectl
yourself, see the Kubernetes documentation.
- This can be installed with the
Deploy the application with the deployment script
- Open a PowerShell command line at the
k8s
directory of your local eShopOnContainers repository. - Ensure
docker
,docker-compose
, andkubectl
are on the path, and configured for your Docker machine and Kubernetes cluster. - Run
deploy.ps1
with your registry information. The Docker username and password are provided by Azure Container Registry, and can be retrieved from the Azure portal. Optionally, ACR credentials can be obtained by running the following command:
az acr credential show -n eshopregistry
Once the user and password are retrieved, run the following script for deployment. For example:
./deploy.ps1 -registry myregistry.azurecr.io -dockerUser User -dockerPassword SecretPassword
The script will build the code and corresponding Docker images, push the latter to your registry, and deploy the application to your cluster. You can watch the deployment unfold from the Kubernetes web interface: run kubectl proxy
and open a browser to http://localhost:8001/ui