11. Kubernetes setup
Prev |  | Next

# 11. Kubernetes setup

## 11.1 Kubernetes CLI Installation

First you’ll need to install the `kubectl` CLI.

### 11.1.1 Script Installation

You can use the `tools/k8s-helper.sh` script to install `kubectl`. Just call

    $ ./tools/minikube-helper download-kubectl

and then the `kubectl` will get downloaded

### 11.1.2 Manual Installation

Example for OSX

    $ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl
    $ chmod +x ./kubectl
    $ sudo mv ./kubectl /usr/local/bin/kubectl

Example for Linux

    $ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
    $ chmod +x ./kubectl
    $ sudo mv ./kubectl /usr/local/bin/kubectl

Check out this page for more information.

## 11.2 Kubernetes Cluster setup

We need a cluster of Kubernetes. The best choice will be Minikube.

| Tip
You can skip this step if you have Kubernetes cluster installed and don’t want to use Minikube The only thing you have to do is to set up spaces.

| Warning
It’s more than likely that you’ll run out of resources when you reach stage step. Don’t worry! Keep calm and clear some apps from Minikube and continue.

### 11.2.1 Script Installation

You can use the `tools/k8s-helper.sh` script to install `Minikube`. Just call

    $ ./tools/minikube-helper download-minikube

and then the `Minikube` cluster will get downloaded

### 11.2.2 Manual Installation

Example for OSX

    $ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.20.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Feel free to leave off the `sudo mv minikube /usr/local/bin` if you would like to add minikube to your path manually.

Example for Linux

    $ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.20.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Feel free to leave off the `sudo mv minikube /usr/local/bin` if you would like to add minikube to your path manually. Check out this page for more info on the installation.

## 11.3 Run Minikube

Just type in `minikube start` to start Kubernetes on your local box.

To add the dashboard just execute `minikube dashboard`

## 11.4 Certificates and Workers

### 11.4.1 Minikube Certificates and Workers

By default if you install Minikube all the certificates get installed in your `~/.minikube` folder. Your `kubectl` configuration under `~/.kube/config` will also get updated to use Minikube.

### 11.4.2 Manual Certificates and Workers Setup

| Important
If you just want to run the default, demo setup you can skip this section

To target a given Kubernetes instance one needs to pass around Certificate Authority key and also user keys.

You can read more about the instructions on how to generate those keys here. Generally speaking if you have a Kubernetes installation (e.g. `minikube`) this step has already been done for you. Time to reuse those keys on the workers.

Extracted from the official docs.

Configure kubectl to connect to the target cluster using the following commands, replacing several values as indicated:

- Replace `${MASTER_HOST}` with the master node address or name used in previous steps
- Replace `${CA_CERT}` with the absolute path to the `ca.pem` created in previous steps
- Replace `${ADMIN_KEY}` with the absolute path to the `admin-key.pem` created in previous steps
- Replace `${ADMIN_CERT}` with the absolute path to the `admin.pem` created in previous steps

    $ kubectl config set-cluster default-cluster --server=https://${MASTER_HOST} --certificate-authority=${CA_CERT}
    $ kubectl config set-credentials default-admin --certificate-authority=${CA_CERT} --client-key=${ADMIN_KEY} --client-certificate=${ADMIN_CERT}
    $ kubectl config set-context default-system --cluster=default-cluster --user=default-admin
    $ kubectl config use-context default-system

## 11.5 Generate Minikube namespaces

With the running Minikube cluster we need to generate namespaces. Just execute the `./tools/k8s-helper.sh setup-namespaces` to do this.

Prev |  | Next
10. Jenkins FAQ | Home | 12. The demo setup (Cloud Foundry)