You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-32Lines changed: 32 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,15 +70,15 @@ Follow the steps below to create the Bastion host (Linux VM), install pre-requis
70
70
1. Login to the [Azure Portal](https://portal.azure.com) using your credentials and use a **Azure Cloud Shell** session to perform the next steps. Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources. The first time you access the Cloud Shell, you will be prompted to create a resource group, storage account and file share. You can use the defaults or click on *Advanced Settings* to customize the defaults. Accessing the Cloud Shell is described in [Overview of Azure Cloud Shell](https://docs.microsoft.com/en-us/azure/cloud-shell/overview).
71
71
72
72
2. An Azure resource group is a logical container into which Azure resources are deployed and managed. From the Cloud Shell, use Azure CLI to create a **Resource Group**. Azure CLI is already pre-installed and configured to use your Azure account (subscription) in the Cloud Shell. Alternatively, you can also use Azure Portal to create this resource group.
73
-
```
73
+
```bash
74
74
# Create the resource group
75
75
$ az group create --name myResourceGroup --location eastus
76
76
```
77
77
**NOTE:** Keep in mind, if you specify a different name forthe resource group (other than **myResourceGroup**), you will need to substitute the same valuein multiple CLI commands in the remainder of this project! If you are new to Azure or AKS, it's best to use the suggested name.
78
78
79
79
3. Use the command below to create a **CentOS 7.4** VM on Azure. Make sure you specify the correct **resource group** name and provide a value for the *password*. Once the command completes, it will print the VM connection info. in the JSON message (response). Note down the **Public IP address**, **Login name** and **Password** info. so that we can connect to this VM using SSH (secure shell).
80
80
Alternatively, if you prefer you can use SSH based authentication to connect to the Linux VM. The steps for creating and using an SSH key pair for Linux VMs in Azure is documented [here](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys). You can then specify the location of the public key with the `--ssh-key-path` option to the `az vm create ...` command.
81
-
```
81
+
```bash
82
82
# Remember to specify the password for the 'labuser'.
83
83
$ az vm create --resource-group myResourceGroup --name k8s-lab --image OpenLogic:CentOS:7.4:7.4.20180118 --size Standard_B2s --generate-ssh-keys --admin-username labuser --admin-password <password> --authentication-type password
84
84
# When the above command exits, it will print the public IP address, login name (labuser) and password. Make a note of these values.
@@ -87,14 +87,14 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
87
87
4. Login into the Linux VM via SSH. On a Windows PC, you can use a SSH client such as [Putty](https://putty.org/) or the [Windows Sub-System for Linux (Windows 10)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to login into the VM.
88
88
89
89
**NOTE:** Use of Cloud Shell to SSH into the VM is **NOT** recommended.
90
-
```
90
+
```bash
91
91
# SSH into the VM. Substitute the public IP address for the Linux VM in the command below.
92
92
$ ssh labuser@x.x.x.x
93
93
#
94
94
```
95
95
96
96
5. Install Azure CLI, Kubernetes CLI, Helm CLI, Service Catalog CLI, Git client, Open JDK, Jenkins and Maven on this VM. If you are a Linux power user and would like to save yourself some typing time, use this [shell script](./shell-scripts/setup-bastion.sh) to install all the pre-requisite CLI tools.
97
-
```
97
+
```bash
98
98
# Install Azure CLI on this VM so that we can to deploy this application to the AKS cluster later in step [D].
99
99
#
100
100
# Import the Microsoft repository key.
@@ -177,7 +177,7 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
177
177
```
178
178
179
179
6. Next, install **docker-ce** container runtime. Refer to the commands below. You can also refer to the [Docker CE install docs for CentOS](https://docs.docker.com/install/linux/docker-ce/centos/).
@@ -189,12 +189,12 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
189
189
190
190
LOGOUT AND RESTART YOUR LINUX VM BEFORE PROCEEDING. You can restart the VM via Azure Portal. Once the VM is back up, log back in to the Linux VM via SSH. Run the command below to verify **docker** engine is running.
191
191
192
-
```
192
+
```bash
193
193
$ docker info
194
194
```
195
195
196
196
7. Pull the Microsoft VSTS agent container from docker hub. It will take approx. 20 to 30 minutes to download the image (~ 10+ GB). Take a break and get some coffee!
197
-
```
197
+
```bash
198
198
$ docker pull microsoft/vsts-agent
199
199
$ docker images
200
200
```
@@ -216,7 +216,7 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
216
216
VSTS_TOKEN | VSTS PAT Token. This is the value which you copied and saved in a file in the previous step.
217
217
VSTS_ACCOUNT | VSTS Organization name. An Org. is a container for DevOps projects in Azure DevOps (VSTS) platform. It's usually the first part (Prefix) of the VSTS URL (eg., **Prefix**.visualstudio.com). If you are using Azure DevOps URL, then it is the last part (ContextPath) of the URL (eg., dev.azure.com/**ContextPath**).
The VSTS build agent will initialize and you should see a message indicating "Listening for Jobs". See below.
@@ -275,7 +275,7 @@ Before proceeding with the next steps, feel free to inspect the dockerfile and s
275
275

276
276
277
277
From the terminal window connected to the Bastion host (Linux VM), clone this repository. Ensure that you are using the URL of your fork when cloning this repository.
278
-
```
278
+
```bash
279
279
# Switch to home directory
280
280
$ cd
281
281
# Clone your GitHub repository. This will allow you to make changes to the application artifacts without affecting resources in the forked (original) GitHub project.
@@ -287,7 +287,7 @@ Before proceeding with the next steps, feel free to inspect the dockerfile and s
287
287
288
288
2. Create an Azure Service Principal (SP) and assign *Contributor* role access to the ACR created in Section [B]. This SP will be used in a subsequent lab (Jenkins-CI-CD) to push the *po-service* container image into ACR and re-deploy the microservice to AKS.
289
289
Execute the shell script `./shell-scripts/jenkins-acr-auth.sh` in the Linux VM (Bastion Host) terminal window. The command output will be displayed on the console and also saved to a file (SP_ACR.txt) in the current directory. Before running the shell script, open it in 'vi' editor (or 'nano') and specify the correct values for variables 'ACR_RESOURCE_GROUP' and 'ACR_NAME'.
290
-
```
290
+
```bash
291
291
# Enable execute permission for this script
292
292
$ chmod 700 ./shell-scripts/jenkins-acr-auth.sh
293
293
#
@@ -398,11 +398,11 @@ In case you want to modify the default values used for MySQL database name and/o
398
398
399
399
Follow the steps below to provision the AKS cluster and deploy the *po-service* microservice.
400
400
1. Ensure the *Resource provider* for AKS service is enabled (registered) for your subscription. A quick and easy way to verify this is, use the Azure portal and go to *->Azure Portal->Subscriptions->Your Subscription->Resource providers->Microsoft.ContainerService->(Ensure registered)*. Alternatively, you can use Azure CLI to register all required service providers. See below.
401
-
```
402
-
az provider register -n Microsoft.Network
403
-
az provider register -n Microsoft.Storage
404
-
az provider register -n Microsoft.Compute
405
-
az provider register -n Microsoft.ContainerService
401
+
```bash
402
+
$ az provider register -n Microsoft.Network
403
+
$ az provider register -n Microsoft.Storage
404
+
$ az provider register -n Microsoft.Compute
405
+
$ az provider register -n Microsoft.ContainerService
406
406
```
407
407
408
408
2. At this point, you can use a) The Azure Portal Web UI to create an AKS cluster and b) The Kubernetes Dashboard UI to deploy the Springboot Microservice application artifacts. To use a web browser (*Web UI*) for deploying the AKS cluster and application artifacts, refer to the steps in [extensions/k8s-dash-deploy](./extensions/k8s-dash-deploy).
@@ -412,14 +412,14 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
412
412
Alternatively, if you prefer CLI for deploying and managing resources on Azure and Kubernetes, continue with the next steps.
413
413
414
414
(If you haven't already) Open a terminal window and login to the Linux VM (Bastion host).
415
-
```
415
+
```bash
416
416
#
417
417
# Check if kubectl is installed OK
418
418
$ kubectl version -o yaml
419
419
```
420
420
421
421
3. Refer to the commands below to create an AKS cluster. If you haven't already created a **resource group**, you will need to create one first. If needed, go back to step [A] and review the steps for the same. Cluster creation will take a few minutes to complete.
422
-
```
422
+
```bash
423
423
# Create a 1 Node AKS cluster
424
424
$ az aks create --resource-group myResourceGroup --name akscluster --node-count 1 --dns-name-prefix akslab --generate-ssh-keys --disable-rbac --kubernetes-version "1.11.5"
425
425
#
@@ -428,7 +428,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
428
428
```
429
429
430
430
4. Connect to the AKS cluster and initialize **Helm** package manager.
431
-
```
431
+
```bash
432
432
# Configure kubectl to connect to the AKS cluster
433
433
$ az aks get-credentials --resource-group myResourceGroup --name akscluster
434
434
#
@@ -449,7 +449,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
449
449
```
450
450
451
451
5. Next, create a new Kubernetes **namespace** resource. This namespace will be called *development*.
452
-
```
452
+
```bash
453
453
# Make sure you are in the *k8s-springboot-data-rest* directory.
@@ -458,7 +458,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
458
458
```
459
459
460
460
6. Create a new Kubernetes context and associate it with the **development** namespace. We will be deploying all our application artifacts into this namespace in subsequent steps.
461
-
```
461
+
```bash
462
462
# Create the 'dev' context
463
463
$ kubectl config set-context dev --cluster=akscluster --user=clusterUser_myResourceGroup_akscluster --namespace=development
464
464
#
@@ -480,7 +480,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
480
480
481
481
Then execute this shell script. See below.
482
482
483
-
```
483
+
```bash
484
484
# Change file permission to allow user to execute the script
485
485
$ chmod 700 ./shell-scripts/acr-auth.sh
486
486
#
@@ -490,13 +490,13 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
490
490
```
491
491
492
492
At this point you will also want to save your Kube Configuation file to a known temporary location. You will need this to properly setup your Kubernetes cluster in a subsequent lab. To do this, in your Terminal, `cat` the kube config file and cut and paste it's contents into another file. Save this config file to a directory location on you local workstation/PC.
493
-
```
494
-
cat ~/.kube/config
493
+
```bash
494
+
$ cat ~/.kube/config
495
495
```
496
496
497
497
It should appear similar to this
498
498
499
-
```
499
+
```YAML
500
500
apiVersion: v1
501
501
clusters:
502
502
- cluster:
@@ -530,7 +530,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
530
530

531
531
532
532
9. Deploy the **MySQL** database container.
533
-
```
533
+
```bash
534
534
# Make sure you are in the *k8s-springboot-data-rest* directory.
535
535
$ kubectl create -f k8s-scripts/mysql-deploy.yaml
536
536
#
@@ -542,12 +542,12 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
542
542

543
543
544
544
(Optional) You can login to the mysql container using the command below. Specify the correct value for the pod ID (Value under 'Name' column listed in the previous command output). The password for the 'mysql' user is 'password'.
545
-
```
545
+
```bash
546
546
$ kubectl exec <pod ID> -i -t -- mysql -u mysql -p sampledb
547
547
```
548
548
549
549
10. Deploy the **po-service** microservice container.
550
-
```
550
+
```bash
551
551
# Make sure you are in the *k8s-springboot-data-rest* directory.
552
552
$ kubectl create -f k8s-scripts/app-deploy.yaml
553
553
#
@@ -704,7 +704,7 @@ Next, continue to explore other container solutions available on Azure. Use the
704
704
In case you want to change the name of the *MySQL* database name, root password, password or username, you will need to make the following changes. See below.
705
705
706
706
- Update the *Secret* object **mysql** in file *./k8s-scripts/mysql-deploy.yaml* file with appropriate values (replace 'xxxx' with actual values) by issuing the commands below.
707
-
```
707
+
```bash
708
708
# Create Base64 encoded values for the MySQL server user name, password, root password and database name. Repeat this command to generate values for each property you want to change.
709
709
$ echo "xxxx" | base64 -w 0
710
710
# Then update the corresponding parameter value in the Secret object.
@@ -713,7 +713,7 @@ $ echo "xxxx" | base64 -w 0
713
713
- Update the *./k8s-scripts/app-deploy.yaml* file. Specify the correct value for the database name in the *ConfigMap* object **mysql-db-name** parameter **mysql.dbname**
714
714
715
715
- Update the *Secret* object **mysql-sql** in file *./k8s-scripts/app-deploy.yaml* file with appropriate values (replace 'xxxx' with actual values) by issuing the commands below.
716
-
```
716
+
```bash
717
717
# Create Base64 encoded values for the MySQL server user name and password.
- In case you created the **po-service** application artifacts in the wrong Kubernetes namespace (other than `development`), use the commands below to clean all API objects from the current namespace. Then follow instructions in Section D starting Step 6 to create the API objects in the 'development' namespace.
- In case you want to delete all API objects in the 'development' namespace and start over again, delete the 'development' namespace. Also, delete the 'dev' context. Then start from Section D Step 5 to create the 'development' namespace, create the API objects and deploy the microservices.
745
-
```
745
+
```bash
746
746
# Make sure you are in the 'dev' context
747
747
$ kubectl config current-context
748
748
#
@@ -757,7 +757,7 @@ $ kubectl delete namespace development
0 commit comments