├── README.md ├── bottlerocket-cluster.yaml ├── Bottlerocket.ps1 ├── Getting Started with Microsoft AKS AzureCLI.azcli ├── Getting Started with EKS.ps1 ├── Getting Started with GKE.ps1 ├── Getting Started with Microsoft AKS AzPowershell.ps1 └── AzureCSI.azcli /README.md: -------------------------------------------------------------------------------- 1 | # LearnKubernetes 2 | Repository for storing code walkthroughs. 3 | -------------------------------------------------------------------------------- /bottlerocket-cluster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eksctl.io/v1alpha5 2 | kind: ClusterConfig 3 | 4 | metadata: 5 | name: bottlerocket 6 | region: eu-west-2 7 | version: '1.19' 8 | 9 | nodeGroups: 10 | - name: ng-bottlerocket 11 | instanceType: m5.large 12 | desiredCapacity: 3 13 | amiFamily: Bottlerocket 14 | iam: 15 | attachPolicyARNs: 16 | - arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy 17 | - arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy 18 | - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly 19 | - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore 20 | ssh: 21 | allow: true 22 | publicKeyName: bottlerocket 23 | bottlerocket: 24 | settings: 25 | motd: "Hello from eksctl!" -------------------------------------------------------------------------------- /Bottlerocket.ps1: -------------------------------------------------------------------------------- 1 | #Create a keypair 2 | aws ec2 create-key-pair --key-name bottlerocket --query "bottlerocket" --output text > bottlerocket.pem 3 | 4 | #Create EKS Cluster based on yaml configuration (16 mins) 5 | eksctl create cluster --config-file "D:\Personal OneDrive\OneDrive\Veeam Live Documentation\Blog\AWS EKS Setup\bottlerocket-cluster.yaml" 6 | 7 | #Confirm you have access to your new EKS Cluster 8 | kubectl get nodes 9 | 10 | #The above doesnt show your OS image used so run the following to confirm Bottlerocket is being used. 11 | kubectl get nodes -o=wide 12 | 13 | #Delete the cluster 14 | eksctl delete cluster --config-file "D:\Personal OneDrive\OneDrive\Veeam Live Documentation\Blog\AWS EKS Setup\bottlerocket-cluster.yaml" 15 | aws ec2 delete-key-pair --key-name bottlerocket 16 | 17 | #Resources 18 | #bottlerocket - https://docs.aws.amazon.com/eks/latest/userguide/launch-node-bottlerocket.html -------------------------------------------------------------------------------- /Getting Started with Microsoft AKS AzureCLI.azcli: -------------------------------------------------------------------------------- 1 | #Web Browser will open to authenticate against your subscription 2 | az login 3 | 4 | #Create a New resource group 5 | az group create --name AKSResourceGroup --location eastus 6 | 7 | #Creating The AKS Cluster 8 | #If you would like to generate new SSH Keys 9 | az aks create --resource-group AKSResourceGroup --name myAKSCluster --node-count 3 --generate-ssh-keys 10 | 11 | #If you would like to use existing SSH keys 12 | az aks create --resource-group AKSResourceGroup --name MyAKSCluster --node-count 3 --ssh-key-value C:\\Users\micha\\.ssh\\id_rsa 13 | 14 | #Merge AKS Cluster with current Kubectl Configuration 15 | az aks get-credentials --resource-group AKSResourceGroup --name myAKSCluster 16 | 17 | #Confirm kubectl has new config 18 | kubectl config get-contexts 19 | 20 | #Confirm your nodes are all up and running 21 | kubectl get nodes 22 | 23 | #Delete the Cluster 24 | az group delete --name AKSResourceGroup --yes --no-wait 25 | -------------------------------------------------------------------------------- /Getting Started with EKS.ps1: -------------------------------------------------------------------------------- 1 | #Using the AWS CLI to deploy an Amazon EKS cluster 2 | 3 | #Install EKSCTL on Windows with Chocolatey 4 | choco install -y eksctl 5 | 6 | #Start by configuring your AWS CLI to work with the correct IAM and region 7 | aws configure 8 | 9 | #Create an Amazon EKS Cluster with specified name, region, nodegroup and node type 10 | eksctl create cluster --name mc-eks --region eu-west-2 --nodegroup-name standard --node-type t3.small --managed 11 | 12 | #Create an Amazon EKS Cluster with specified name, region, nodegroup and using existing SSH public key 13 | eksctl create cluster --name mc-eks --region eu-west-2 --nodegroup-name standard --managed --ssh-access --ssh-public-key=MCEKS1 --nodes 3 --nodes-min 1 --nodes-max 4 14 | 15 | #SSH connection to your nodes (change to your public DNS) 16 | ssh ec2-user@ec2-18-130-232-27.eu-west-2.compute.amazonaws.com -i C:\Users\micha\.kube\MCEKS1.pem 17 | 18 | #You can get the above DNS by running the following command 19 | aws ec2 describe-instances --filters Name=instance-type,Values=m5.large 20 | 21 | #If this is the only compute nodes you have running then you may not need a filter 22 | aws ec2 describe-instances 23 | 24 | #Delete Amazon EKS Cluster 25 | eksctl delete cluster --name=mc-eks -------------------------------------------------------------------------------- /Getting Started with GKE.ps1: -------------------------------------------------------------------------------- 1 | #Make sure you have the Google Cloud SDK Installed on your system 2 | 3 | #Deploy GKE Cluster (basic) 4 | gcloud container clusters create cluster-name --num-nodes=1 5 | 6 | #Confirm access to new GKE Cluster 7 | kubectl get nodes 8 | 9 | #Available Kubernetes versions 10 | gcloud container get-server-config 11 | 12 | #Deploy GKE Cluster with latest version of Kubernetes 13 | gcloud container clusters create cluster-name --num-nodes=1 --cluster-version=latest 14 | 15 | #Available Machine Types 16 | gcloud compute machine-types list 17 | 18 | #Deploy GKE Cluster with latest version of Kubernetes and a specific machine type 19 | gcloud container clusters create cluster-name --num-nodes=1 --cluster-version=latest --machine-type=n1-standard-2 20 | 21 | #Deploy GKE Cluster with the latest version of Kubernetes, specific machine type and a number of nodes (default if not specified is 3) 22 | gcloud container clusters create cluster-name --num-nodes=4 --cluster-version=latest --machine-type=n1-standard-2 23 | 24 | #Deploy GKE Cluster with the latest version of Kubernetes, specific machine type, number of nodes, and specify regional cluster meaning you will get 2 nodes in each zone of the regional 25 | gcloud container clusters create cluster-name --num-nodes=2 --cluster-version=latest --machine-type=n1-standard-2 --region=europe-west2 26 | 27 | #Delete GKE Cluster 28 | gcloud container clusters delete cluster-name 29 | 30 | #Delete GKE Cluster with regional flag and multiple zones 31 | gcloud container clusters delete cluster-name --zone=europe-west2 32 | -------------------------------------------------------------------------------- /Getting Started with Microsoft AKS AzPowershell.ps1: -------------------------------------------------------------------------------- 1 | #Local Az PowerShell creating AKS cluster 2 | 3 | $ResourceGroupName = "CadeAKS" 4 | $ClusterName = "CadeAKSCluster" 5 | $ClusterLocation = "eastus" 6 | $NodeCount = "3" 7 | 8 | #Web Browser will open to authenticate against your subscription 9 | Connect-AzAccount 10 | 11 | #Create a New resource group 12 | New-AzResourceGroup -Name $ResourceGroupName -Location $ClusterLocation 13 | 14 | #Create the AKS cluster, GenerateSshKey is used here to authenticate to the cluster from the local machine. 15 | New-AzAksCluster -ResourceGroupName $ResourceGroupName -Name $ClusterName -NodeCount $NodeCount -GenerateSshKey -KubernetesVersion 1.19.7 16 | 17 | New-AzAksCluster -ResourceGroupName $ResourceGroupName -Name $ClusterName -NodeCount $NodeCount -SshKeyValue 'C:\\Users\micha\\.ssh\\id_rsa' 18 | 19 | #This will install Kubectl but i am not sure if this is needed if you already have kubectl on your system will have to test that. 20 | Install-AzAksKubectl 21 | 22 | #Now we need to add our AKS context so we can connect 23 | Import-AzAksCredential -ResourceGroupName $ResourceGroupName -Name $ClusterName -Force 24 | 25 | #Confirm that you have access to your cluster 26 | kubectl get nodes 27 | 28 | #If you have multiple contexts and you want to list them 29 | kubectl config get-contexts 30 | 31 | #change name below to the context you wish to jump to 32 | kubectl config use-context NAME 33 | 34 | kubectl create namespace kasten-io 35 | 36 | #To Delete your cluster run the following command 37 | Remove-AzResourceGroup -Name $ResourceGroupName -force 38 | Remove-Item C:\Users\micha\.ssh\id_rsa 39 | -------------------------------------------------------------------------------- /AzureCSI.azcli: -------------------------------------------------------------------------------- 1 | #Can only be set when you create the cluster 2 | #Has to be Kubernetes version 1.17 or newer 3 | #Default will remain in tree 4 | #Only Azure CLI is supported in preview 5 | 6 | #register feature flag 7 | az feature register --namespace "Microsoft.ContainerService" --name "EnableAzureDiskFileCSIDriver" 8 | 9 | #show feature list 10 | az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/EnableAzureDiskFileCSIDriver')].{Name:name,State:properties.state}" 11 | 12 | #refresh registration 13 | az provider register --namespace Microsoft.ContainerService 14 | 15 | #add and update the aks-preview extension for Azure CLI 16 | # Install the aks-preview extension 17 | az extension add --name aks-preview 18 | # Update the extension to make sure you have the latest version installed 19 | az extension update --name aks-preview 20 | 21 | # Create an Azure resource group 22 | az group create --name AKSCSIResourceGroup --location eastus 23 | 24 | #Choose the relevant & required Kubernetes version change to your region 25 | az aks get-versions --location eastus --output table 26 | 27 | # Create an AKS-managed Azure AD cluster 28 | az aks create -g AKSCSIResourceGroup -n AKSCSIManagedCluster --network-plugin azure -k 1.20.7 --node-count 3 --generate-ssh-keys --aks-custom-headers EnableAzureDiskFileCSIDriver=true 29 | 30 | #Merge AKS Cluster with current Kubectl Configuration 31 | az aks get-credentials --resource-group AKSCSIResourceGroup --name AKSCSIManagedCluster 32 | 33 | #Confirm kubectl has new config 34 | kubectl config get-contexts 35 | 36 | #Confirm your nodes are all up and running 37 | kubectl get nodes 38 | 39 | #crds, controllers, drivers, rbac 40 | kubectl create -f .\azurefile-csi-driver\deploy\ 41 | 42 | #Create VolumeSnapshotClass for Azure Disk 43 | kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/deploy/example/snapshot/storageclass-azuredisk-snapshot.yaml 44 | 45 | #Create VolumeSnapshotClass for Azure File 46 | kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/snapshot/volumesnapshotclass-azurefile.yaml 47 | 48 | #Confirm that we have our newly created VolumeSnapshotClass 49 | kubectl get VolumeSnapshotClass 50 | 51 | #Delete the Cluster 52 | az group delete --name AKSCSIResourceGroup --yes --no-wait 53 | 54 | #Resources 55 | #https://docs.microsoft.com/en-us/azure/aks/csi-storage-drivers 56 | #https://docs.microsoft.com/en-us/azure/aks/azure-disk-csi 57 | #https://docs.microsoft.com/en-us/azure/aks/azure-files-csi 58 | --------------------------------------------------------------------------------