automation, kubernetes-dedicated, linux, packet.net

Kubernetes, Helm and RancherOS

What is Helm?

Helm is the package manager for Kubernetes.

Helm is divided into two parts, the Helm Client (client) and Tiller Server (server)

Why do I need Helm?

To exemplify why do I need helm, I will tell you:

How my life was before Helm:

In order to get any kubernetes apps up and running, I had to:

  • Write Kubernetes manifests by hand
  • Do this everytime I wanted to release anything
  • Figure out how to deal with sharing this with other team members
  • Tweak all the resources by hand
  • Use kubectl to manage it

 

How is my life now with Helm:

  • Installing resources with kubernetes is now easy like apt-get, yum, homebrew … etc
  • My team is now able to colaborate, sharing helm charts on our internal repositories
  • Releases are reproducible across all environments (develop, accept and production)
  • Packages are now sharable

 

 

  • Charts: A bundle of kubernetes resource data, it operates the System Package
  • Repository: A collection of release charts, something like NPM, or Ubuntu Repository.
  • Release: A chart instance that was loaded into Kubernetes. If the same chart is installed several times inside the same cluster, each time the cart will have its own release.

 

Installing Helm on RancherOS

If you are trying to install Helm on RancherOS, chances are that you are now running into the problem that RancherOS does not come with cURL installed.

[rancher@kubernetes1 ~]$ curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
-bash: curl: command not found

Due to the fact that Helm uses cURL to download its dependencies, please follow up How to install cURL on RancherOS

 

Download Helm executable script:

[root@kubernetes1 ~]# curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5962 100 5962 0 0 47711 0 –:–:– –:–:– –:–:– 55203

 

Add the chmod to the executable file:

[root@kubernetes1 ~]# chmod 700 get_helm.sh

Install Helm:

[root@kubernetes1 ~]# ./get_helm.sh

Happy Helming

 

 

automation, docker, kubernetes-dedicated, linux, rancher server, rancheros

How to install Rancher Server on RancherOS

How to install Rancher Server on RancherOS ?

If you are playing with RancherOS, chances are that you are stuck trying to figure out how to get the Rancher Server (Web UI) up and running after your fresh RancherOS installation.

Why RancherOS?

With RancherOS,  your server runs on a System Docker as the first process the kernel starts.

The System Docker replaces systemd, thus allowing RancherOS to manage all system services as Docker containers.

 

In order to get started on it, I’ve created this little guide for my own reference, I hope it helps:

 

Installing Rancher Server on RancherOS with Docker

 

$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server
Unable to find image 'rancher/server:latest' locally
latest: Pulling from rancher/server

6599cadaf950: Pull complete 
23eda618d451: Pull complete 
f0be3084efe9: Pull complete 
52de432f084b: Pull complete 
a3ed95caeb02: Pull complete 
e75cd91a1dc5: Pull complete 
997f1b48f59f: Pull complete 
313c28fb4e37: Pull complete 
2a0730d1275c: Pull complete 
8848fbebd2c8: Pull complete 
bf44fc918d8d: Pull complete 
294d2b8ef44a: Pull complete 
8ef53e786a1e: Pull complete 
c66f5c1af2aa: Pull complete 
21a529f5f5c5: Pull complete 
e0b120915e7e: Pull complete 
1ce569657333: Pull complete 
a21d853ef921: Pull complete 
d11646728ac8: Pull complete 
Digest: sha256:59dba13b5cc1f50bbeb9127ed77cc5e72674e80f92dc0a22905a5df9372af464
Status: Downloaded newer image for rancher/server:latest
8064ddc60d59db1f4609f75cf425ab4e02e5dec08604014c1258195b398c3441


Check that the docker instance of rancher is up and running:

[rancher@kubernetes1 ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8064ddc60d59 rancher/server "/usr/bin/entry /usr/" About a minute ago Up About a minute 3306/tcp, 0.0.0.0:8080->8080/tcp hungry_roentgen



Installing Rancher Agent on RancherOS with Docker
[rancher@kubernetes1 ~]$ sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.2 http://147.75.81.119:8080/v1/scripts/59ADA64CAB0BC3410D4F:1483142400000:8Fxhl6E5HlVEIqLQmfrqKWG9V8c
Unable to find image 'rancher/agent:v1.2.2' locally
v1.2.2: Pulling from rancher/agent
b3e1c725a85f: Pull complete 
4daad8bdde31: Pull complete 
63fe8c0068a8: Pull complete 
4a70713c436f: Pull complete 
bd842a2105a8: Pull complete 
3f7d6fd71888: Pull complete 
16914729cfd3: Pull complete 
b9c91512c230: Pull complete 
Digest: sha256:cfb7fc0de1146680ca26e3bc8cd09cc7a0274eff99f5b84246c33642a99f81da
Status: Downloaded newer image for rancher/agent:v1.2.2

INFO: Running Agent Registration Process, CATTLE_URL=http://147.75.81.220:8080/v1
INFO: Attempting to connect to: http://147.75.81.220:8080/v1
INFO: http://147.75.81.220:8080/v1 is accessible
INFO: Inspecting host capabilities
INFO: Boot2Docker: false
INFO: Host writable: true
INFO: Token: xxxxxxxx
INFO: Running registration
INFO: Printing Environment
INFO: ENV: CATTLE_ACCESS_KEY=4DF30CB1CA8A0B6B4251
INFO: ENV: CATTLE_HOME=/var/lib/cattle
INFO: ENV: CATTLE_REGISTRATION_ACCESS_KEY=registrationToken
INFO: ENV: CATTLE_REGISTRATION_SECRET_KEY=xxxxxxx
INFO: ENV: CATTLE_SECRET_KEY=xxxxxxx
INFO: ENV: CATTLE_URL=http://147.75.81.220:8080/v1
INFO: ENV: DETECTED_CATTLE_AGENT_IP=172.17.0.1
INFO: ENV: RANCHER_AGENT_IMAGE=rancher/agent:v1.2.2
INFO: Launched Rancher Agent: ca73dede34008Installing Rancher Agent on RancherOS92f9203b1b45a9c3228d267cd2f723b105805c5dfa25170373e


You can now access your Rancher Server on the provided IP address, on my case (eg: http://147.75.81.220:8080/v1)

automation, kubernetes-dedicated, rancheros

Installing cURL on RancherOS

How to install cURL on RancherOS ?

RancherOS comes without cURL, so it maybe that if you are trying to install something on a RancherOS box, you will find a dead end when trying to use cURL.

So I created this post for my own future reference, I hope it helps someone else

 

 

[root@rancheros ~]# echo 'docker run --rm radial/busyboxplus:curl curl $@' > /usr/bin/curl && chmod +x /usr/bin/curl


[root@rancheros ~]# curl
Unable to find image 'radial/busyboxplus:curl' locallycurl:

Pulling from radial/busyboxplusa3ed95caeb02:

Pull complete 7802a1bc4dbd:

Pull complete e89c986f208e:

Pull complete Digest: sha256:a68c05ab1112fd90ad7b14985a48520e9d26dbbe00cb9c09aa79fdc0ef46b372Status:

Downloaded newer image for radial/busyboxplus:curlcurl: try 'curl --help' for more information
automation, java, SDET, soapUI

SoapUI Assessment – The Cloanto Currency Server

Introduction to the assessment

Hello there Tester,

A currency exchange company uses a server to provide the latest exchange rate information and conversions as a service.  It holds forty two operations for customers to query and they would like you to create tests for some of these operations.  

Today your job is to provided test cases using SoapUI for some of the real world scenarios our company are currently facing.

You should solve the problem using SOAP UI Standard (FREE) version, answers using SoapUI Pro are out of the scope today. 

Pre-Requisite

Import the WSDL into SoapUI from the following location:

http://fx.cloanto.com/webservices/CloantoCurrencyServer.asmx?WSDL

Screen Shot 2017-04-14 at 12.51.04

Fig 1: Imported WSDL

Figure 1 shows you what your project should look like.  Take time to familiarise yourself with the operations available and when you feel ready, begin creating your tests.

The SoapUI Test Scenarios

To help you get going, our Product Owner have prepared a set of scenarios that your testing techniques should be applied, they are:

Scenario 1:

Employees are not expected to learn every single currency code.  Devise a test that can return the full currency name for any currency code, this should be an input parameter.

 

Scenario 2:

A UK businesswoman trades currencies with Germany and uses the service regularly to check the value of Germany’s currency. Create a test that will check that the service returns a value and store it. 

 

Scenario 3:

A couple will be travelling to the United States of America and are keeping a close eye on the value of the dollar.  They want to purchase £500 worth of dollars, only if the amount of dollars is greater than $800.  The test condition should fail based on these conditions.

 

Scenario 4:

The company has a list of all currencies that they deal with.    Create a properties file containing the first five currencies and use that file to drive a test that will check each currency appears in the response.

 

Solution:

The solution for this challenge is quite tricky, it involves several steps and the resolution for the step 4 using SoapUI OpenSource version will require you to code some Groovy scripts in order to be able to finish the assessment.

You are finished when you have 3 passing and 1 failing:

test-result-mini

The resolution for all the steps you should be able to do it yourself, so I will only focus to explain the Test 4 and the parts involved.

How to pass properties to a request in SoapUI Free?

In SoapIU Pro, this is a easy task, however if you are a non-profit or just cheap developer who don’t like to pay anything, the resolution for some problems will require some Groovy coding skills.

So, How do I to pass properties to a request using SoapUI ? How do I use Groovy with SoapUI ?

The Test 4 involves passing properties into a action and executing it, so the following Groovy code will do the trick:

// Define the array
def paramList = [];
def projectDir = context.expand('${projectDir}');

// open the property file and store the contents in memory
new File( projectDir, "scenario_4_list_currencies.properties" ).eachLine { line -> paramList.add( line ) };

// Loop through each item in the array
for ( i in paramList ) {

 // Execute the myRequest TestStep
 log.info("will send the request using param value: " + i); 
 def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
 def testCase = testRunner.testCase;
 
 def testStep = testCase.getTestStepByName("myRequest");

//open the soapUI testcase and create a testRunner variable 
 testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
 //open the soapUI testStep
 testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
 //run the testRunner manually inserting the parameters from the property files on the scope
 //so the test will perform with no error when comparing contains
 testStep.run(testRunner, testStepContext);
}

Complete Code:

You can find this and more examples on SouJava Github – Complete Assessment

Cheers,

Thomas Modeneis.