Skip to content

Commit

Permalink
Adding code
Browse files Browse the repository at this point in the history
  • Loading branch information
JBalzano authored Oct 19, 2021
1 parent 64e75e3 commit 31a00f6
Show file tree
Hide file tree
Showing 100 changed files with 362 additions and 0 deletions.
Binary file added 9781484271919.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions CH01/Listing0101-Running your first Docker Container.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run hello-world
26 changes: 26 additions & 0 deletions CH01/Listing0102-Output of your first Docker Container.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
az login
1 change: 1 addition & 0 deletions CH01/Listing0104-Set Azure CLI’s active subscription.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
az account set -s <YourSubscription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Modify these variables as needed
$Region="EastUS"
$RG="KubernetesLabs"
$Username="labuser"
$PW="Str@ngPassw0rd"
$dnsPrefix="k8slab"
$VMSize="Standard_B2s"
$Linux_Image="Canonical:UbuntuServer:18.04-LTS:latest"
$Windows_Image="Win2016datacenter"

#Define machines
$machines = ConvertFrom-Csv @'
Hostname,IP,OS
storage,172.16.94.5,Linux
control,172.16.94.10,Linux
node1,172.16.94.11,Linux
node2,172.16.94.12,Linux
node3,172.16.94.13,Linux
workstation,172.16.94.100,Windows
'@

# Create RG
az group create -l $Region -n $RG

# Create VNET and NSG
az network vnet create --name LABVnet --resource-group $RG --address-prefixes 172.16.94.0/24

az network vnet subnet create --name LabSubnet --address-prefixes 172.16.94.0/24 `
--resource-group $RG --vnet-name LABVnet

az network nsg create --name LABNSG --resource-group $RG

az network nsg rule create --name SSH --nsg-name LABNSG --priority 1000 `
--resource-group $RG --destination-port-ranges 22 --access "Allow" `
--protocol TCP --direction Inbound

az network nsg rule create --name RDP --nsg-name LABNSG --priority 1001 `
--resource-group $RG --destination-port-ranges 3389 --access "Allow" `
--protocol TCP --direction Inbound

#Create VMs
foreach($vm in $machines) {
$hostname=$vm.Hostname
$DNSName="$dnsPrefix-$hostname"
$image=$Windows_Image
if ($vm.OS -eq "Linux") { $image=$Linux_Image }
az network public-ip create --name PIP-$hostname --resource-group $RG --dns-name $DNSName

az network nic create --name NIC-$hostname --resource-group $RG --subnet LabSubnet `
--vnet-name LABVnet --private-ip-address $vm.IP --public-ip-address PIP-$hostname

az vm create --name $hostname --resource-group $RG --nics NIC-$hostname --os-disk-size-gb 150 `
--os-disk-name Disk-$hostname --image $image --authentication-type password `
--admin-username $Username --admin-password $PW --size $VMSize
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
172.16.94.5 storage
172.16.94.10 control
172.16.94.11 node1
172.16.94.12 node2
172.16.94.13 node3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
echo 172.16.94.5 storage > tmphosts
echo 172.16.94.10 control >> tmphosts
echo 172.16.94.11 node1 >> tmphosts
echo 172.16.94.12 node2 >> tmphosts
echo 172.16.94.13 node3 >> tmphosts
sudo -- sh -c "cat tmphosts >> /etc/hosts"
8 changes: 8 additions & 0 deletions CH01/Listing0108-apt script for basic prerequisites.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sudo apt-get update
sudo apt-get install gnupg ca-certificates curl wget software-properties-common apt-transport-https lsb-release -y
curl -sL https://packages.microsoft.com/keys/microsoft.asc |
gpg --dearmor |
sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/prod.list)"
sudo apt-get update
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sudo apt-get install -y azdata-cli
sudo apt-get install -y azure-cli
sudo apt-get install -y kubectl
sudo apt-get install -y mssql-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
4 changes: 4 additions & 0 deletions CH01/Listing0111-Install script for recommended tools.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
choco install curl -y
choco install grep -y
choco install putty -y
choco install googlechrome -y
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
choco install kubernetes-cli -y
choco install sqlserver-cmdlineutils -y
choco install azure-cli -y
2 changes: 2 additions & 0 deletions CH01/Listing0113-Install script for azdata.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
curl -o azdata.msi https://aka.ms/azdata-msi
msiexec /i azdata.msi /passive
24 changes: 24 additions & 0 deletions CH01/Listing0114-enable-nfs.sh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
apt install -y nfs-kernel-server
groupadd mssql -g 10001
useradd -u 10001 mssql -g mssql
addgroup --gid 472 grafana
useradd -g 472 -u 472 grafana

mkdir -p /srv/exports/volumes/
chown -R mssql:mssql /srv/exports/volumes/
echo '/srv/exports 172.16.94.0/24(rw,sync,no_subtree_check,no_root_squash)' > exports
chmod 644 exports
mv exports /etc/exports
exportfs -a
systemctl restart nfs-kernel-server

