CKAD kubernetes developer certification preparation

HOW to prepare CKAD exam as of Sep 2021

1. Mantra to pass CKAD exam

Practice !!!

Practice !!!

Practice !!!

2. Purchase the exam voucher

Exam vouchers are valid for 1 year in general, but always go and verify below links as they may change from time to time. Once you registered you can reschedule exam too if exam schedule is not with in 24 hours. At the time of this writing, CKAD exams voucher regular cost is $375 USD, now and then they give discounts from 10% to 50% also.

https://trainingportal.linuxfoundation.org/learn/course/certified-kubernetes-application-developer-ckad/exam/exam

https://www.cncf.io/certification/ckad/

Once you register exam, make sure you go through this exam handbook at least once. As it clears many of your exam related questions. Like what kind of browser supported (i.e. chrome), what extension to use and also rules and regulations.

https://docs.linuxfoundation.org/tc-docs/certification/lf-candidate-handbook

3.0 Curriculum

Official exam syllabus provided here. Be familiarize with the syllabus and prepare section wise. https://github.com/cncf/curriculum

I kept one week goal for each section to finish. This kind of goals will help you to prepare exam in a planned way.

3.1 Changes from Sep 28th 2021

Previous version for comparison:

Current Curriculum

New items included in changed curriculum are highlighted below. As exam has 19 questions or scenarios to complete in 2 hours, some questions are lengthy enough to take 1 minute to read. Time is challenge for the exam, it can be conquered only by practicing repeatedly until your fingers get muscle memory.

4.0 Make kubernetes.io as your browser home page. And download ckad exam browser favorites.

https://kubernetes.io/docs/home/

More familiar you are with this site, chances of passing exam are high. Think like this, they are allowing you carry this online guide with your exam and allowing to you copy officially and finish the exam (thanks to concept of open book exam, which help students not to memorize, but understand the concept)

ckad exam favorites are in reference section, get used to those favorite url. While practicing for exam try to reach required section quickly and copy the required yaml file quickly.

for you example if you need to create pv (persistant volume), then you need to go to “https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistent-volumes” and copy that yaml to your exam terminal and modify the yaml file.

5.0 you need a kubernetes environment to practice

5.1 Minikube

Best way to have practice environment is to setup minikube. Refer below my blog for instructions, if you use Linux os, I gave script to setup minikube

Note: for practicing network related modules, you need additional minikube modules

Following script will start minukube with 2 nodes (default it uses 1 node), 4 cores and 16gb. I use this higher configuration as my laptop has 8 core/32gb memory configuration. But 1 node with 1 core and 4 or 8 gb also works well.

5.2 Practice environment provided by Linux foundation

if you purchase exam voucher and register at Linux foundation, you get access to kiler.sh exam simulator. Trust me it’s much tougher than real exam, so if you finis these in time, you can relax and attend exam with full confidence.

https://trainingportal.linuxfoundation.org/learn/course/certified-kubernetes-application-developer-ckad/exam/exam

Same can be accessed from “https://killer.sh/dashboard” CKAD simulator using your linuxfoundation credentials. Does this inclusion of simulator impacted raise in exam price ??? as I remember exam voucher prices used to be around USD300.

https://killer.sh/dashboard

5.3 KodeKloud labs (kodkloud )

Enroll in kodekloud is good idea as it became de facto standard in kubernetes training (it’s not marketing gimmick and I have no association with him. kodekloud became house hold name for those who start learning kubernetes. it gives you virtual environment to practice all you need is internet and browser. Before attending exam you need to finish both lightning labs. Consider this as pre exam qualification. If you unable to do it, better postpone your exam. )

5.4 CKAD-Practice-Questions

You need questions to practice and you get them here.

https://github.com/bbachi/CKAD-Practice-Questions

5.5 Katacoda virtual browser based environments

Katacoda offering some basic scenarios for free. It’s a good start to practice, as they give you solutions too. https://www.katacoda.com/courses/kubernetes

