Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
Vagrantfile Cleanup vagrant folder structure (#437) Jun 19, 2018
cluster.yml Add network LB to vagrant/centos example (#1061) Feb 11, 2019

README.md

Pharos Cluster with Vagrant & CentOS hosts

Pharos Cluster Vagrant setup for local testing using Vagrant and CentOS hosts.

Prerequisities

  • Kontena Pharos toolchain installed locally
  • Vagrant toolchain installed
  • Copy of Vagrantfile and cluster.yml in this directory available locally

Install the latest version of Pharos CLI tool

$ chpharos install --use latest

Quickstart

$ vagrant up
$ pharos up
$ pharos kubeconfig > kubeconfig
$ export KUBECONFIG=kubeconfig
$ kubectl get nodes

Now you cluster is ready to take in your workloads.

Walkthrough

Let's take a look what each of the steps actually does.

$ vagrant up

This will ensure that the virtual machines managed by Vagrant are up-and-running.

$ pharos up

This invokes Pharos CLI tool to setup and configure the Kubernetes cluster according to given cluster.yml file.

$ pharos kubeconfig > kubeconfig

This downloads the configuration file used for accessing the cluster for administrative purposes. This is somewhat analogous to having root access, so keep it safe.

$ export KUBECONFIG=kubeconfig

Sets up the downloaded access configuration to be used by kubectl and other such tools.

$ kubectl get nodes

Lists the nodes taking part in the cluster.

Network LB

In this example we'll also deploy the Kontena Network Loadbalancer addon. It allows easy experimentation with LoadBalancer type services on Kubernetes.

In this example the nodes are allocated with 192.168.110.100-192.168.110.103 addresses. Kontena Network LB will be configured with address pool 192.168.110.110-192.168.110.150.

To test out, let's create first a Deployment for Nginx:

$ kubectl run nginx --image=nginx

Then we need to expose that with a LoadBalancer type Service:

$ kubectl expose deployment nginx --port=80 --type=LoadBalancer

That will make the Network LB to select a free address from the configured pool and make the service available on that address:

$ kubectl get svc
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)        AGE
kubernetes   ClusterIP      172.32.0.1      <none>            443/TCP        4m46s
nginx        LoadBalancer   172.32.34.151   192.168.110.110   80:30464/TCP   11s

We can use the service address directly to access our Nginx deployment:

$ curl 192.168.110.110
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Teardown

Complete teardown:

$ vagrant destroy

This will destroy the VMs and all state related to them.

You can’t perform that action at this time.