项目作者: ailispaw

项目描述 :
Kubernetes Cluster on Barge with Vagrant
高级语言: Shell
项目地址: git://github.com/ailispaw/kubernetes-barge.git
创建时间: 2018-05-31T19:16:15Z
项目社区:https://github.com/ailispaw/kubernetes-barge

开源协议:

下载


Kubernetes Cluster on Barge with Vagrant

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

It groups containers that make up an application into logical units for easy management and discovery. Kubernetes builds upon 15 years of experience of running production workloads at Google, combined with best-of-breed ideas and practices from the community.

This repo creates a Kubernetes cluster on Barge with Vagrant locally and instantly.

Requirements

Boot up

  1. $ vagrant up

That’s it.

It will create one Master VM and one Node VM by default.

  1. $ vagrant ssh master
  2. Welcome to Barge 2.13.0, Docker version 18.06.2-ce, build 6d37f41
  3. [bargee@master ~]$ kubectl get nodes
  4. NAME STATUS ROLES AGE VERSION
  5. master Ready master 50s v1.15.0
  6. node-01 Ready <none> 20s v1.15.0
  7. [bargee@master ~]$ kubectl cluster-info
  8. Kubernetes master is running at https://192.168.65.100:6443
  9. KubeDNS is running at https://192.168.65.100:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
  10. To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Create a Sample Pod

  1. [bargee@master ~]$ kubectl create -f /vagrant/samples/sample-pod.yml
  2. pod/sample-pod created
  3. [bargee@master ~]$ kubectl get pods
  4. NAME READY STATUS RESTARTS AGE
  5. sample-pod 1/1 Running 0 11s
  6. [bargee@master ~]$ kubectl get pods -o wide
  7. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  8. sample-pod 1/1 Running 0 23s 10.244.1.2 node-01 <none> <none>
  9. [bargee@master ~]$ kubectl logs sample-pod
  10. [bargee@master ~]$ kubectl exec -it sample-pod bash
  11. root@sample-pod:/# ls
  12. bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
  13. root@sample-pod:/# exit
  14. exit
  15. [bargee@master ~]$ kubectl port-forward sample-pod 8888:80 >/dev/null 2>&1 &
  16. [1] 4600
  17. [bargee@master ~]$ wget -qO- http://localhost:8888
  18. <!DOCTYPE html>
  19. <html>
  20. <head>
  21. <title>Welcome to nginx!</title>
  22. <style>
  23. body {
  24. width: 35em;
  25. margin: 0 auto;
  26. font-family: Tahoma, Verdana, Arial, sans-serif;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <h1>Welcome to nginx!</h1>
  32. <p>If you see this page, the nginx web server is successfully installed and
  33. working. Further configuration is required.</p>
  34. <p>For online documentation and support please refer to
  35. <a href="http://nginx.org/">nginx.org</a>.<br/>
  36. Commercial support is available at
  37. <a href="http://nginx.com/">nginx.com</a>.</p>
  38. <p><em>Thank you for using nginx.</em></p>
  39. </body>
  40. </html>
  41. [bargee@master ~]$ kill 4600
  42. [bargee@master ~]$ kubectl delete -f /vagrant/samples/sample-pod.yml
  43. pod "sample-pod" deleted
  44. [bargee@master ~]$ kubectl get pods
  45. No resources found.

Scale Up

You can add more Nodes to modify the following line in the Vagrantfile.

  1. NUM_OF_NODES = 2

and execute vagrant up node-<n> to boot up an additional node.

  1. $ vagrant up node-02
  1. $ vagrant ssh master
  2. Welcome to Barge 2.13.0, Docker version 17.03.2-ce, build f5ec1e2
  3. [bargee@master ~]$ kubectl get nodes
  4. NAME STATUS ROLES AGE VERSION
  5. master Ready master 4m41s v1.15.0
  6. node-01 Ready <none> 3m57s v1.15.0
  7. node-02 Ready <none> 21s v1.15.0