6.0 Exam tips

Following common tips for the exam are:

$alias k=kubectl

(For me I observed it’s already configured in exam terminal, check with k <enter> as soon as you start exam.

Export following two variables, will be very handy from time to time

export do=”--dry-run=client -o yaml”

export d=”--grace-period=0 –force”

When you delete a pod it’s default wait time is 30seconds. This 30 seconds is very precious. So practice to use variable like $d to delete a pod, by referring $d, will delete it immediately and saves you those 30seconds.

$k delete po testpod $d

7.0 Reference

7.1 Bookmarks

kubernetes

container portconfigmap all envconfigmap env variablecronjobenv variable simplejobliveness commandliveness httpreadiness commandresource cpurollout deprolling update yamlresource memorynetwork policynode selectornode affinitypvcpvserviceaccountsecret env variablesecret as all env varsecuritycontext usersecuritycontext capabitiesservice Nodeportservice clusteriptainttolerationvolume emptydirvolume configmapvolume secretvolume hostpathvolume with pvcAssigning Pods to Nodes | KubernetesConnecting Applications with Services | KubernetesKubectl Reference DocsPerform a Rolling Update on a DaemonSet – Kuberneteskubectl Cheat Sheet | KubernetesAssign CPU Resources to Containers and PodsConfigure Liveness, Readiness and Startup Probes | Kubernetesingress 1.18

JSON PATH

free kodekloud course on Json path.

Now a days dealing with REST API bases services gives outputs of json. Knowing this jsonpath queries will be very help full to filter out and get the required outputs.

json-path-quiz

Discloser: no association or affiliation with kodekloud, just happen to see this course and did over weekend, sharing here as it might be useful for others. If you see other good courses on this topic, feel free recommends or provide the details.

User case senarios:

  1. If you are kubernets admin,then this will be very useful.
  2. if you are managing huge resources in any cloud environments and working on their CLI tools like azure cli, then this will be very useful to generate quick details about the cloud footprint.
  3. Hadoop services support rest api and provide json output, this query will be helpful to list required outputs.

For practice you can use :

https://jsonpath.com

JSONPathDescription
$the root object/element
@the current object/element
. or []child operator
..recursive descent. JSONPath borrows this syntax from E4X.
*wildcard. All objects/elements regardless their names.
[]subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator.
[,]Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set.
[start:end:step]array slice operator borrowed from ES4.
?()applies a filter (script) expression.
()script expression, using the underlying script engine.
Sample json:

{
“firstName”: “John”,
“lastName” : “doe”,
“age” : 26,
“address” : {
“streetAddress”: “naist street”,
“city” : “Nara”,
“postalCode” : “630-0192”
},
“phoneNumbers”: [
{
“type” : “iPhone”,
“number”: “0123-4567-8888”
},
{
“type” : “home”,
“number”: “0123-4567-8910”
}
]
}

json query to get iphone number

$.phoneNumbers.[0].number

[
“0123-4567-8888”
]

But order may not be standard, if we user number 0, it prints phone number of first item in the phoneNumbers list. We can write more specific query to get only iPhone number

$.phoneNumbers.[?(@.type == ‘iPhone’)].number

[
“0123-4567-8888”
]

Oracle DB pre built VM bringing up with vagrant

This is setup a ETL from oracle database to mysql/datawerehouse using open source tool like  Talend openstudio.

Pre Requisites for SANBOX environment:

1. Pre-built Virtual Machine for Oracle Enterprise Data Quality 12.2.1

Download The sandbox from Oracle and for installation steps use the guide clickhere

The following software is installed in this VirtualBox image, we just need bold highlighted software.

  • Oracle Enterprise Linux (64-bit) 6.6
  • Oracle Enterprise Data Quality 12.2.1.0.0
  • Oracle Enterprise Data Quality Customer Data Services Pack 12.2.1.0.0
  • Oracle Enterprise Data Quality Address Verification 15.3.0.0.0
  • Oracle Watchlist Screening 11.1.1.7.3
  • Oracle Database Enterprise Edition 12.1.0.1.0
  • Oracle WebLogic Server 12.2.1.0.0
  • Oracle SQL Developer 3.2.20.09.90
  • Oracle Java SE Development Kit Version 8, Update 65

system Requirements:

Please note that this VirtualBox appliance requires a host machine with a minimum of 8GB memory installed, and that 16GB is recommended; your host computer must also have an up to date Java Runtime Environment (JRE) installed.

Installation Procedure:

ls -l
total 10659316
-rw-rw-r– 1 user user 2147483648 Mar 23 19:47 EDQ-12.2.1-Trn.zip.001
-rw-rw-r– 1 user user 2147483648 Mar 23 18:59 EDQ-12.2.1-Trn.zip.002
-rw-rw-r– 1 user user 2147483648 Mar 23 18:57 EDQ-12.2.1-Trn.zip.003
-rw-rw-r– 1 user user 2147483648 Mar 23 18:57 EDQ-12.2.1-Trn.zip.004
-rw-rw-r– 1 user user 2147483648 Mar 23 18:57 EDQ-12.2.1-Trn.zip.005
-rw-rw-r– 1 user user 177698269 Mar 23 18:44 EDQ-12.2.1-Trn.zip.006

cat EDQ-12.2.1-Trn.zip.00* > EDQ-12.2.1-Trn.zip

unzip EDQ-12.2.1-Trn.zip
Archive: EDQ-12.2.1-Trn.zip
inflating: EDQ-12.2.1-Trn.ova

NOTE: Attempt to import EDQ-12.2.1 failed with following error

2nd Attempt made with following with EDQ-12.1.3

Pre-built Virtual Machine for Oracle Enterprise Data Quality 12.1.3

Overview

Please note that this appliance is for testing purposes only, as such it is unsupported and should not be used in production environments.

This VirtualBox appliance contains a fully configured, ready-to-use Oracle Enterprise Data Quality 12.1.3 installation.  It also includes the Oracle Enterprise Data Quality Customer Data Services Pack 11.1.1.7.4, and Oracle Watchlist Screening 11.1.1.7.3.

All you need is to install Oracle VM VirtualBox on your desktop/laptop  and you are ready to try out Oracle Enterprise Data Quality 12.1.3 — no installation and configuration required!

The following software is installed in this VirtualBox image:

  • Oracle Enterprise Linux (64-bit) 6.6
  • Oracle Enterprise Data Quality 12.1.3.0.0
  • Oracle Enterprise Data Quality Customer Data Services Pack 11.1.1.7.4
  • Oracle Enterprise Data Quality Address Verification 14.4.0.0.0
  • Oracle Watchlist Screening 11.1.1.7.3
  • Oracle Database Enterprise Edition 12.1.0.1.0
  • Oracle WebLogic Server 12.1.3.0.0
  • Oracle SQL Developer 3.2.20.09.90
  • Oracle Java SE Development Kit Version 7, Update 71
  • Oracle Java SE Development Kit Version 8, Update 25

Please note that this VirtualBox appliance requires a host machine with a minimum of 8GB memory installed, and that 16GB is recommended; your host computer must also have an up to date Java Runtime Environment (JRE) installed.

Please check the EDQ 12.1.3 VM Installation Guide for detailed instructions on downloading and importing the VirtualBox image and make sure to also check the Release Notes.

1. Go to oracle github vagrant

https://github.com/oracle/vagrant-boxes/tree/master/OracleDatabase/12.2.0.1

2.  Follow the steps:

$cd /media/user/E224F55324F52AE5/oracle12db

$git clone https://github.com/oracle/vagrant-boxes

$cd vagrant-boxes/OracleDatabase/12.2.0.1

$mv ~user/Downloads/linuxx64_12201_database.zip .

$vagrant up
Bringing machine ‘oracle-12201-vagrant’ up with ‘virtualbox’ provider…
==> oracle-12201-vagrant: Box ‘ol7-latest’ could not be found. Attempting to find and install…
oracle-12201-vagrant: Box Provider: virtualbox
oracle-12201-vagrant: Box Version: >= 0
==> oracle-12201-vagrant: Box file was not detected as metadata. Adding it directly…
==> oracle-12201-vagrant: Adding box ‘ol7-latest’ (v0) for provider: virtualbox
oracle-12201-vagrant: Downloading: https://yum.oracle.com/boxes/oraclelinux/latest/ol7-latest.box

—> failed as AMD-V (virtualization feature for AMD processor) not enabled in Bios.

2nd attempt:

$vagrant up
Bringing machine ‘oracle-12201-vagrant’ up with ‘virtualbox’ provider…
==> oracle-12201-vagrant: Clearing any previously set forwarded ports…
==> oracle-12201-vagrant: Clearing any previously set network interfaces…
==> oracle-12201-vagrant: Preparing network interfaces based on configuration…
oracle-12201-vagrant: Adapter 1: nat
==> oracle-12201-vagrant: Forwarding ports…
oracle-12201-vagrant: 1521 (guest) => 1521 (host) (adapter 1)
oracle-12201-vagrant: 5500 (guest) => 5500 (host) (adapter 1)
oracle-12201-vagrant: 22 (guest) => 2222 (host) (adapter 1)
==> oracle-12201-vagrant: Running ‘pre-boot’ VM customizations…
==> oracle-12201-vagrant: Booting VM…
==> oracle-12201-vagrant: Waiting for machine to boot. This may take a few minutes…
oracle-12201-vagrant: SSH address: 127.0.0.1:2222
oracle-12201-vagrant: SSH username: vagrant
oracle-12201-vagrant: SSH auth method: private key
oracle-12201-vagrant:
oracle-12201-vagrant: Vagrant insecure key detected. Vagrant will automatically replace
oracle-12201-vagrant: this with a newly generated keypair for better security.
oracle-12201-vagrant:
oracle-12201-vagrant: Inserting generated public key within guest…
oracle-12201-vagrant: Removing insecure key from the guest if it’s present…
oracle-12201-vagrant: Key inserted! Disconnecting and reconnecting using new SSH key…
The private key to connect to this box via SSH has invalid permissions
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
ignore the key. Vagrant tried to do this automatically for you but failed. Please set the
permissions on the following file to 0600 and then try running this command again:

/media/user/E224F55324F52AE5/oracle12db/vagrant-boxes/OracleDatabase/12.2.0.1/.vagrant/machines/oracle-12201-vagrant/virtualbox/private_key

Note that this error occurs after Vagrant automatically tries to
do this for you. The likely cause of this error is a lack of filesystem
permissions or even filesystem functionality. For example, if your
Vagrant data is on a USB stick, a common case is that chmod is
not supported. The key will need to be moved to a filesystem that
supports chmod.

3rd attempt:

vagrant up
Bringing machine ‘oracle-12201-vagrant’ up with ‘virtualbox’ provider…
==> oracle-12201-vagrant: This machine used to live in /media/user/E224F55324F52AE5/oracle12db/vagrant-boxes/OracleDatabase/12.2.0.1 but it’s now at /home/user/oracle12db/vagrant-boxes/OracleDatabase/12.2.0.1.
==> oracle-12201-vagrant: Depending on your current provider you may need to change the name of
==> oracle-12201-vagrant: the machine to run it as a different machine.
==> oracle-12201-vagrant: Running provisioner: shell…
oracle-12201-vagrant: Running: /tmp/vagrant-shell20190325-5246-17fd2r5.sh
oracle-12201-vagrant: INSTALLER: Started up
oracle-12201-vagrant: Resolving Dependencies
oracle-12201-vagrant: –> Running transaction check

——Succeeded

oracle-12201-vagrant: ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: xxxxxxxx
oracle-12201-vagrant: INSTALLER: Installation complete, database ready to use!
(base) user@ubuntu18:~/oracle12db/vagrant-boxes/OracleDatabase/12.2.0.1$

Note: It print db password last but one line make note of it.

How to Install AZURE VM using Terraform


Reference: Microsoft LINK about the steps

HASHICORP link on azure build

Install terraform:

wget –no-check-certificate https://releases.hashicorp.com/terraform/0.14.6/terraform_0.14.6_linux_amd64.zip
unzip terraform_0.14.6_linux_amd64.zip
#Update .profile with path

vi ~/.profile
source ~/.profile

terraform -install-autocomplete

Install azcli:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
AZ_REPO=$(lsb_release -cs)
echo “deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main” | sudo tee /etc/apt/sources.list.d/azure-cli.list
curl -sL https://packages.microsoft.com/keys/microsoft.asc|gpg –dearmor| sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg

mkdir /tf/learn-terraform-azure
cd /tf/learn-terraform-azure
STEP#1 create the terraform file “main.tf” with all required Azure Resources
vi main.tf

###Configure the Azure provider

terraform {
required_providers {
azurerm = {
source = “hashicorp/azurerm”
version = “>= 2.26”
}
}
}
provider “azurerm” {
features {}
}

###Create Resource Group with name “myrg” in eastus2 location.

resource “azurerm_resource_group” “rg” {
name = “myrg”
location = “eastus2”
tags = {
environment = “Terraform Demo”
}
}

###Create Azure virtual network with name “myVnet”

resource “azurerm_virtual_network” “mynw” {
name = “myVnet”
address_space = [“10.0.0.0/16”]
location = “eastus2”
resource_group_name = azurerm_resource_group.rg.name
tags = {
environment = “Terraform Demo”
}
}

###Create subnetwork on virtual network created above.

resource “azurerm_subnet” “mysn” {
name = “mySubnet”
resource_group_name = azurerm_resource_group.rg.name
virtual_network_name = azurerm_virtual_network.mynw.name
address_prefixes = [“10.0.2.0/24”]
}

###Create public IP

resource “azurerm_public_ip” “mypip” {
name = “myPublicIP”
location = “eastus2”
resource_group_name = azurerm_resource_group.rg.name
allocation_method = “Dynamic”
tags = {
environment = “Terraform Demo”
}
}

###NSG rules are important for security

resource “azurerm_network_security_group” “mynsg” {
name = “myNetworkSecurityGroup”
location = “eastus2”
resource_group_name = azurerm_resource_group.rg.name
security_rule {
name = “SSH”
priority = 1001
direction = “Inbound”
access = “Allow”
protocol = “Tcp”
source_port_range = “” destination_port_range = “22” source_address_prefix = “
destination_address_prefix = “*”
}
tags = {
environment = “Terraform Demo”
}
}

###Create Azure network interface

resource “azurerm_network_interface” “mytfnic” {
name = “myNIC”
location = “eastus2”
resource_group_name = azurerm_resource_group.rg.name

ip_configuration {
    name                          = "myNicConfiguration"
    subnet_id                     = azurerm_subnet.mysn.id
    private_ip_address_allocation = "Dynamic"
    public_ip_address_id          = azurerm_public_ip.mypip.id
}

tags = {
    environment = "Terraform Demo"
}

}

###Connect the security group to the network interface

resource “azurerm_network_interface_security_group_association” “sg2nic” {
network_interface_id = azurerm_network_interface.mytfnic.id
network_security_group_id = azurerm_network_security_group.mynsg.id
}

###Create Stoage Account with random name

resource “random_id” “randomId” {
keepers = {
# Generate a new ID only when a new resource group is defined
resource_group = azurerm_resource_group.rg.name
}
byte_length = 8
}
resource “azurerm_storage_account” “mysa” {
name = “diag${random_id.randomId.hex}”
resource_group_name = azurerm_resource_group.rg.name
location = “eastus2”
account_replication_type = “LRS”
account_tier = “Standard”

tags = {
    environment = "Terraform Demo"
}

}

###Private keys creation

resource “tls_private_key” “example_ssh” {
algorithm = “RSA”
rsa_bits = 4096
}
output “tls_private_key” { value = tls_private_key.example_ssh.private_key_pem }

###Now create the Azure VM

resource “azurerm_linux_virtual_machine” “mytfvm” {
name = “myVM”
location = “eastus2”
resource_group_name = azurerm_resource_group.rg.name
network_interface_ids = [azurerm_network_interface.mytfnic.id]
size = “Standard_DS1_v2”
os_disk {
name = “myOsDisk”
caching = “ReadWrite”
storage_account_type = “Standard_LRS”
}

source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "18.04-LTS"
    version   = "latest"
}

computer_name  = "myvm"
admin_username = "azuser1"
disable_password_authentication = true

admin_ssh_key {
    username       = "azuser1"
    public_key     = tls_private_key.example_ssh.public_key_openssh
}

boot_diagnostics {
    storage_account_uri = azurerm_storage_account.mysa.primary_blob_endpoint
}

tags = {
    environment = "Terraform Demo"
}

}
STEP2: Run the plan
$terraform plan
STEP3: Execute now to create the resources
$terraform apply
STEP4: ls terraform.tfstate
Connect to Azure VM:

  1. create the private key “azuser1.pem”
  2. Change permissions “chmod 400 azuser1.pem”
  3. Connect to VM using: ssh -i azuser1.pem azuser1@

