Code Monkey home page Code Monkey logo

kubernetes-localhost's Introduction

kubernetes-localhost

asciicast Deploys Kubernetes with loadbalancer, dashboard & persistent storage on local machine using Vagrant.

By default you get 1 master, 2 working nodes, NFS server, loadbalancer, and deployed dashboard.

Version of deployed Kubernetes cluster is 1.18, version of Ubuntu VirtualBox image is 18.04.

Persistent volume pv-nfs and 5GB persistent volume claim pvc-nfs are provided automatically. For examples on how to use/create your own pv/pvc, check storage directory.

For bare-metal loadbalancing purposes MetalLB is used.

Dashboard is available via port 30000 on worker nodes. If you didn't change network ip range or number of worker nodes in Vagrantfile, dashboard will be available on both:

Dashboard Example

Note: In order to access dashboard via Chromium based browsers, you'll have to bypass invalid error certificate error on above mentioned URLs. In order to do that, just type thisisunsafe while on dashboard page. You don't need any input field, just typing it while on that page will do the trick.

Requirements

Note: Vagrantfile uses ansible_local module, which means you don't need Ansible installed on your workstation. However, if you already have it installed, and prefer to use that instead of letting Vagrant install Ansible on each node separately, change *vm.provision from ansible_local to ansible in Vagrantfile.

Another option is having dedicated "controller" node, which can be used as Ansible host. You can learn more by visiting this link.

How-To Manual

New setup:

  • Clone this repository
  • Run vagrant up

Poweroff machines:

  • Run vagrant halt

Checking nodes status:

  • Run vagrant status

Accessing master/worker nodes:

  • While in project directory, type:
vagrant ssh $NAME_OF_THE_NODE

Example:

vagrant ssh k8s-master

Using kubectl from local workstation without SSH-ing via Vagrant

  • Create dedicated config directory in local .kube directory
# Create directory in which you're going to store Kubernetes config
mkdir -p ~/.kube/kubernetes-localhost
# Copy file from Kubernetes master
scp -i ~/.vagrant.d/insecure_private_key [email protected]:~/.kube/config ~/.kube/kubernetes-localhost

Note: In case you redeploy cluster, you'll have to remove previous entry from .ssh/known_hosts or you'll get WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! warning, you can use this command for example: sed -i "/192.168.100.100/d" ~/.ssh/known_hosts

  • You can now access Kubernetes cluster without sshing into Vagrant box:

kubectl --kubeconfig=/home/$USER/.kube/kubernetes-localhost get pods --all-namespaces

Optional: Create alias in configuration file of your shell, for example:

# Open rc file
vim ~/.zshrc
# Insert alias
alias kubectl_local='kubectl --kubeconfig=/home/$USER/.kube/kubernetes-localhost'
# Save and exit Vim (can't help you there), and reload config
source ~/.zshrc
# Test
kubectl_local get pods --all-namespaces

Obtaining token for Dashboard access

  • Check for secret name
kubectl get secrets -n kube-system | grep 'dashboard'
# Example:
kubectl describe secret/dashboard-access-token-mb7fw -n kube-system
  • Navigate to one of above mentioned URLs and paste it in there

Delete setup:

  • Run vagrant destroy -f
  • Remove repository

kubernetes-localhost's People

Contributors

ajvn avatar garyttt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.