Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 96 additions & 7 deletions deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
- [JQ](https://stedolan.github.io/jq/download/)

> Note: in linux systems, it is possible to run the docker command without prefacing
> with sudo. For more information, please refer to [the Post-installation steps
> for linux](https://docs.docker.com/install/linux/linux-postinstall/)
> with sudo. For more information, please refer to [the Post-installation steps
> for linux](https://docs.docker.com/install/linux/linux-postinstall/)

Clone or download this repo locally.

Expand All @@ -27,6 +27,7 @@ The deployment steps shown here use Bash shell commands. On Windows, you can use
## Generate a SSH rsa public/private key pair

the SSH rsa key pair can be generated using ssh-keygen, among other tools, on Linux, Mac, or Windows. If you already have an ~/.ssh/id_rsa.pub file, you could provide the same later on. If you need to create an SSH key pair, see [How to create and use an SSH key pair](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys).

> Note: the SSH rsa public key will be requested when deploying your Kubernetes cluster in Azure.

## Azure Resources Provisioning
Expand Down Expand Up @@ -123,6 +124,7 @@ az group deployment create -g $RESOURCE_GROUP --name $DEV_DEPLOYMENT_NAME --temp
```

Get outputs from Azure Deploy

```bash
# Shared
export ACR_NAME=$(az group deployment show -g $RESOURCE_GROUP -n $DEV_DEPLOYMENT_NAME --query properties.outputs.acrName.value -o tsv) && \
Expand All @@ -131,6 +133,7 @@ export CLUSTER_NAME=$(az group deployment show -g $RESOURCE_GROUP -n $DEV_DEPLOY
```

Download kubectl and create a k8s namespace

```bash
# Install kubectl
sudo az aks install-cli
Expand Down Expand Up @@ -185,11 +188,11 @@ kubectl create -f https://raw.githubusercontent.com/Azure/kubernetes-keyvault-fl
## Deploy the ingress controller

> :warning: WARNING
>
> Do not use the certificates created by these scripts for production. The
> certificates are provided for demonstration purposes only.
> For your production cluster, use your
> security best practices for digital certificates creation and lifetime management.
>
> Do not use the certificates created by these scripts for production. The
> certificates are provided for demonstration purposes only.
> For your production cluster, use your
> security best practices for digital certificates creation and lifetime management.

```bash
# Deploy the ngnix ingress controller
Expand Down Expand Up @@ -476,6 +479,7 @@ docker push $ACR_SERVER/dronescheduler:0.1.0
```

Deploy the dronescheduler service:

```bash
# Deploy the service
helm install $HELM_CHARTS/dronescheduler/ \
Expand All @@ -500,6 +504,90 @@ helm install $HELM_CHARTS/dronescheduler/ \
helm status dronescheduler-v0.1.0-dev
```

## Getting a Bing Maps Key

In order for the Website to function it will need a Bing Maps API Key.

An API Key can be obtained from the here [How to Get a Bing Maps Key](https://docs.microsoft.com/en-us/bingmaps/getting-started/bing-maps-dev-center-help/getting-a-bing-maps-key).

The Bing Maps Key's 'Application URL' should be set to the the External Ingest URL. To get that URL run the command below.

```bash
echo $EXTERNAL_INGEST_FQDN
```

When creating a new Bing Maps key use following values.

- Application Name: Drone Demo Website
- Application URL: *$EXTERNAL_INGEST_FQDN value*
- Key type: Basic
- Application type: Website

Once the new key is created click on the 'Show key' option and then copy the key.

Run then command below and replace '<Bing Map API Key>' with the key you just created.

```bash
export $BING_MAP_API_KEY=<Bing Map API Key>
```

## Deploy Website service

Build the website service

```bash
export WEBSITE_PATH=$PROJECT_ROOT/src/shipping/website
```

Create and set up pod identity

```bash
# Extract outputs from deployment
export WEBSITE_PRINCIPAL_RESOURCE_ID=$(az group deployment show -g $RESOURCE_GROUP -n $IDENTITIES_DEPLOYMENT_NAME --query properties.outputs.deliveryPrincipalResourceId.value -o tsv) && \
export WEBSITE_PRINCIPAL_CLIENT_ID=$(az identity show -g $RESOURCE_GROUP -n $DELIVERY_ID_NAME --query clientId -o tsv)
export WEBSITE_INGRESS_TLS_SECRET_NAME=website-ingress-tls
```

Build and publish the container image

```bash
# Build the Docker image
docker build --pull --compress -t $ACR_SERVER/website:0.1.0 $WEBSITE_PATH/.

# Push the images to ACR
az acr login --name $ACR_NAME
docker push $ACR_SERVER/website:0.1.0
```

Deploy the website service:

```bash
# Deploy the service
helm install $HELM_CHARTS/website/ \
--set image.tag=0.1.0 \
--set image.repository=website \
--set dockerregistry=$ACR_SERVER \
--set ingress.hosts[0].name=$EXTERNAL_INGEST_FQDN \
--set ingress.hosts[0].serviceName=website \
--set ingress.hosts[0].tls=true \
--set ingress.hosts[0].tlsSecretName=$DELIVERY_INGRESS_TLS_SECRET_NAME \
--set ingress.tls.secrets[0].name=$DELIVERY_INGRESS_TLS_SECRET_NAME \
--set ingress.tls.secrets[0].key="$(cat ingestion-ingress-tls.key)" \
--set ingress.tls.secrets[0].certificate="$(cat ingestion-ingress-tls.crt)" \
--set identity.clientid=$WEBSITE_PRINCIPAL_CLIENT_ID \
--set identity.resourceid=$WEBSITE_PRINCIPAL_RESOURCE_ID \
--set bingmap.key=$BING_MAP_API_KEY \
--set api.url=$EXTERNAL_INGEST_FQDN \
--set reason="Initial deployment" \
--set tags.dev=true \
--namespace backend-dev \
--name website-v0.1.0-dev \
--dep-up

# Verify the pod is created
helm status website-v0.1.0-dev
```

## Validate the application is running

You can send delivery requests and check their statuses using curl.
Expand Down Expand Up @@ -527,6 +615,7 @@ curl -X POST "https://$EXTERNAL_INGEST_FQDN/api/deliveryrequests" --header 'Cont
```

### Check the request status

```bash
DELIVERY_ID=$(cat deliveryresponse.json | jq -r .deliveryId)
curl "https://$EXTERNAL_INGEST_FQDN/api/deliveries/$DELIVERY_ID" --header 'Accept: application/json' -k
Expand Down