~/tf/learn-terraform-azure$ terraform destroy

Azure automation using powershell

Editor to use: your choice

prefered: visual studio code (free and meant for azure automation, cross-platform)

This article is about to configure  power shell editor: Windows powershell ISE

PS C:\Users\user1> Install-Module azureautomationauthoringtoolkit -scope CurrentUser

PS C:\Users\user1> Import-Module -name azureautomationauthoringtoolkit
Import-Module : File C:\Users\user1\Documents\WindowsPowerShell\Modules\azureautomationauthoringtoolkit\0.2.4
.2\AzureAutomationAuthoringToolkitInner.psm1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module -name azureautomationauthoringtoolkit
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

To make it work:

Get-ExecutionPolicy -scope CurrentUser

Then got this warning. What to do now yes/no

Powershell_securitywarning

Got below error. Through this powershell automation, windows is trying to change to unix like OS, but still long way to go.

Betterway I think is giving us option like sudo in unix, running such high privileged commands, instead rerunning entire powershell with “Run as administrator”. But I can understand windows team is tranisitioning takes time to mature.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied. To change the execution policy for the default (LocalMachine) scope, start Windows PowerShell with the “Run as administrator” option. To change the execution policy for the current user, run “Set-ExecutionPolicy -Scope CurrentUser”.
At line:1 char:1
+ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionP
olicyCommand

when I reran in powershell with “Run as administrator” it worked. I hope I remember to reset this after my powershell practice as it puts me at great risk

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Another x86 vs x64 dilemma

PS C:\Users\user1> Import-Module -name azureautomationauthoringtoolkit -scope Global
Windows PowerShell Workflow is not supported in a Windows PowerShell x86-based console. Open a Windows PowerShell x64-based console, and then try again. At C:\Users\user1\Documents\WindowsPowerShell\Modules\azureautomationauthoringtoolkit\0.2.4.2\AzureAutomation AuthoringToolkit.psm1:1 char:1
+ <#
+ ~~
+ CategoryInfo : OperationStopped: (:) [], NotSupportedException
+ FullyQualifiedErrorId : System.NotSupportedException

Finally it worked after run as x64.

Next thing is to authenticate Azure

AzureAutomation-windowsPowerShell_ISE