Easy Kubernetes Using Ansible! (RKE2)

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 102

  • @TechnoTim
    @TechnoTim 6 місяців тому +41

    Great video! Glad you found some use with the k3s version!

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +10

      Thanks, Tim. Your playbook is awesome, hope to emulate the functionality for RKE2.

  • @DriscollJeff
    @DriscollJeff 2 місяці тому +1

    Success!!! Thank you for the great instruction videos starting with how to use cloud-init, ansible and creating this RKE2 cluster. Now to deploy Rancher.

    • @Jims-Garage
      @Jims-Garage  2 місяці тому

      You're very welcome! Rancher should be easy to install (check my previous scripts or follow their installation instructions), reach out if you need.

  • @_ytuser
    @_ytuser 6 місяців тому +10

    Congratulations on one year milestone🎉 & deepest thanks for tremendously valuable content! 💎✌

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +2

      Thanks, really appreciate that

  • @arne-olafposaasen4601
    @arne-olafposaasen4601 6 місяців тому +4

    Thanks Jim, great video and instructions. I have a Kubernetes cluster up and running on my first attempt - amazing. Would love to see a playbook installing Rancher and Longhorn.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +3

      Thanks, I might get round to that soon. The scripts should still work.

  • @JAMaitim
    @JAMaitim 6 місяців тому +1

    Nice work! Hope we can also see upgrading of kubernetes and components in your playbook soon.😊

  • @subzizo091
    @subzizo091 2 місяці тому +1

    thanks for the great information since you started the channel & best of luck.

    • @Jims-Garage
      @Jims-Garage  2 місяці тому

      @@subzizo091 thanks for the feedback, appreciate it

  • @hyperprotagonist
    @hyperprotagonist 6 місяців тому +3

    Happy anniversary Jim. It’s been an incredible year. Here’s to another fantastic year and growth 🎉

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      Thank you! Appreciate the support.

  • @nahum35
    @nahum35 6 місяців тому +2

    Congrats Jay on first year milestone celebration🥳🎉🥳🎉, deploying RKE2 with the longest video is a great way for this milestone.😉
    Regarding the Kube VIP...
    Do i need it on a brand new environment?
    Is it mandatory?
    what is Kube VIP?
    I'll be happy to hear from you and understand this better.
    Wishing you all the best!

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      It's a virtual IP, it's an IP address shared by all servers. It means you can connect to the VIP and any server can respond. That's why it's highly available.

    • @nahum35
      @nahum35 6 місяців тому

      Thanks 😊

    • @tolpacourt
      @tolpacourt 4 місяці тому

      It's a process that _runs_ on *all* the servers.

  • @elsammael
    @elsammael 5 місяців тому +1

    I've just tested it with Debian 12, seems to be all ok. All nodes are up and running, VIP is replying to ping and MetalLB pods are all running 😄.

    • @Jims-Garage
      @Jims-Garage  5 місяців тому +1

      Phew 😅 thanks for confirming

    • @elsammael
      @elsammael 5 місяців тому

      @@Jims-Garage Just one thing though: should the playbook use the kube-vip IP address instead of the Ip address of server 1 in .kube config (during the task change IP from local to server 1 IP)?

  • @haraldfielker4635
    @haraldfielker4635 6 місяців тому +2

    @jim you need to find a way to add a galaxy.yml file to your roles (or reploy it to the official galaxy servers). k8s deployment is always part of some "bigger" thing, where your scripts are just one part. I did that for Tims k3s roles. In the real world you need to install VMs / prepare the bare metal systems - and after - k8s is installed, you need to install more stuff. If you want to be your part the "middle thing" that is used be a lot of people - add the galaxy :)

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Thanks, I will certainly look into that (my dev skills are a little rusty though!).

  • @rudypieplenbosch6752
    @rudypieplenbosch6752 6 місяців тому +1

    I had some problems with the previous Rke2 script, glad you were talking about sync issues not being handled correctly before, this is pretty difficult stuff, hope it will work, will try tomorrow. 👍

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Great, fingers crossed 🤞

    • @rudypieplenbosch6752
      @rudypieplenbosch6752 6 місяців тому +1

      @@Jims-Garage Hi Jim, there is something not right with these scripts, I have a cluster that works, but only 1 masternode is running and 2 workernodes. On the nodes that have not joined the cluster, seems Kubectl is not installed, when i try kubectl get nodes on them. At the end of your script it seems everything is ok, however two nodes have not been installed properly (running kubectl on them points me to install with apt..), seems some omission in your script that doesn't check for this installation status. I will try to find where this can happen, i tried deleting the two missing nodes and run yoir script again, the system ends up in the same state, no HA, only 1 masternode, kubectl doesn't run on 2 failing masternodes.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      @@rudypieplenbosch6752 kubectl doesn't run, it's a binary for executing commands against a cluster. It's installed on all nodes by default, I just didn't map it to the user space on mn2 and mn3.
      How long did you wait for 2&3 to show up? It can take a while. I'm unable to replicate your issue with the script, it works every time for me. Any more info on your setup would be useful. Perhaps pop into Discord.

    • @rudypieplenbosch6752
      @rudypieplenbosch6752 6 місяців тому +1

      @@Jims-Garage Thanks for your answer. Yes, i meant the Kubectl binary is not installed on those two nodes (since using that command on those nodes, pointed towards "you can install Kubectl with..., standard linux info"). Ok, so i can fix this by mapping it to userspace on the two nodes that don't join ? I waited a very long time, more than an hour, there was no attempt from either pod to join the cluster. I can see a big download starts on both pods, after i deleted both pods and start with fresh clones and run your script again, but even after an hour i see no chsnge in the cluster, just 3 ready pods, 1 master, two worker pods. How do i map it to userspace ?

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      @@rudypieplenbosch6752 look at the playbook, kubectl is downloaded as part of RKE2. I forget the location but it's there (playbook will show you). You can copy to /usr/local/bin and should be accessible to all with the right permissions.

  • @OutOfMySystem
    @OutOfMySystem 6 місяців тому

    Great stuff! Lot of effort clearly went into this.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Thanks a ton! Yes, took quite a while!

  • @BrynnHarrison66
    @BrynnHarrison66 6 місяців тому +1

    You can supply your own cluster token if you wish, that way you don't have to wait for it to be created. It only creates a random token if you don't supply it

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      Thanks, yes I am aware of that. Was wondering whether to add as a variable or not. In the end decided not to as it means it'll be strong by default. Guess I could add a check to see if the user supplied one and if not generate one.

  • @demorez5
    @demorez5 6 місяців тому +3

    "don't wanna compete with TechnoTim" - sips beer CraftComputing style :D

  • @torgrimt
    @torgrimt 6 місяців тому +2

    Next series on talos? no need for ansible or the heavy os undeneath. Trying it out in my homelab now

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Thanks, yes, I've been playing with Talos. It's a great tool. Immutability is a blessing and a curse haha

  • @agusawaludin4447
    @agusawaludin4447 3 місяці тому +1

    Thank for the video, and plese tell me how to clean up all the rke installation from the server ? :)

    • @Jims-Garage
      @Jims-Garage  3 місяці тому

      @@agusawaludin4447 there's an uninstall script that comes with RKE2. Check in the /etc/rancher folder

  • @Ole-Endurance
    @Ole-Endurance 6 місяців тому +2

    Thanks Jim - great scripts worked on the first try.
    One remark: the folder tasks for prepare-nodes is missing - currently no preperation would be done (if just copying your folderstructure)
    Question: my ubuntu typically has no iptables installed but without rke is not running (at least I get error messages) - so why not just install iptables as prepare step. If already there fine if not is is guaranteed to be there. Using Ubuntu 24.04 minimal cloud image.
    Hint: similar for qemu-guest-agent I would simply install it. But yes makes only sense in a qemu env.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      Thanks, you're the first to say it works haha. As mentioned I only tested on 23, 24 is quite broken so I'm avoiding it. On 23 it works without any other dependencies. I will look to add stuff to support other OS as required. A pr would be great 👍

    • @Ole-Endurance
      @Ole-Endurance 6 місяців тому +1

      @@Jims-Garage Happy to be the first :) Was perfect timing as I just used the script version and I anyway wanted to switch o ansible. Thanks again for your work.
      iptables I had to add also on ubuntu 22 minimal.
      24 is of course super new but LTS, so I will slowly move to it. Might create a PR but - honestly need to figure out how first :) - last time I used version control system is maaaannnnyy years back.

    • @Ole-Endurance
      @Ole-Endurance 6 місяців тому +1

      @@Jims-Garage Did another test on a different hardware platform (first was on i9 with NVME now DL380 with lots of RAM but spinning disks - also CPU (E5-2640) is single threaded slow compared to a i9).
      Randomly not working :(, most likely due to high iowait. Maybe it makes sense to have at least the first master completely ready before spinning up the other nodes.
      Could be also a good idea to add workers/masters later on using seperate ansible playbook. So start small and then grow as you need.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      @@Ole-Endurance thanks for the feedback. Interesting, it does wait for API, then server 1 to be ready before doing anything further. Can you paste some logs or output on discord?

  • @javisartdesign
    @javisartdesign 6 місяців тому +2

    well done, thanks for explain all the steps. Does the ansible spcript idempotence in the sense we can reexecute the script if something in the middle failed?

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Yes, I believe so but I need lots of testing.

  • @chillgates_
    @chillgates_ 6 місяців тому +4

    This is likely going to be a legendary video so I sought to comment in case it turns top comment :D Kubernetes ftw!! goooo jim!! :')

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Haha, thanks! I'm rooting for you...

  • @motionthings
    @motionthings 6 місяців тому +1

    Have you looked at Harvester, the bare metal OS that's made by the Rancher and Longhorn devs?

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      I have, it's a cool technology but not something I want to run at home. Essentially Kubernetes in Kubernetes.

  • @carlosgarcia1165
    @carlosgarcia1165 5 місяців тому +1

    hi there, I have a suggestion for a video. Could you give a definitive explanation of an scenario with the proper tools where rke2 can have security?
    I am on my way to have k8s with rke2 v1.28. I managed to have this running thanks to your videos and others: rke2 - metallb - longhorn - postgres-oprator - kong using postgres - Rancher. I am on my way to deploy knative for the serverless, and istio oc. I am using Ansible, Vagrant, Packer, plus MAAS to manage all of these.
    The thing is that I am missing the security stack and firewall. I have read about NeuVector, authentik, keycloak, stackrox, stig, wazuh, and Crowdsec. But to be honest I don't know where to start, and where to end. I need help from the pros to decide my security/firewall security for my staing and prod clusters. I think this would make a great video :)

    • @Jims-Garage
      @Jims-Garage  5 місяців тому +1

      Good questions and I have already covered most of this. I have videos on most of that stuff. I would start out with a firewall (Sophos XG is very simple, but OPNSense is more popular in homelabbing). Then put something like Traefik with Crowdsec. I would also put stuff on their vLANs, especially for internet facing things to create a virtual DMZ.

  • @subzizo091
    @subzizo091 2 місяці тому +1

    a question please, is the same script will run with rocky linux and what if i need just 1 master and 2 workers "due to lack of resources :)" thanks for much

    • @Jims-Garage
      @Jims-Garage  2 місяці тому

      @@subzizo091 I haven't tested rocky so let me know (should be a case of just adding any missing dependencies to the top).
      You could amend the number of nodes as well by simply modifying the numbers in the groups (I think)

  • @tolpacourt
    @tolpacourt 4 місяці тому +2

    Do the hostnames of the VMs need to match what you named these servers in the Ansible? I have a bunch of VMs set up in DNS but they are not named "server1," "server2," etc. in DNS. Also, I'm getting errors regarding passwords. This latest version of RKE2 stores a password in /etc/rancher/node/password. I'm seeing errors like,
    "Node password rejected, duplicate hostname or contents of '/etc/rancher/node/password' may not match server node-passwd entry, try enabling a unique node name with the --with-node-id flag" "

    • @Jims-Garage
      @Jims-Garage  4 місяці тому +1

      @@tolpacourt node names don't matter, this is just a reference inside the playbook.
      I'm not familiar with that error, perhaps something has changed since my video. Might be worth pinning the version.

    • @tolpacourt
      @tolpacourt 4 місяці тому +1

      @@Jims-Garage I have RKE v1.29.4+rke2r1, just like your Ansible config specifies. I did update the kube-vip version to v0.8.1 from what you had, v0.8.0. I'll try 0.8.0 kube-vip.

    • @Jims-Garage
      @Jims-Garage  4 місяці тому

      @@tolpacourt which OS?

    • @tolpacourt
      @tolpacourt 4 місяці тому

      I had a duplicate host name in one of my hosts i.e. two of my worker nodes had the same hostname but different IP addresses. Bleh.

  • @ctroyp
    @ctroyp 6 місяців тому +1

    How were you able to successfully deploy Rancher on RKE2 1.29.4 if it is not compatible? Helm deploy failed as it was not compatible with 1.29.x.
    Thanks so much for this walkthrough!

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      It was already installed on an earlier version then I upgraded the Kubernetes version (it works from what I can see but I don't recommend it).

    • @ctroyp
      @ctroyp 6 місяців тому

      @@Jims-Garage Just noticed that tasks in the 'prepare-nodes' play are not being executed. HTH

  • @BrynnHarrison66
    @BrynnHarrison66 6 місяців тому +1

    Can you verify something for me please as I was having issues with the kernel parameters being applied.
    should the main.yaml file in Ansible/Playbooks/RKE2/roles/prepare-nodes directory be in a tasks subdirectory like the other roles? I couldn't get the kernel parameters to be applied without it.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      Well spotted, yes it should. Fixing now.

    • @BrynnHarrison66
      @BrynnHarrison66 6 місяців тому +1

      @@Jims-Garage This is my first pass at installing RKE2 with Ansible. I'm learning lots, thanks to you. Cheers

  • @dracula172
    @dracula172 5 місяців тому +1

    Hello, sorry coz maybe it sounds silly but about prerequisites, are you using 5 virtual machines? each of one has 4GB RAM and 4 cores? first time i see procmox i always use virtual box or vmware.

    • @Jims-Garage
      @Jims-Garage  5 місяців тому +1

      Correct, 5 VMs. Your choice of hypervisor shouldn't matter albeit I recommend Proxmox over virtual box. VMware is good, but costs for a licence, you'll see most people in the homelab space using Proxmox.

    • @dracula172
      @dracula172 5 місяців тому

      @@Jims-Garage Thank you so much to answer! I know so little about this tecnologies, i dont know if i get this right, you create a node in each VM? i ve only worked with clusters inside of 1 VM, i create 2 o 3 nodes. If you could tell me in the simpliest way what you achieve using 5 VMs and with the playbook (english is not my first language 😅.

  • @MrSziman
    @MrSziman 3 місяці тому +1

    Hi Jim,
    Great vidoe and I've learend alot!!
    I've tried to deploy RKE with Ansibale playbook. I'm using 5 AWS machines. 1 is the master. 3 servers and 2 agents. all the machines are Ubuntu server 24.04
    No error appear and it's seems that the deploy successed
    ed
    at the end on server 1 only one node appear: control-plane,etcd,master
    Is there any configuration is needed in rke2-server-config.j2 or rke2-agent-config.j2 in order to see all nodes?
    Thanks alot!
    Shahar

    • @Jims-Garage
      @Jims-Garage  3 місяці тому

      Thanks. How long have you waited? The nodes should take a few minutes to pop up. (Make sure you have enough storage space as well!).

    • @MrSziman
      @MrSziman 3 місяці тому

      @@Jims-Garage i still not see them.
      I have about 10% of free diskspace
      Thanks

    • @Jims-Garage
      @Jims-Garage  3 місяці тому

      @@MrSziman you might not have enough space on the devices for them to download the necessary containers. Create more space and try again.

    • @MrSziman
      @MrSziman 3 місяці тому

      @@Jims-Garage I will try to add more space. I will update regard the results.
      Cheers 🤟

  • @anand-nb4bb
    @anand-nb4bb 6 місяців тому +1

    Hi Bro can you please make a tutorial video explaining in a very simple way on writing a Ansible file. I am new to ansible & I am not from a programming background or DevOps so don't understand the indentation spacing's , Curly Brackets , Variables, loops etc when creating the Ansible

    • @jdratlif
      @jdratlif 6 місяців тому +3

      He has a full play list on ansible. You're watching the most recent video in it.
      ua-cam.com/play/PLXHMZDvOn5sW-EXm2Ur5TroSatW-t0Vz_.html

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Thanks for linking

    • @Jims-Garage
      @Jims-Garage  6 місяців тому

      Yes, I have a series on all of that.

  • @CelebrateJoyOfLife
    @CelebrateJoyOfLife 2 місяці тому

    Could not make it work with Ubuntu Server 24.04.1 on HyperV. TASK [rke2-prepare : Wait for kubectl] fails. Somehow, I do not see kubectl file anywhere when all steps till that step were successful on Server1. I just cant make RKE2 work even on a single server.

  • @mnededeejay
    @mnededeejay 5 місяців тому +1

    would it be possible to add a reset/destroy cluster playbook?

    • @Jims-Garage
      @Jims-Garage  5 місяців тому

      Good suggestion, something I'll consider for later. There's a script from rancher you can run anyway that ships with it.

  • @tolpacourt
    @tolpacourt 4 місяці тому

    "Waiting to retrieve agent configuration; server is not ready: Node password rejected, duplicate hostname or contents of '/etc/rancher/node/password' may not match server node-passwd entry, try enabling a unique node name with the --with-node-id flag"

    • @tolpacourt
      @tolpacourt 4 місяці тому

      I had two worker nodes with the same hostname. Different IP addresses, same hostname. Bad!

  • @tolpacourt
    @tolpacourt 4 місяці тому

    I have a bunch of pods that don't seem right. Do I need to run these playbooks again?
    helm-install-rke2-canal-wkggx 0/1 Completed 0 13m
    helm-install-rke2-coredns-l8f98 0/1 Completed 0 13m
    helm-install-rke2-metrics-server-m6kml 0/1 Completed 0 13m
    helm-install-rke2-snapshot-controller-crd-s5r85 0/1 Completed 0 13m
    helm-install-rke2-snapshot-controller-zphhc 0/1 Completed 0 13m
    helm-install-rke2-snapshot-validation-webhook-7smss 0/1 Completed 0 13m

    • @tolpacourt
      @tolpacourt 4 місяці тому

      OK. Apparently these are not broken. I checked the pod logs and see no errors.

  • @michaelwentzell9809
    @michaelwentzell9809 6 місяців тому +1

    Doesn't work for me, configured everything just as in the video and it gets hung up on fact gathering.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      That's interesting. What OS are you using?

    • @michaelwentzell9809
      @michaelwentzell9809 6 місяців тому +1

      @@Jims-Garage my apologies Jim, I was just exhausted going on 7 hours trying to troubleshoot deploying the cluster. I believe I’m using the most up to date Ubuntu Server from the official website, however looking at your videos, especially the cloud-init one, maybe lunar is the best bet especially with KVM considering. Do you think this would inhibit the provisioning?

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      @@michaelwentzell9809 I mentioned at the start this is only tested on 23.04 non KVM. I don't use KVM image as it often causes problems. Try with the one I mentioned and see how you get on.

    • @michaelwentzell9809
      @michaelwentzell9809 6 місяців тому

      @@Jims-Garage ohhhh man how could I have missed that!

    • @michaelwentzell9809
      @michaelwentzell9809 6 місяців тому

      @@Jims-Garage thanks Jim! I’ll try this right away and get back to you! I was gonna say, I think Lunar had reached EOL for support as well

  • @supernerd6983
    @supernerd6983 5 місяців тому +1

    Got this working!! Do I need to install a cni for this or was that included in the script?

    • @Jims-Garage
      @Jims-Garage  5 місяців тому +1

      It's part of the deployment, uses flannel by default.

  • @BrynnHarrison66
    @BrynnHarrison66 6 місяців тому +1

    Could I make a suggestion regarding the rke2-server-config.j2 template. I notice you have one for the 1st (bootstrap) server and another one for the subsequent servers added to the cluster. The only difference being, the addition of server and token lines . I use the same template but have a '#' at the beginning of the server and token lines, effectively commenting them out. This is used as-is for the bootstrap server, then simply remove the '#' when it is copy it to server nodes 2 & 3.
    Great work by the way.

    • @Jims-Garage
      @Jims-Garage  6 місяців тому +1

      Thanks, yes I will consider that 👍