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.

Advertisements
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)

docker, gcloud, linux

Installing Google App Engine gcloud on Linux

If followed the Google recommended steps described on Google for installing the Google App Engine SDK, chances are that it failed just after when you tried to install kubectl or something else like goapp or the java cmds. 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\

 

If you have followed the installation instructions for  Ubuntu (and others) Linux distributions come with the google cloud SDK installed through the local package manager, but is a trap, and doesn’t contain everything you will need to get things done.

kubectl is missing on the default instalation, together with many others.

$ 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

 

And 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

error_meme1

 

In order to get this sorted out, the solution is fairly easy. You will have to remove the google recommended way of installing the Google Cloud SDK  and proceed with the following 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 and Get yourself 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

 

Installing Google App Engine for Golang

gcloud components install app-engine-go


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

┌────────────────────────────────────────────────────┐
│ These components will be installed. │
├───────────────────────────────┬─────────┬──────────┤
│ Name │ Version │ Size │
├───────────────────────────────┼─────────┼──────────┤
│ App Engine Go (Linux, x86_64) │ 1.9.50 │ 47.9 MiB │
│ App Engine Go Extensions │ │ │
│ gcloud app Python Extensions │ 1.9.52 │ 6.1 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: App Engine Go (Linux, x86_64) ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go Extensions ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud app Python Extensions ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done. 

Update done!

 

Installing Google App Engine for Java

$ gcloud components install app-engine-java


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

┌──────────────────────────────────────────────────┐
│ These components will be installed. │
├────────────────────────────┬─────────┬───────────┤
│ Name │ Version │ Size │
├────────────────────────────┼─────────┼───────────┤
│ gcloud app Java Extensions │ 1.9.51 │ 128.6 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: gcloud app Java Extensions ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done. 

Update done!

 

I hope it helps.

Cheers.