Blockchain, Ethererum, Solidity

Solidity, The Ethereum programming model.

Ethereum has a fairly “hard to understand” programming model.

It makes Senior devs, to spend hours chasing their own tails. Wondering what is going on with their code.

 

So I decided to write this little post, in order to clarify some aspects that I think are Crucial on Any programming language.

The main idea is: YES, Solidity can improve, but there are so many things do be done, most of them are basics that any other programming language have. Things that have been solved long time ago.

Would Ethereum survive and thrive ?Β 

TYPES:

Solidity includes the following types:

hash: 256-bit, 32-byte data chunk, index-able into bytes and operable with bit-wise operations.
uint: 256-bit unsigned integer, operable with bit-wise and unsigned arithmetic operations.
int: 256-bit signed integer, operable with bit-wise and signed arithmetic operations.

real: 256-bit signed fixed-point quantity, 127-bit left of the point, 128-bit right.
string32: zero-terminated ASCII string of maximum length 32-bytes (256-bit).

bytes32: sequence of 32 bytes (256 bit in total).

address: account identifier, similar to a 160-bit hash type.
bool: two-state value.

 

BYTES:

All the types (Hash,uint,int,string32, etc) in Solidity are 256-bit wide.

So, no matter what use use (int8, int16, int32). If you create a type in Solidity, its ALWAYS 256-bit.

The native 256-bit wide primitive type is the bytes32.

Strings

String concatenation must be done by hand after casting to a byte array.

If you want to use indexOf() you must writte your OWN implementation by hand or copy one into your program.

 

String Length

To get the length of a string you must cast it to a byte array.

And it gets worse, If you “accidentally” pass a empty string to a function (normal day to day programming issue).Β This will cause all arguments after that string to be silently corrupted, and of course make you hate your life and all your relatives mother for couple of days. πŸ˜€

 

Numbers

Despite Ethereum being intended to be used by Finance contracts,Β floating point is not supported AND Integer operations can overflow.

(That’s a feature, not a bug. Said a solidity developer).

There is a enhancement open in order to provide simple basic functions for fixed point types:

 

Arithmetic overflows return silently:

FOR LOOP:

A normal JS programmer, would write a for loop like this:

var a[] = (... think there are +256 elements on this array)
for (var i = 0; i < a.length; i ++) {
 a[i] = i;
}

WELL, if you are programming in Solodity, be advised: This loop it will enter an infinite loop.

Because a[] is a array bigger than 255 elements it will wrap around back to zero.

Arrays:

Array syntax kind of looks like C or Java. BUT, you will freak out now: Array declaration syntax is written backwards:

 int8[][5]

This syntax declares a 5 dynamic arrays of bytes.

 

Array of String

Arrays of Strings is not allowed. You cannot create multi-dimensional dynamic arrays.
Because “string” is a byte array, that means “string[]” does not work. πŸ˜€

 

Crash with too large arraysΒ 

A simple uint definition, can cause the compiler to crash with error:Β Integer constant too large

contract c {
	uint[8**90] ids;
}
contract c {
	struct Data { uint x; uint y; }
	Data[8**90] data;
}

Detailed error:

solidity/libsolidity/ast/Types.cpp(977): Throw in function virtual u256 dev::solidity::RationalNumberType::literalValue(const dev::solidity::Literal *) const
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
std::exception::what: Integer constant too large.
[dev::tag_comment*] = Integer constant too large.

 

JSON:

The documentation includes a list of …. bugs ….

`In some situations, the optimizer replaces certain numbers in the code with routines that compute different numbers`

`Dynamic allocation of an empty memory array caused an infinite loop and thus an exception`

 

Garbage Collection (GC):

Oh, if you use Java, NodeJS or Golang, you are adapted and just love your GC skills. You probably never worry about it.
Solidity have no garbage collection.
Dead allocations are never reclaimed, despite the scarcity of available memory space.
There is also no manual memory management. (SCARED).

 

 

