Kubernetes for Dummies: Your first Cluster IBM Cloud Private

A step-by-step to start creating your First Cluster Kubernetes in IBM Cloud.

Hope you enjoy! Stay tuned!

For Windows machines:

Install Chocolatey

@”%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe” -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”

Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.11.
Extracting C:\Users\IGORMO~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\IGORMO~1\AppData\Local\Temp\chocolatey\chocInstall…
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting ‘Machine’)
Setting ChocolateyInstall to ‘C:\ProgramData\chocolatey’
WARNING: It’s very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to ‘C:\ProgramData\chocolatey\lib’
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to ‘C:\ProgramData\chocolatey\bin’
and points to an executable in ‘C:\ProgramData\chocolatey\lib\yourPackageName’.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
‘Batch file could not be found’ is also safe to ignore.
‘The system cannot find the file specified’ – also safe.
chocolatey.nupkg file not installed in lib.
Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding…
WARNING: Not setting tab completion: Profile file does not exist at ‘C:\Users\IgorMonteiroVieira\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1’.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

Install kubernetes-helm

C:\WINDOWS\system32>choco install kubernetes-helm
Chocolatey v0.10.11
Installing the following packages:
By installing you accept licenses for the packages.
Progress: Downloading kubernetes-helm 2.9.1… 100%

kubernetes-helm v2.9.1 [Approved]
kubernetes-helm package files install completed. Performing other installation steps.
The package kubernetes-helm wants to run ‘chocolateyInstall.ps1’.
Note: If you don’t run this script, the installation will fail.
Note: To confirm automatically next time, use ‘-y’ or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[N]o/[P]rint): Y

Downloading kubernetes-helm 64 bit
from ‘https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-windows-amd64.zip’
Progress: 100% – Completed download of C:\Users\IgorMonteiroVieira\AppData\Local\Temp\chocolatey\kubernetes-helm\2.9.1\helm-v2.9.1-windows-amd64.zip (8.78 MB).
Download of helm-v2.9.1-windows-amd64.zip (8.78 MB) completed.
Hashes match.
Extracting C:\Users\IgorMonteiroVieira\AppData\Local\Temp\chocolatey\kubernetes-helm\2.9.1\helm-v2.9.1-windows-amd64.zip to C:\ProgramData\chocolatey\lib\kubernetes-helm\tools…
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
ShimGen has successfully created a shim for helm.exe
The install of kubernetes-helm was successful.
Software installed to ‘C:\ProgramData\chocolatey\lib\kubernetes-helm\tools’

Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Add incubator (I will tell you in next post what is that. For security reasons, install!)

helm repo add ibm-incubator https://registry.bluemix.net/helm/ibm-incubator
Error: Couldn’t load repositories file (C:\Users\IgorMonteiroVieira\.helm\repository\repositories.yaml).
You might need to run `helm init` (or `helm init –client-only` if tiller is already installed)

C:\WINDOWS\system32>cd helm init
The system cannot find the path specified.

C:\WINDOWS\system32>helm init
Creating C:\Users\IgorMonteiroVieira\.helm
Creating C:\Users\IgorMonteiroVieira\.helm\repository
Creating C:\Users\IgorMonteiroVieira\.helm\repository\cache
Creating C:\Users\IgorMonteiroVieira\.helm\repository\local
Creating C:\Users\IgorMonteiroVieira\.helm\plugins
Creating C:\Users\IgorMonteiroVieira\.helm\starters
Creating C:\Users\IgorMonteiroVieira\.helm\cache\archive
Creating C:\Users\IgorMonteiroVieira\.helm\repository\repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL:
$HELM_HOME has been configured at C:\Users\IgorMonteiroVieira\.helm.
Error: error installing: Post http://localhost:8080/apis/extensions/v1beta1/namespaces/kube-system/deployments: dial tcp connectex: No connection could be made because the target machine actively refused it.

Start Helm

C:\WINDOWS\system32>helm init –client-only
$HELM_HOME has been configured at C:\Users\IgorMonteiroVieira\.helm.
Not installing Tiller due to ‘client-only’ flag having been set
Happy Helming!

Add Docker container to the repository

C:\WINDOWS\system32>helm repo add ibm-incubator https://registry.bluemix.net/helm/ibm-incubator
“ibm-incubator” has been added to your repositories

Create a service ID to IBM Cloud

C:\WINDOWS\system32>bx iam service-id-create ibmigor
Creating service ID ibmigor bound to current account as igor@br.ibm.com…
Service ID ibmigor is created successfully

Name          ibmigor
CRN           crn:v1:bluemix:public:iam-identity::a/596165d331edf2279*******9d50::serviceid:ServiceId-a0f3807b-225c-47e9*****3504aa53
Bound To      crn:v1:bluemix:public:::a/596165****f22796ad7644a2889d50:::
Version       1-a11b73ee87d878a2a3e26d49a3385b35
Locked        false
UUID          ServiceId-a0f38******7e9-8b20-27de3504aa53

Create an API

C:\WINDOWS\system32>bx iam service-api-key-create apikeyname ibmigor
Creating API key apikeyname of service ibmigor as igor@br.ibm.com…
Service API key apikeyname is created