mkdir /srv/exports/volumes/sql-instance-1
chown -R mssql:mssql /srv/exports/volumes/

mkdir /srv/exports/volumes/influxdb
mkdir /srv/exports/volumes/grafana
chown 472:472 /srv/exports/volumes/grafana

mkdir /srv/exports/volumes/webcontent
echo "Hello World!!!" > /srv/exports/volumes/webcontent/index.html
2 changes: 2 additions & 0 deletions CH01/Listing0115-Run enable-nfs.sh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chmod +x enable-nfs.sh
sudo ./enable-nfs.sh
1 change: 1 addition & 0 deletions CH01/Listing0116-nstall NFS utilities on NFS clients.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo apt install -y nfs-common
2 changes: 2 additions & 0 deletions CH01/Listing0117-Verify NFS Connectivity on NFS clients.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo mount -t nfs storage:/srv/exports /mnt
ls -al /mnt/volumes
1 change: 1 addition & 0 deletions CH01/Listing0118-Disable swap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
swapoff -a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker pull mcr.microsoft.com/mssql/server:2019-latest
1 change: 1 addition & 0 deletions CH02/Listing0202-Command on Bash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -sL https://mcr.microsoft.com/v2/mssql/server/tags/list
1 change: 1 addition & 0 deletions CH02/Listing0203-Command on Windows.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(Invoke-WebRequest https://mcr.microsoft.com/v2/mssql/server/tags/list).Content
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker pull mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-18.04
1 change: 1 addition & 0 deletions CH02/Listing0205-docker image ls command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker image ls
7 changes: 7 additions & 0 deletions CH02/Listing0206-docker run command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker run \
--env 'ACCEPT_EULA=Y' \
--env 'MSSQL_SA_PASSWORD=S0methingS@Str0ng!' \
--name 'sql1' \
--publish 1433:1433 \
--detach \
mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-18.04
1 change: 1 addition & 0 deletions CH02/Listing0207-docker ps command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker ps
1 change: 1 addition & 0 deletions CH02/Listing0208-docker logs command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker logs sql1 | more
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlcmd -S localhost,1433 -U sa -Q 'SELECT @@VERSION' -P 'S0methingS@Str0ng!'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docker run \
--name 'sql2' \
-e 'ACCEPT_EULA=Y' \
-e 'MSSQL_SA_PASSWORD=S0methingS@Str0ng!' \
-p 1434:1433 \
-d mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-18.04
4 changes: 4 additions & 0 deletions CH02/Listing0211-restore_testdb1.sql.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
USE [master]
RESTORE DATABASE [TestDB1]
FROM DISK = N'/var/opt/mssql/data/TestDB1.bak'
WITH REPLACE
1 change: 1 addition & 0 deletions CH02/Listing0212-docker cp command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker cp TestDB1.bak sql2:/var/opt/mssql/data
1 change: 1 addition & 0 deletions CH02/Listing0213-chown command inside the container.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker exec -u root sql2 chown mssql /var/opt/mssql/data/TestDB1.bak
1 change: 1 addition & 0 deletions CH02/Listing0214-Execute restore script through sqlcmd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlcmd -S localhost,1434 -U sa -i restore_testdb1.sql -P 'S0methingS@Str0ng!'
1 change: 1 addition & 0 deletions CH02/Listing0215-docker exec command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker exec -it sql2 /bin/bash
1 change: 1 addition & 0 deletions CH02/Listing0216-pa -aux command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ps -aux
1 change: 1 addition & 0 deletions CH02/Listing0217-Directory listing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ls -la /var/opt/mssql/data
1 change: 1 addition & 0 deletions CH02/Listing0218-docker stop command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker stop sql2
1 change: 1 addition & 0 deletions CH02/Listing0219-docker ps -a command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker ps -a
1 change: 1 addition & 0 deletions CH02/Listing0220-docker start command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker start sql2
1 change: 1 addition & 0 deletions CH02/Listing0221-List databases using sqlcmd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlcmd -S localhost,1434 -U sa -Q 'SELECT name from sys.databases' -P 'S0methingS@Str0ng!'
2 changes: 2 additions & 0 deletions CH02/Listing0222-docker stop command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker stop sql1
docker stop sql2
2 changes: 2 additions & 0 deletions CH02/Listing0223-docker rm command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker rm sql1
docker rm sql2
1 change: 1 addition & 0 deletions CH02/Listing0224-docker image ls command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker image ls
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker run \
--name 'sql1' \
-e 'ACCEPT_EULA=Y' \
-e 'MSSQL_SA_PASSWORD=S0methingS@Str0ng!' \
-p 1433:1433 \
-v sqldata1:/var/opt/mssql \
-d mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-18.04
3 changes: 3 additions & 0 deletions CH02/Listing0226-docker cp command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker cp TestDB1.bak sql1:/var/opt/mssql/data
docker exec -u root sql1 chown mssql /var/opt/mssql/data/ TestDB1.bak
sqlcmd -S localhost,1433 -U sa -i restore_testdb1.sql -P 'S0methingS@Str0ng!'
1 change: 1 addition & 0 deletions CH02/Listing0227-List all databases through sqlcmd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlcmd -S localhost,1433 -U sa -Q 'SELECT name from sys.databases' -P 'S0methingS@Str0ng!'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlcmd -S localhost,1433 -U sa -Q 'SELECT name, physical_name from sys.master_files' -P 'S0methingS@Str0ng!' -W
2 changes: 2 additions & 0 deletions CH02/Listing0229-stop and remove the container sql1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker stop sql1
docker rm sql1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker run \
--name 'sql2' \
-e 'ACCEPT_EULA=Y' \
-e 'MSSQL_SA_PASSWORD=S0methingS@Str0ng!' \
-p 1433:1433 \
-v sqldata1:/var/opt/mssql \
-d mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-18.04
1 change: 1 addition & 0 deletions CH02/Listing0231-List all databases through sqlcmd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlcmd -S localhost,1433 -U sa -Q 'SELECT name from sys.databases' -P 'S0methingS@Str0ng!'
1 change: 1 addition & 0 deletions CH02/Listing0232-docker volume ls command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker volume ls
1 change: 1 addition & 0 deletions CH02/Listing0233-docker inspect command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker volume inspect sqldata1
1 change: 1 addition & 0 deletions CH02/Listing0234-docker stop command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker stop sql1
1 change: 1 addition & 0 deletions CH02/Listing0235-docker rm command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker rm sql1
1 change: 1 addition & 0 deletions CH02/Listing0236-docker Volume rm command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker volume rm sqldata1
3 changes: 3 additions & 0 deletions CH04/Listing0401-Install single node cluster.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wget -q -O deploy_kubeadm.sh https://bookmark.ws/ArcDemo_Linux
chmod +x deploy_kubeadm.sh
./deploy_kubeadm.sh
2 changes: 2 additions & 0 deletions CH04/Listing0402-Install modprobe and br_netfilter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo modprobe overlay
sudo modprobe br_netfilter
4 changes: 4 additions & 0 deletions CH04/Listing0403-Persist modprobe and br_netfilter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
5 changes: 5 additions & 0 deletions CH04/Listing0404-Persist system parameters for containerd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
1 change: 1 addition & 0 deletions CH04/Listing0405-Apply sysctl changes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo sysctl --system
2 changes: 2 additions & 0 deletions CH04/Listing0406-Install containerd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo apt-get update
sudo apt-get install -y containerd
2 changes: 2 additions & 0 deletions CH04/Listing0407-Create containerd config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml
1 change: 1 addition & 0 deletions CH04/Listing0408-Edit containerd config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo vi /etc/containerd/config.toml
1 change: 1 addition & 0 deletions CH04/Listing0409-Section in containerd config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
2 changes: 2 additions & 0 deletions CH04/Listing0410-Lines to be added to containerd config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
1 change: 1 addition & 0 deletions CH04/Listing0411-Restart containerd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo systemctl restart containerd
1 change: 1 addition & 0 deletions CH04/Listing0412-Status of containerd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo systemctl status containerd
1 change: 1 addition & 0 deletions CH04/Listing0413-Add Google gpg key.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
3 changes: 3 additions & 0 deletions CH04/Listing0414-Add Kubernetes apt repository.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sudo bash -c 'cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF'
2 changes: 2 additions & 0 deletions CH04/Listing0415-Update apt package list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo apt-get update
apt-cache policy kubelet | head -n 20
1 change: 1 addition & 0 deletions CH04/Listing0416-Install Kubernetes packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo apt-get install -y kubelet kubeadm kubectl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VERSION=1.20.1-00
sudo apt-get install -y kubelet=$VERSION kubeadm=$VERSION kubectl=$VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo apt-mark hold kubelet kubeadm kubectl containerd
2 changes: 2 additions & 0 deletions CH04/Listing0419-Check status of kubelet and containerd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo systemctl status kubelet.service
sudo systemctl status containerd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo systemctl enable kubelet.service
sudo systemctl enable containerd.service
1 change: 1 addition & 0 deletions CH04/Listing0421-Create kubeadm configuration file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kubeadm config print init-defaults | tee ClusterConfiguration.yaml
10 changes: 10 additions & 0 deletions CH04/Listing0422-Modify kubeadm config file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sed -i 's/ advertiseAddress: 1.2.3.4/ advertiseAddress: 172.16.94.10/' ClusterConfiguration.yaml

sed -i 's/ criSocket: \/var\/run\/dockershim\.sock/ criSocket: \/run\/containerd\/containerd\.sock/' ClusterConfiguration.yaml

cat <<EOF | cat >> ClusterConfiguration.yaml
---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cgroupDriver: systemd
EOF
1 change: 1 addition & 0 deletions CH04/Listing0423-Get current kubeadm version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kubeadm version
Loading

0 comments on commit 31a00f6

Please sign in to comment.