THIS keyword:

In Solidity there is a “this” keyword …

However there are actually security-critical differences between “this.setX()” and “setX()” that can cause wrong results.

I also really love the way they deal with the issue, very fast and precisely providing a correction. This Dev seems to be also very happy about it:

 

Just to wrap this up, I don’t want to spoil anyone party here. I just think there is a loot going on on Ethereum right now, developers are working hard and is likely that this get fixed soon (HOPEFULLY).

However, one should consider this points, before diving into programming in Solidity, therefore avoiding new bugs like the $31M stolen couple months ago.

 

More about it:

Solidity is so riddled with bizarre design errors that it makes PHP4 look like a work of genius.

Exactly, this is a language that they want to run a new economy, not just payment processing, but banking, title transfer, legal resolutions

Underhanded Solidity Coding ContestΒ 

Deconstructing the DAO Attack: A Brief Code Tour

List of “closed” bugs on Ethereum Solidity

List of Open bugs on Ethereum Solidity

Advertisements
Uncategorized

Kubernetes DevOps day-to-day tasks and commands – Kubernetes/HELM Cheatsheet

 

Often I see members of my team struggling to remember the somehow hard to remember commands for operating Kubernetes. Its quite hard to find a descent documentation that goes straight to the point. Not much lalala, but just give me the CMD I’m looking for.

This is a curated list that I’ve been updating periodically with many of the commands I use day to day on operations, so if you know anything that is not here, please let me know! πŸ˜€

Kubernetes DevOps day-to-day tasks and commands

devops

 

Kubernetes – How to change the scope to another namespace

$ kubectl config set-context $(kubectl config current-context) --namespace=env-JIRA-1234

Kubernetes – How to List the active pods on a namespace:

$ kubectl get pods
NAME READY STATUS RESTARTS AGE
golang-api-1280745034-4s6jt 1/1 Running 0 17m
golang-api-1280745034-7knzq 1/1 Running 0 17m
``

 

Kubernetes – How to Get the logs for a POD:

$ kubectl logs golang-api-1280745034-4s6jt

 

Kubernetes – How toΒ Get services the Load Balancer IP addresses for a Namespace:

$ kubectl get services --namespace=develop
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
(...)

 

Kubernetes – How toΒ Get the ingres and services for a Namespace:

$ kubectl get ing,service --namespace=develop

Kubernetes – How to Get info about the services for a Namespace

$ kubectl describe services --namespace=develop 
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
(...)

Kubernetes – How toΒ Get info about the services for ALL Namespaces

$Β kubectl get services --all-namespaces
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
(...)

 

Kubernetes – How to open a proxy to a POD and expose it locally OR (How to connect to a POD directly and expose it locally)

$ kubectl port-forward golang-api-1280745034-4s6jt 8888:3000

 

Kubernetes – How to configure kubectl to always point to same cluster

$ kubectl config set-context gke_apps_europe-west1-b_europa --namespace=prod

Kubernetes – How to Get the current context (The cluster kubectl is pointing to)

$Β kubectl config current-context

Kubernetes – How to setup kubectl Auto Complete

$ source <(kubectl completion bash)

Kubernetes – How to check resource utilization (TOP) for all nodes (Cluster legs)

$kubectl top nodes

Kubernetes – How to check resource utilization (TOP) for all pods in all namespaces

$ kubectl top pods --all-namespaces

Kubernetes – How to WATCH constantly the resource utilization for all pods in a particular namespace and order the results so they don’t keep changing all the time.

$ watch "kubectl top pods --namespace=prod |sort"

Kubernetes – How to WATCH constantly the resource utilization for nodesΒ in a particular namesmace (legs) andΒ order the results so they don’t keep changing all the time.

$ watch "kubectl top nodes --namespace=prod |sort"

Kubernetes – How to WATCH constantly the resource utilization for all pods in ALL namespaces and order the results so they don’t keep changing all the time.

$ watch "kubectl top pods --all-namespaces |sort"

 