Please preserve the API key! It cannot be retrieved after it’s created.

Name          apikeyname
Bound To      crn:v1:bluemix:public:iam-identity::a/596165d33***44a2889d50::serviceid:ServiceId-a0f3****7e9-8b20-27de3504aa53
Created At    2018-07-11T23:04+0000
API Key       KnMqBkyfTAZhBXx_GY8Ac6***Cwjh7ps
Locked        false
UUID          ApiKey-dcc6fc4f-******f505

Create such Policy for that container

C:\WINDOWS\system32>bx iam service-policy-create ibmigor –resource-type scaningress –service-name container-registry –roles Writer
Creating policy under current account for service ID ibmigor as igor@br.ibm.com…
Service policy is successfully created

Policy ID:   ef76ac2f-c6f9-40c0-b51c-1a0450a281ed
Version:     1-48d5ad27242782ac38f451c2928f0f55
Roles:       Writer
Service Name       container-registry
Service Instance
Resource Type      scaningress

Let’s inspect that container?

C:\WINDOWS\system32>helm inspect values ibm-incubator/ibmcloud-container-scanner > config.yaml

Identify your AccountID

C:\WINDOWS\system32>bx account list
Retrieving all accounts of igor@br.ibm.com…
Account GUID                       Name                      State    Owner User ID
596165****df22796ad7644a2889d50   IGOR MONTEIRO’s Account   ACTIVE   igor@br.ibm.com

Is there any cluster available? Not yet!

C:\WINDOWS\system32>bx cs clusters
Name   ID   State   Created   Workers   Location   Version

What are the zones?

C:\Users\IgorMonteiroVieira>ibmcloud cs zones


Ok, I want to see even more. What are the types into zone?

C:\Users\IgorMonteiroVieira>ibmcloud cs machine-types sao01
Name         Cores   Memory   Network Speed   OS             Server Type   Storage   Secondary Storage   Trustable
u2c.2×4      2       4GB      1000Mbps        UBUNTU_16_64   virtual       25GB      100GB               false
b2c.4×16     4       16GB     1000Mbps        UBUNTU_16_64   virtual       25GB      100GB               false
b2c.16×64    16      64GB     1000Mbps        UBUNTU_16_64   virtual       25GB      100GB               false
b2c.32×128   32      128GB    1000Mbps        UBUNTU_16_64   virtual       25GB      100GB               false
b2c.56×242   56      242GB    1000Mbps        UBUNTU_16_64   virtual       25GB      100GB               false

You know, Let’s rock! Create your FIRST Cluster with Free Account:

C:\Users\IgorMonteiroVieira>ibmcloud cs cluster-create –name igorcluster
The ‘machine-type’ flag was not specified. So a free cluster will be created.
Creating cluster…

Creation status is: Requested. You have to wait Deployed.

C:\Users\IgorMonteiroVieira>ibmcloud cs clusters
Name          ID                                 State       Created          Workers   Location         Version
igorcluster   26ce924a271e4fafb0c3f0cb0de71079   requested   14 seconds ago   1         us-south-hou02   1.9.8_1515

What are the workers for my cluster?

C:\Users\IgorMonteiroVieira>ibmcloud cs workers igorcluster
ID                                                 Public IP   Private IP   Machine Type   State               Status   Zone    Version
kube-hou02-pa26ce924a271e4fafb0c3f0cb0de71079-w1   –           –            free           provision_pending   –        hou02   1.9.8_1517

What are the config for my cluster ? Ohhh, still haven’t finished it’s creation. Tongue

C:\Users\IgorMonteiroVieira>ibmcloud cs cluster-config igorcluster

The cluster is not fully deployed yet. Wait a few minutes, then try again.   (E0030)
Incident ID: 7dab38c2-80f4-4f47-bce0-54c2818b3ed0

What is the status? Normal, it’s fine then!

C:\Users\IgorMonteiroVieira>ibmcloud cs clusters

Name          ID                                 State    Created          Workers   Location   Version
igorcluster   26ce924a271e4fafb0c3f0cb0de71079   normal   41 minutes ago   1         Dallas     1.9.8_1515

Let’s get the variables and start playing?

C:\Users\IgorMonteiroVieira>ibmcloud cs cluster-config igorcluster
The configuration for igorcluster was downloaded successfully. Export environment variables to start using Kubernetes.

SET KUBECONFIG=C:\Users\IgorMonteiroVieira\.bluemix\plugins\container-service\clusters\igorcluster\kube-config-hou02-igorcluster.yml

Export that variable:

C:\Users\IgorMonteiroVieira>SET KUBECONFIG=C:\Users\IgorMonteiroVieira\.bluemix\plugins\container-service\clusters\igorcluster\kube-config-hou02-igorcluster.yml

Finally, start your Kubernetes Locally with Proxy Tunnel:

C:\Users\IgorMonteiroVieira>kubectl proxy
Starting to serve on

Enjoyed? Post here your tries!


Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair /  Alterar )

Foto do Google

Você está comentando utilizando sua conta Google. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s