Git Product home page Git Product logo

k3s's Introduction

k3s

Automated setup of a k3s cluster with 1 master and n compute-nodes.

Warning

I only tested this on my local cluster running on 6 ODROID-MC1 Solo. I run them with Armbian buster (Linux 5.4.28-odroidxu4) So use this at your own risk!

Setup

$ cd setup
$ # update inventory to your needs
$ ansible-playbook -i inventory.yaml prep.yaml 
$ ansible-playbook -i inventory.yaml create_cluster.yaml

To connect to the cluster, copy the kube-config from the k3s-master to your local machine.

# assuming you have passwordless sudo, which you're gonna need for ansible either way
$ ssh user@master "sudo cp /etc/rancher/k3s/k3s.yaml /home/<user>/k3s.yaml && sudo chown <user>:<group> /home/<user>/k3s.yaml"
$ scp <user>@<master>:k3s.yaml .
$ ssh user@master "rm -f /home/<user>/k3s.yaml"

Update k3s.yaml by replacing server: https://127.0.0.1:6443 with the actual servername server: https://<mastername or -ip>:6443 Afterwards you should be able to connect to your cluster, using k3s.yaml kube-config.
You can test it with:

$ kubectl --kubeconfig=k3s.yaml get nodes

Test the functionality

In deploy you can find a directory called test, which contains a simple deployment for nginx with a service and an ingress. You can deploy it, to see if your cluster is working properly.

$ kubectl apply -f deploy/test/
# Verify the deployment
$ kubectl get all -n test
# You should get an output similar to this:
NAME                              READY   STATUS    RESTARTS   AGE
pod/nginx-test-6ddd567766-9vdm5   1/1     Running   0          103m

NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/nginx-test   ClusterIP   10.43.25.181   <none>        80/TCP    103m

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx-test   1/1     1            1           103m

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-test-6ddd567766   1         1         1       103m

If this worked, update /etc/hosts to make example.com point to the IP of your master. Now open http://example.com in your Browser and check, if you can see the default NGINX-homepage. Alternatively you can test from the cli using this command

$ curl example.com 2>/dev/null |grep "Welcome to nginx\!" || echo "Failed"
# Good
<title>Welcome to nginx!</title>
<h1>Welcome to nginx!</h1>
# Bad
Failed

Now you're good to go. Have fun with your k3s-cluster!

k3s's People

Contributors

devoops0 avatar qm3ster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

qm3ster robvor

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.