Azure Kubernetes Service (AKS)¶
This tutorial demonstrates how to deploy the Open AMT Cloud Toolkit on a Kubernetes cluster using AKS. Alternatively, you can also perform a simpler, test deployment using a single-node cluster locally. See Kubernetes (K8s).
Azure Kubernetes Service (AKS) offers serverless Kubernetes, an integrated continuous integration and continuous delivery (CI/CD) experience, and enterprise-grade security and governance. Learn more about AKS here.
Prerequisites¶
Get the Toolkit¶
-
Clone the Open AMT Cloud Toolkit.
git clone https://github.com/open-amt-cloud-toolkit/open-amt-cloud-toolkit --branch v2.3.4
Create SSH Key¶
This key is required by Azure to create VMs that use SSH keys for authentication. For more details, see Detailed steps: Create and manage SSH keys.
-
Create a new ssh key.
ssh-keygen -m PEM -t rsa -b 4096
-
Take note of the location it was saved at. You will need the public key (
.pub
file) in a following step.
Deploy AKS¶
-
Login to Azure.
az login
-
Provide a name and region to create a new resource group.
az group create --name <your-resource-group-name> --location <region>
-
Provide the name of your new resource group from the last step and start a deployment at that resource group based on
aks.json
in the./open-amt-cloud-toolkit
directory.az deployment group create --resource-group <your-resource-group-name> --template-file aks.json
-
After running the previous command, you will be prompted for 3 different strings. After the final prompt, it will take about 5 minutes to finish running.
- Provide a name for the AKS Cluster.
- Provide a name (e.g. your name) for the linux user admin name.
- Provide the string of the ssh key from the
.pub
file.
-
Take note of the
fqdnSuffix
in theoutputs
section of the JSON response (e.g.eastus.cloudapp.azure.com
)"outputs": { "controlPlaneFQDN": { "type": "String", "value": "bwcluster-9c68035a.hcp.westus.azmk8s.io" }, "fqdnSuffix": { "type": "String", "value": "eastus.cloudapp.azure.com" } },
Connect to AKS Instance¶
Ensure your kubectl
is connected to the Kubernetes cluster you wish to deploy/manage.
-
Provide your resource group name and cluster name, respectively.
az aks get-credentials --resource-group <your-resource-group-name> --name <your-cluster-name>
Create Secrets¶
1. MPS/KONG JWT¶
This is the secret used for generating and verifying JWTs.
kubectl create secret generic open-amt-admin-jwt --from-literal=kongCredType=jwt --from-literal=key="admin-issuer" --from-literal=algorithm=HS256 --from-literal=secret="<your-secret>"
Where:
- <your-secret> is your chosen strong secret.
2. KONG ACL for JWT¶
This configures KONG with an Access Control List (ACL) to allow an admin user open-amt-admin
to access endpoints using the JWT retrieved when logging in.
kubectl create secret generic open-amt-admin-acl --from-literal=kongCredType=acl --from-literal=group=open-amt-admin
3. MPS Web Username and Password¶
This is the username and password that is used for requesting a JWT. These credentials are also used for logging into the Sample Web UI.
kubectl create secret generic mpsweb --from-literal=user=<your-username> --from-literal=password=<your-password>
Where:
- <your-username> is a username of your choice.
-
<your-password> is a strong password of your choice.
Important - Using Strong Passwords
The password must meet standard, strong password requirements:
- 8 to 32 characters
- One uppercase, one lowercase, one numerical digit, one special character
4. Database connection strings¶
-
Configure the database connection strings used by MPS, RPS, and MPS Router.
Where:
- <USERNAME> is the full username for the Postgres database (Ex:
<postgres-username>@<your-cluster-name>-sql
). - <PASSWORD> is the password for the Postgres database.
- <SERVERURL> is the url for the Azure-hosted Postgres database (Ex:
<your-cluster-name>-sql.postgres.database.azure.com
).
- <USERNAME> is the full username for the Postgres database (Ex:
-
Create RPS connection string secret.
kubectl create secret generic rps --from-literal=connectionString=postgresql://<USERNAME>:<PASSWORD>@<SERVERURL>:5432/rpsdb?sslmode=require
-
Create MPS Router connection string secret.
kubectl create secret generic mpsrouter --from-literal=connectionString=postgresql://<USERNAME>:<PASSWORD>@<SERVERURL>:5432/mpsdb?sslmode=require
-
Create MPS connection string secret.
kubectl create secret generic mps --from-literal=connectionString=postgresql://<USERNAME>:<PASSWORD>@<SERVERURL>:5432/mpsdb?sslmode=require
Update Configuration¶
Edit values.yaml¶
-
Open the
values.yaml
file in./open-amt-cloud-toolkit/kubernetes/charts/
. -
Update the
service.beta.kubernetes.io/azure-dns-label-name
key in the kong section with a desired subdomain name for the URL that you would like for your cluster (i.e. myopenamtk8s).kong: proxy: annotations: service.beta.kubernetes.io/azure-dns-label-name: "<your-subdomain-name>"
-
Update the
commonName
key to your FQDN in themps
section. For AKS, the format is<your-subdomain-name>.<location>.cloudapp.azure.com
. This is thefqdnSuffix
provided in theoutputs
section when you Deploy AKS.mps: commonName: "<your-subdomain-name>.<location>.cloudapp.azure.com" replicaCount: 1 logLevel: "silly" jwtExpiration: 1440
-
Save and close the file.
Create Databases and Schema¶
Enable Access to Database¶
-
Navigate to
Home > Resource Groups > Resource Group Name
using Microsoft Azure via online. -
Select the Postgres DB. It will have a Type of
Azure Database for PostgreSQL Server
. -
Under Settings in the left-hand menu, select Connection Security.
-
Under Firewall rules, select Add current client IP address.
-
Select Save.
-
Under the Overview tab, take note of the 'Server name' and 'Admin username'. They will be needed in the next steps.
Note
Remember to delete this firewall rule when finished.
Create Databases¶
-
Use the database schema files to initialize the hosted Postgres DB in the following steps.
Where:
- <SERVERURL> is the location of the Postgres database (Ex:
<your-cluster-name>-sql.postgres.database.azure.com
). - <USERNAME> is the admin username for the Postgres database (Ex:
<postgres-username>@<your-cluster-name>-sql
).
- <SERVERURL> is the location of the Postgres database (Ex:
-
Create the RPS database.
psql -h <SERVERURL> -p 5432 -d postgres -U <USERNAME> -W -c "CREATE DATABASE rpsdb"
-
Create tables for the new 'rpsdb' database.
psql -h <SERVERURL> -p 5432 -d rpsdb -U <USERNAME> -W -f ./data/init.sql
-
Create the MPS database.
psql -h <SERVERURL> -p 5432 -d postgres -U <USERNAME> -W -f ./data/initMPS.sql
Deploy Open AMT Cloud Toolkit using Helm¶
-
Deploy using Helm.
helm install openamtstack ./kubernetes/charts
Success
NAME: openamtstack LAST DEPLOYED: Thu Jul 15 11:17:38 2021 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None
-
View the pods. You might notice
mps
,rps
, andopenamtstack-vault-0
are not ready. This will change after we initialize and unseal Vault. All others should be Ready and Running.kubectl get pods
Success
NAME READY STATUS RESTARTS AGE mps-69786bfb47-92mpc 0/1 CreateContainerConfigError 0 2m6s mpsrouter-9b9bc499b-2tkb2 1/1 Running 0 2m6s openamtstack-kong-68d6c84bcc-fp8dl 2/2 Running 0 2m6s openamtstack-vault-0 0/1 Running 0 2m6s openamtstack-vault-agent-injector-6b564845db-zss78 1/1 Running 0 2m6s rps-79877bf5c5-dsg5p 0/1 CreateContainerConfigError 0 2m6s webui-6cc48f4d68-6r8b5 1/1 Running 0 2m6s
Initialize and Unseal Vault¶
Danger - Download and Save Vault Keys
Make sure to download your Vault credentials and save them in a secure location when unsealing Vault. If the keys are lost, a new Vault will need to be started and any stored data will be lost.
Tip - Finding the Vault UI External IP Address
The external IP of your Vault UI service can be found by running:
kubectl get services openamtstack-vault-ui
-
Please refer to HashiCorp documentation on how to Initialize and unseal Vault. Stop and return here after signing in to Vault with the
root_token
. -
After initializing and unsealing the vault, you need to enable the Key Value engine.
-
Click Enable New Engine +.
-
Choose KV.
-
Click Next.
-
Leave the default path and choose version 2 from the drop down.
-
Click Enable Engine.
Vault Token Secret¶
-
Add the root token as a secret to the AKS cluster so that the services can access Vault.
kubectl create secret generic vault --from-literal=vaultKey=<your-root-token>
Where:
- <your-root-token> is your
root_token
generated by Vault.
- <your-root-token> is your
-
View the pods. All pods should now be Ready and Running.
kubectl get pods
Success
NAME READY STATUS RESTARTS AGE mps-69786bfb47-92mpc 1/1 Running 0 4m5s mpsrouter-9b9bc499b-2tkb2 1/1 Running 0 4m5s openamtstack-kong-68d6c84bcc-fp8dl 2/2 Running 0 4m5s openamtstack-vault-0 1/1 Running 0 4m5s openamtstack-vault-agent-injector-6b564845db-zss78 1/1 Running 0 4m5s rps-79877bf5c5-dsg5p 1/1 Running 0 4m5s webui-6cc48f4d68-6r8b5 1/1 Running 0 4m5s
Next Steps¶
Visit the Sample Web UI using the FQDN name and Continue from the Get Started steps