Kubernetes – How to kill all running jobs:

`kubectl delete jobs -l `

Kubernetes – How to SSH inside a node to execute commands

Β gcloud compute ssh gke-cluster-default-pool-123-4321s --zone europe-west1-c

 

Kubernetes – How toΒ SSH inside the pod and perform a curl on the healthcheck endpoint. This is particular useful for troubleshot and assert that the service is really running and healthy.

$ kubectl exec -ti golang-api-1280745034-4s6jt curl http://localhost:3000/health`

 

Kubernetes – How toΒ Change the configuration file Β ‘on the fly’

Β kubectl apply -f kubernetes/config/develop.yaml

Kubernetes – How toΒ Restart all PODS in one go:

Β $kubectl delete pods -l app=golang-api --namespace=prod

Kubernetes – How toΒ List all Environment variables for a particular POD

$ kubectl exec -ti golang-api-4135068084-3wpb5 env --namespace=prod

Kubernetes – How toΒ Check health for a particular backend POD from inside the frontend pod in order to test that they connect with no issues

$Β kubectl exec -ti front-end-355436834-whtnp curl http://golang-api/health --namespace=prod

Kubernetes – How toΒ Check for all logs inside the main scheduler

Β $ journalctl -f

Kubernetes – How toΒ List all pods and order them by how many times they have restarted. This is useful to detect memory leaks or debug the pods that are restarting more often.

$ kubectl get pods --sort-by=.status.containerStatuses[0].restartCount

Kubernetes – How to test that your API is returning something on a particular endpoint directly inside the POD (Useful when you deploy something but is not working .. you are pulling your hair out and hating kubernetes … keep call and curl it from inside πŸ˜€ )

$ kubectl exec -ti frontend-355436834-whtnp curl http://golang-api/find/1 --namespace=develop

 

Kubernetes – How to proxy a existing InfluxDB pod so you can use it locally:

$ kubectl port-forward --namespace monitoring $(kubectl get pods --namespace monitoring -l app=influxdb-influxdb -o jsonpath='{ .items[0].metadata.name }') 8086:8086

 

GCLOUD: How to list all images for your DockerΒ eu.gcr.io:

gcloud

$ gcloud container images list-tags eu.gcr.io/thomasmodeneis-apps/golang-api

 

HELM DevOps day-to-day tasks and commands

helm

HELM – How to deploy aΒ Docker image from eu.gcr.io to your cluster:

$ export NAMESPACE=develop
$ export VERSION=1.0.0
$ helm upgrade -i golang-api-$NAMESPACE ./helm_chart \ 
--namespace=$NAMESPACE 
--values helm_values/develop.yaml 
--set cluster=clustername,version=$VERSION

 

HELM – How to delete a chart and all its pods

helm delete redis-develop

 

HELM – How to delete a chart and all its pods for a specific namespace:

helm delete redis-develop --namespace=cache-develop

 

HELM – How to delete a chart and all its pods and purge it, in order to also delete PV and PVC’s associated to it: (Caution, this will delete all your data from stored disks).

helm delete redis-develop --purge

 

 

I hope it helps,

 

Happy opensource coding for everyone πŸ˜€

docker, gcloud, golang, kubectl, kubernetes-dedicated, linux, ubuntu

Installing Kubectl with GCloud – Common errors

The Google recommended steps for installing the GCloud and Kubectl are somehow confusing, and I see that often, members of my team are confused and can’t find good enough instructions in order to have this installed correctly.

ERROR 1:Β  Google is not able to enable component manager.Β If you have found this post on google search, chances are that you are stuck with the error.

ERROR: (gcloud.components.update) The component manager is disabled for this installation

ERROR 2:Β Google cant find default credentials

error: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

ERROR 3: Kubectl can’t do anything … error is confusing (what now ?)

➜ kubectl get pods --namespace=develop
 The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

docker_kubernetes

