2019-09-19 15:30:23 -04:00
2019-10-26 21:41:51 -04:00
2019-09-25 13:49:45 -04:00
2019-09-12 11:15:04 -04:00
2018-09-17 07:08:14 -05:00
2019-09-23 14:29:58 -04:00
2019-10-26 21:41:51 -04:00
2019-10-27 00:08:47 -04:00
2019-09-03 13:21:21 -04:00
2018-09-02 17:25:15 -05:00
2019-10-09 08:18:31 -04:00
2019-10-26 22:12:48 -04:00

Kubernetes cluster

A Vagrant script for setting up a barebones Kubernetes cluster with a load-balancer and dynamic provisioner using Kubeadm.

Pre-requisites

  • Vagrant 2.2.4+

  • Virtualbox 6+

  • Do NOT install the proprietary extension pack from Oracle - it is non-free and they have started to track IP addresses and demand license fees.

  • Do NOT use Powershell ISE - when attempting to SSH, ISE will lockup. Please use CMD/Powershell or a *nix OS.

Start the Base Cluster

Run the following command using CMD/Powershell in the dir where your Vagrantfile lives.

vagrant up
  • When this command finishes you will have (4) running VMs joined together as a K8s cluster.
  • If more than three worker nodes are required, you can edit the servers array in the Vagrantfile
servers = [
    {
        :name => "k8s-node3",
        :type => "node",
        :box => "ubuntu/bionic64",
        :eth1 => "192.168.205.13",
        :mem => "2048",
        :cpu => "2"
    }
]
  • As you can see above, you can also configure a static IP address, memory and CPU in the servers array.

Check Cluster Health

PS> vagrant ssh k8s-head
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-38-generic x86_64)
 
<snip output>
vagrant@k8s-head:~$ kubectl cluster-info
Kubernetes master is running at https://192.168.205.10:6443
KubeDNS is running at https://192.168.205.10:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
 
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
 
vagrant@k8s-head:~$ kubectl get nodes
NAME        STATUS   ROLES    AGE   VERSION
k8s-head    Ready    master   68m   v1.15.2
k8s-nfs     Ready    <none>   53m   v1.15.2
k8s-node1   Ready    <none>   65m   v1.15.2
k8s-node2   Ready    <none>   61m   v1.15.2

Install NFS Provisioner

vagrant@k8s-head:~$ kubectl taint nodes k8s-nfs key=value:NoSchedule
node/k8s-nfs tainted
vagrant@k8s-head:~$ kubectl apply -f \
https://raw.githubusercontent.com/jprdonnelly/kubernetes-cluster/master/nfs-provisioner/nfs-helm-pvc.yaml
persistentvolume/nfs-provisioner-vol created
vagrant@k8s-head:~$ helm install -n nfs stable/nfs-server-provisioner \
-f https://raw.githubusercontent.com/jprdonnelly/kubernetes-cluster/master/nfs-provisioner/nfs-helm-values.yaml
NAME:   nfs
LAST DEPLOYED: Mon Sep  9 12:59:26 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ClusterRole
NAME                        AGE
nfs-nfs-server-provisioner  1s

==> v1/ClusterRoleBinding
NAME                        AGE
nfs-nfs-server-provisioner  1s

==> v1/Pod(related)
NAME                          READY  STATUS   RESTARTS  AGE
nfs-nfs-server-provisioner-0  0/1    Pending  0         1s

==> v1/Service
NAME                        TYPE       CLUSTER-IP     EXTERNAL-IP  PORT(S)                                 AGE
nfs-nfs-server-provisioner  ClusterIP  10.105.237.23  <none>       2049/TCP,20048/TCP,51413/TCP,51413/UDP  1s

==> v1/ServiceAccount
NAME                        SECRETS  AGE
nfs-nfs-server-provisioner  1        1s

==> v1/StorageClass
NAME                   PROVISIONER            AGE
nfs-dynamic (default)  provisioner.local/nfs  1s

==> v1beta2/StatefulSet
NAME                        READY  AGE
nfs-nfs-server-provisioner  0/1    1s


NOTES:
The NFS Provisioner service has now been installed.

A storage class named 'nfs-dynamic' has now been created
and is available to provision dynamic volumes.

You can use this storageclass by creating a `PersistentVolumeClaim` with the
correct storageClassName attribute. For example:

    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: test-dynamic-volume-claim
    spec:
      storageClassName: "nfs-dynamic"
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 100Mi
vagrant@k8s-head:~$ kubectl apply -f \
https://raw.githubusercontent.com/jprdonnelly/kubernetes-cluster/master/nfs-provisioner/nfs-class.yaml
storageclass.storage.k8s.io/nfs-dynamic configured

Clean-up

Execute the following command to remove the virtual machines created for the Kubernetes cluster.

vagrant destroy -f

You can destroy individual machines by

vagrant destroy k8s-node3 -f
Licensing

Apache License, Version 2.0.

Description
No description provided
Readme Apache-2.0 424 KiB
Languages
Dockerfile 76.7%
Shell 23.3%