pmfl
pmfl

Reputation: 2109

Installing Kubernetes on Virtual box with Ubuntu

I am trying to install Kubernetes on Ubuntu 16.04 VM, I tried this https://kubernetes.io/docs/getting-started-guides/kubeadm/, but the API server does not start.

The connection to the server localhost:8080 was refused - did you specify the right host or port?

Is there a good procedure on how to install Kubernetes on Ubuntu VM

Upvotes: 2

Views: 3024

Answers (3)

Velkan
Velkan

Reputation: 7602

You probably haven't set up the credentials for kubectl.

sudo cp /etc/kubernetes/admin.conf $HOME/ && sudo chown $(id -u):$(id -g) $HOME/admin.conf; if ! fgrep -q KUBECONFIG= $HOME/.bashrc; then echo 'export KUBECONFIG=$HOME/admin.conf' >> $HOME/.bashrc; fi;. $HOME/.bashrc

It takes /etc/kubernetes/admin.conf to the home directory and makes it readable by current user. Also adjusts .bashrc to set the KUBECONFIG environment variable to point to that admin.conf.

Upvotes: 3

dirtyqwerty
dirtyqwerty

Reputation: 305

I was unable to set up kubernetes on Ubuntu VM on Windows host using Oracle VM VirtualBox. See https://www.virtualbox.org/ticket/4032.

I switched to VMWare Workstation 12 (free not Pro) to use Kubernetes. Taking backups has gotten more tedious as exporting to ovf is available only with Pro. Kubernetes works fine

Upvotes: 0

Crazykev
Crazykev

Reputation: 412

In current version of kubeadm(v1.6.1), insecure port of ApiServer is abandoned by default, you can verify this by checking api-server yaml file in /etc/kubernetes/manifests/kube-apiserver.yaml, there is kube-apiserver parameter --insecure-port=0.

You can

  • Correct this in a running cluster:

    $ mv kube-apiserver.yaml ../kube-apiserver.yaml
    // edit ../kube-apiserver.yaml to remove --insecure-port=0 
    // or change it to --insecure-port=<WHATERER_YOUR_LIKE>
    $ mv ../kube-apiserver.yaml kube-apiserver.yaml
    
  • Do it right at startup. You need a kubeadm config file to do this. A simple one would like:

    apiVersion: kubeadm.k8s.io/v1alpha1
    kind: MasterConfiguration
    apiServerExtraArgs:
      insecure-port: 8080 //or whatever you like
    
    // Then you can start a master node use `kubeadm init --config=<this-configure-file-path>`
    

Upvotes: 0

Related Questions