Discover the comprehensive K3OS configure network guide. Learn step-by-step processes, best practices, and advanced tips for optimal network setup and management in K3OS. #centlinux #linux #k8s
Table of Contents
What is k3OS?
This is a supplementary article to Install Lightweight Kubernetes (K3s) Cluster with k3OS, where we have seen, how to configure a Kubernetes cluster with k3OS operating system. k3OS is purposely built for lightweight Kubernetes (k3s), therefore, it has limited tools and configurations, that are mandatory to run Kubernetes.
We have accepted all the default network options as provided by Installation process during configuration of k3OS. However, if you are not happy with default DHCP assigned IP Addresses and Hostname, then you can change it as per the following procedures.
Identify Network in k3OS
k3OS network is powered by connman. Therefore, we can use connmanctl command to manage our network.
But, first we have to identify the connman network service bound to eth0 device.
$ sudo connmanctl services *AO Wired ethernet_000c29eeaf0e_cable *AR Wired ethernet_aae0cd9b094b_cable *AR Wired ethernet_da9d68a358a4_cable *AR Wired ethernet_d62316791d59_cable $ sudo connmanctl services ethernet_000c29eeaf0e_cable /net/connman/service/ethernet_000c29eeaf0e_cable Type = ethernet Security = [ ] State = online Favorite = True Immutable = False AutoConnect = True Name = Wired Ethernet = [ Method=auto, Interface=eth0, Address=00:0C:29:EE:AF:0E, MTU=1500 ] IPv4 = [ Method=auto, Address=192.168.116.161, Netmask=255.255.255.0] IPv4.Configuration = [ Method=auto ] IPv6 = [ ] IPv6.Configuration = [ Method=auto, Privacy=disabled ] Nameservers = [ ] Nameservers.Configuration = [ ] Timeservers = [ ] Timeservers.Configuration = [ ] Domains = [ ] Domains.Configuration = [ ] Proxy = [ Method=direct ] Proxy.Configuration = [ ] mDNS = False mDNS.Configuration = False Provider = [ ]
We have identified our connman network service.
k3OS Config: Set Static IP Address
To set static IP address for our connman network service, we can use following command.
$ sudo connmanctl config ethernet_000c29eeaf0e_cable --ipv4 manual 192.168.116.201 255.255.255.0 192.168.116.2 --nameservers 192.168.116.2
k3OS Config: Set Preferred DNS Server
Use following command to set preferred DNS server(s) for our connman network service.
$ sudo connmanctl config ethernet_000c29eeaf0e_cable --nameservers 192.168.116.2
k3OS Config: Disable IPv6 Networking
Disable IPv6 using following command.
$ sudo connmanctl config ethernet_000c29eeaf0e_cable --ipv6 off
Restart connman service to apply changes.
$ sudo service connman restart * WARNING: you are stopping a boot service * Caching service dependencies ... [ ok ] * Stopping k3s-service ... [ ok ] * WARNING: you are stopping a boot service * Stopping issue ... * start-stop-daemon: no matching processes found [ ok ] * WARNING: you are stopping a boot service * Stopping haveged ... [ ok ] * Stopping ccapply ... * start-stop-daemon: no matching processes found [ ok ] * Stopping connman ... [ ok ] * Starting connman ... [ ok ] * Starting haveged ... * Starting ccapply ... * Starting issue ... * Starting k3s-service ... [ ok ] [INFO] Skipping k3s download and verify [INFO] env: Creating environment file /etc/rancher/k3s/k3s-service.env [INFO] openrc: Creating service file /etc/init.d/k3s-service [INFO] openrc: Enabling k3s-service service for default runlevel [INFO] No change detected so skipping service start [ ok ]
k3OS Config: Change Hostname Machine
In k3OS, the /etc is automatically reverts any changes after reboot. Therefore, to persistently change Hostname of k3OS machine, we have to change it in k3OS configuration files.
$ sudo vi /var/lib/rancher/k3os/hostname
and update hostname therein.
kubemaster-01.example.com
Reboot k3OS machine to see the effect.
$ sudo reboot
Login to system after reboot.
login as: rancher rancher@192.168.116.163's password: Welcome to k3OS! Refer to https://github.com/rancher/k3os for README and issues By default mode of k3OS is to run a single node cluster. Use "kubectl" to access it. The node token in /var/lib/rancher/k3s/server/node-token can be used to join agents to this server. $
It shows that, the change in Hostname is now persistent. It also configures server name resolution using Local DNS Resolver.
Check the FQDN using following command.
$ hostname kubemaster-01.example.com
Hostname has been persistently changed on k3OS.
Final Thoughts
Configuring the network for K3OS can be challenging, but with the right guidance and tools, you can achieve a robust and efficient setup. This guide aims to provide you with a solid foundation and practical steps to ensure your network is configured correctly.
If you need further assistance or want a professional to handle the K3OS configuration for you, I offer specialized services on Fiverr. From initial setup to advanced configurations, I’m here to help. Visit my Fiverr profile to learn more about my services and how I can assist you in achieving the perfect K3OS network setup.
Thank you for reading, and happy networking!