If you have followed the installation instructions forΒ Mac, Ubuntu, Β (and others) Linux distributions chances are that you end-up with a incomplete Β google cloud SDK installation.

kubectl is missing on the default instalation, together few many other important tooling.

 

We will start by listing and learning some useful cheat-sheet commands:

List all availbale components:
$ gcloud components list

Your current Cloud SDK version is: 154.0.1
The latest available version is: 154.0.1

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Components β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Status β”‚ Name β”‚ ID β”‚ Size β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Not Installed β”‚ App Engine Go Extensions β”‚ app-engine-go β”‚ 47.9 MiB β”‚
β”‚ Not Installed β”‚ Bigtable Command Line Tool β”‚ cbt β”‚ 3.9 MiB β”‚
β”‚ Not Installed β”‚ Cloud Datalab Command Line Tool β”‚ datalab β”‚ < 1 MiB β”‚
β”‚ Not Installed β”‚ Cloud Datastore Emulator β”‚ cloud-datastore-emulator β”‚ 15.4 MiB β”‚
β”‚ Not Installed β”‚ Cloud Datastore Emulator (Legacy) β”‚ gcd-emulator β”‚ 38.1 MiB β”‚
β”‚ Not Installed β”‚ Cloud Pub/Sub Emulator β”‚ pubsub-emulator β”‚ 21.0 MiB β”‚
β”‚ Not Installed β”‚ Emulator Reverse Proxy β”‚ emulator-reverse-proxy β”‚ 14.5 MiB β”‚
β”‚ Not Installed β”‚ Google Container Registry's Docker credential helper β”‚ docker-credential-gcr β”‚ 3.4 MiB β”‚
β”‚ Not Installed β”‚ gcloud Alpha Commands β”‚ alpha β”‚ < 1 MiB β”‚
β”‚ Not Installed β”‚ gcloud Beta Commands β”‚ beta β”‚ < 1 MiB β”‚
β”‚ Not Installed β”‚ gcloud app Java Extensions β”‚ app-engine-java β”‚ 128.6 MiB β”‚
β”‚ Not Installed β”‚ gcloud app Python Extensions β”‚ app-engine-python β”‚ 6.1 MiB β”‚
β”‚ Not Installed β”‚ kubectl β”‚ kubectl β”‚ 14.9 MiB β”‚
β”‚ Installed β”‚ BigQuery Command Line Tool β”‚ bq β”‚ < 1 MiB β”‚
β”‚ Installed β”‚ Cloud SDK Core Libraries β”‚ core β”‚ 6.0 MiB β”‚
β”‚ Installed β”‚ Cloud Storage Command Line Tool β”‚ gsutil β”‚ 2.9 MiB β”‚
β”‚ Installed β”‚ Default set of gcloud commands β”‚ gcloud β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


To install or remove components at your current SDK version [154.0.1], run:
 $ gcloud components install COMPONENT_ID
 $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [154.0.1], run:
 $ gcloud components update

 

How to resolveΒ ERROR 1: (gcloud.components.update) The component manager is disabled for this installation:

If you try to use the recommended way to install anything, it will fail and argue something with very little sense like …

ERROR: (gcloud.components.update) The component manager is disabled for this installation

 

 

Solution: Remove the google recommended way of installing the Google Cloud SDK and install it again, this time doing it the right way:

 

  • UBUNTU install steps:
sudo apt-get update
sudo apt-get remove google-cloud-sdk
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init
gcloud components list

Optionally you can run the one liner command :

sudo apt-get remove google-cloud-sdk && curl -sSL https://sdk.cloud.google.com | bash -

 

After installing and initializing the gcloud, you are finally able to install a full-blown Cloud SDK installation:

$ gcloud components install kubectl

Your current Cloud SDK version is: 154.0.1
Installing components from version: 154.0.1

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ These components will be installed. β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Name β”‚ Version β”‚ Size β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ kubectl β”‚ β”‚ β”‚
β”‚ kubectl (Linux, x86_64) β”‚ 1.6.2 β”‚ 14.9 MiB β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

