Skip to content

Commit 92d297e

Browse files
committed
Updated Readme doc. Added markers to highlight shell script snippets.
1 parent a6f01c1 commit 92d297e

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ Follow the steps below to create the Bastion host (Linux VM), install pre-requis
7070
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).
7171

7272
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
7474
# Create the resource group
7575
$ az group create --name myResourceGroup --location eastus
7676
```
7777
**NOTE:** Keep in mind, if you specify a different name for the resource group (other than **myResourceGroup**), you will need to substitute the same value in 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.
7878
7979
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).
8080
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
8282
# Remember to specify the password for the 'labuser'.
8383
$ 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
8484
# 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
8787
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.
8888
8989
**NOTE:** Use of Cloud Shell to SSH into the VM is **NOT** recommended.
90-
```
90+
```bash
9191
# SSH into the VM. Substitute the public IP address for the Linux VM in the command below.
9292
$ ssh labuser@x.x.x.x
9393
#
9494
```
9595
9696
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
9898
# Install Azure CLI on this VM so that we can to deploy this application to the AKS cluster later in step [D].
9999
#
100100
# Import the Microsoft repository key.
@@ -177,7 +177,7 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
177177
```
178178
179179
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/).
180-
```
180+
```bash
181181
$ sudo yum update
182182
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
183183
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
@@ -189,12 +189,12 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
189189
190190
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.
191191
192-
```
192+
```bash
193193
$ docker info
194194
```
195195
196196
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
198198
$ docker pull microsoft/vsts-agent
199199
$ docker images
200200
```
@@ -216,7 +216,7 @@ Alternatively, if you prefer you can use SSH based authentication to connect to
216216
VSTS_TOKEN | VSTS PAT Token. This is the value which you copied and saved in a file in the previous step.
217217
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**).
218218

219-
```
219+
```bash
220220
$ docker run -e VSTS_ACCOUNT=<Org. Name> -e VSTS_TOKEN=<PAT Token> -v /var/run/docker.sock:/var/run/docker.sock --name vstsagent -it microsoft/vsts-agent
221221
```
222222
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
275275
![alt tag](./images/A-01.png)
276276
277277
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
279279
# Switch to home directory
280280
$ cd
281281
# 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
287287
288288
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.
289289
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
291291
# Enable execute permission for this script
292292
$ chmod 700 ./shell-scripts/jenkins-acr-auth.sh
293293
#
@@ -398,11 +398,11 @@ In case you want to modify the default values used for MySQL database name and/o
398398
399399
Follow the steps below to provision the AKS cluster and deploy the *po-service* microservice.
400400
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
406406
```
407407
408408
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*
412412
Alternatively, if you prefer CLI for deploying and managing resources on Azure and Kubernetes, continue with the next steps.
413413
414414
(If you haven't already) Open a terminal window and login to the Linux VM (Bastion host).
415-
```
415+
```bash
416416
#
417417
# Check if kubectl is installed OK
418418
$ kubectl version -o yaml
419419
```
420420

421421
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
423423
# Create a 1 Node AKS cluster
424424
$ 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"
425425
#
@@ -428,7 +428,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
428428
```
429429
430430
4. Connect to the AKS cluster and initialize **Helm** package manager.
431-
```
431+
```bash
432432
# Configure kubectl to connect to the AKS cluster
433433
$ az aks get-credentials --resource-group myResourceGroup --name akscluster
434434
#
@@ -449,7 +449,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
449449
```
450450
451451
5. Next, create a new Kubernetes **namespace** resource. This namespace will be called *development*.
452-
```
452+
```bash
453453
# Make sure you are in the *k8s-springboot-data-rest* directory.
454454
$ kubectl create -f k8s-scripts/dev-namespace.json
455455
#
@@ -458,7 +458,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
458458
```
459459
460460
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
462462
# Create the 'dev' context
463463
$ kubectl config set-context dev --cluster=akscluster --user=clusterUser_myResourceGroup_akscluster --namespace=development
464464
#
@@ -480,7 +480,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
480480

481481
Then execute this shell script. See below.
482482

483-
```
483+
```bash
484484
# Change file permission to allow user to execute the script
485485
$ chmod 700 ./shell-scripts/acr-auth.sh
486486
#
@@ -490,13 +490,13 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
490490
```
491491

492492
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
495495
```
496496
497497
It should appear similar to this
498498
499-
```
499+
```YAML
500500
apiVersion: v1
501501
clusters:
502502
- cluster:
@@ -530,7 +530,7 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
530530
![alt tag](./images/D-01.PNG)
531531
532532
9. Deploy the **MySQL** database container.
533-
```
533+
```bash
534534
# Make sure you are in the *k8s-springboot-data-rest* directory.
535535
$ kubectl create -f k8s-scripts/mysql-deploy.yaml
536536
#
@@ -542,12 +542,12 @@ Follow the steps below to provision the AKS cluster and deploy the *po-service*
542542
![alt tag](./images/D-02.png)
543543
544544
(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
546546
$ kubectl exec <pod ID> -i -t -- mysql -u mysql -p sampledb
547547
```
548548
549549
10. Deploy the **po-service** microservice container.
550-
```
550+
```bash
551551
# Make sure you are in the *k8s-springboot-data-rest* directory.
552552
$ kubectl create -f k8s-scripts/app-deploy.yaml
553553
#
@@ -704,7 +704,7 @@ Next, continue to explore other container solutions available on Azure. Use the
704704
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.
705705
706706
- 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
708708
# 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.
709709
$ echo "xxxx" | base64 -w 0
710710
# Then update the corresponding parameter value in the Secret object.
@@ -713,7 +713,7 @@ $ echo "xxxx" | base64 -w 0
713713
- 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**
714714
715715
- 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
717717
# Create Base64 encoded values for the MySQL server user name and password.
718718
$ echo "mysql.user=xxxx" | base64 -w 0
719719
$ echo "mysql.password=xxxx" | base64 -w 0
@@ -722,7 +722,7 @@ $ echo "mysql.password=xxxx" | base64 -w 0
722722
723723
### Troubleshooting
724724
- 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.
725-
```
725+
```bash
726726
#
727727
# Delete replication controllers - mysql, po-service
728728
$ kubectl delete rc mysql
@@ -742,7 +742,7 @@ $ kubectl delete configmap mysql-db-name
742742
```
743743
744744
- 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
746746
# Make sure you are in the 'dev' context
747747
$ kubectl config current-context
748748
#
@@ -757,7 +757,7 @@ $ kubectl delete namespace development
757757
```
758758
759759
- A few useful Kubernetes commands.
760-
```
760+
```bash
761761
# List all user contexts
762762
$ kubectl config view
763763
#

0 commit comments

Comments
 (0)