For the latest full release notes, please visit:
 https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)? y

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: kubectl (Linux, x86_64) ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation ═╣
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Performing post processing steps...done. 

Update done

 

After this, you should be able to use gcloud with kubectl. However, you will have to solve more errors … keep reading.

 

GCLOUD Kubectl Common errors:

Problems may raise. One of them is not having the gcloud configs properly set. This will get you an error like this:

How to resolve ERROR 2: GCLOUD is not able to get your credentials, kubectl is blocked:

error: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

This can be fixed by setting the container credentials for the cluster you are wanting to target:

gcloud container clusters get-credentials europa

 

How to resolve ERROR 3: kubectl complains can’t find localhost:8080 (???) Β 

➜ kubectl get pods --namespace=develop
 The connection to the server localhost:8080 was refused - did you specify the right host or port?

To get this solved, you will have to run the gcloud container clusters get-credentials:

gcloud container clusters get-credentials yourclustername
 Fetching cluster endpoint and auth data.
 kubeconfig entry generated forΒ yourclustername.

 

As you can see, there are many things that can go wrong. But we luck you have most of it covered here. Please let me know if you happen to find any other error that is not covered here.

I hope it helps.

Cheers.

linux, ubuntu

How to fix: ERROR: ld.so: object ‘libgtk3-nocsd.so.0’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

This days, after doing a update on Ubuntu, I stumbled upon this error:

ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. 

I’ve looked for answers on the web but there is nothing really specific about it…

I found there is a bug opened on Date: Tue, 10 May 2016 11:27:02 UTC:Β https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=823914

But there is no clear resoliton.

It seems that they have raised a bug for the lib, but I’m not sure how this fixed the issue. There is no comments:Β https://sourceware.org/bugzilla/show_bug.cgi?id=20172

 

The problem seems to be that Ubuntu is looking for a library that does not exist for some reason.

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0

 

So if you check for the file, you won’t find anything:

ls -l /usr/lib/x86_64-linux-gnu/ |grep libgtk3

Fortunately, after a big of dig here and there, I’ve found that there is a quick fix. Execute the following command and install the missing library:Β gtk3-nocsd

$ sudo apt-get install gtk3-nocsd

----- OUTPUT ------
ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following package was automatically installed and is no longer required:
 libgcrypt20:i386
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
 libgtk3-nocsd0
The following NEW packages will be installed:
 gtk3-nocsd libgtk3-nocsd0
0 upgraded, 2 newly installed, 0 to remove and 119 not upgraded.
Need to get 53,0 kB of archives.
After this operation, 125 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://nl.archive.ubuntu.com/ubuntu artful/universe amd64 libgtk3-nocsd0 amd64 3-1 [13,5 kB]
Get:2 http://nl.archive.ubuntu.com/ubuntu artful/universe amd64 gtk3-nocsd all 3-1 [39,5 kB]
Fetched 53,0 kB in 2min 0s (440 B/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package libgtk3-nocsd0:amd64.
(Reading database ... 423877 files and directories currently installed.)
Preparing to unpack .../libgtk3-nocsd0_3-1_amd64.deb ...
Unpacking libgtk3-nocsd0:amd64 (3-1) ...
Selecting previously unselected package gtk3-nocsd.
Preparing to unpack .../gtk3-nocsd_3-1_all.deb ...
Unpacking gtk3-nocsd (3-1) ...
Setting up libgtk3-nocsd0:amd64 (3-1) ...
Setting up gtk3-nocsd (3-1) ...
Processing triggers for libc-bin (2.24-12ubuntu1) ...
Processing triggers for man-db (2.7.6.1-2) ...

 

Check that you have the required file:

ls -l /usr/lib/x86_64-linux-gnu/ |grep libgtk3
-rwSr--r-- 1 root root 26616 jun 1 2016 libgtk3-nocsd.so.0

 

Happy opensource coding for everyone! πŸ˜€

 

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