Ultimate k3OS Configure Network Guide

Share on Social Media

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

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.

Ultimate k3OS Configure Network Guide
Ultimate k3OS Configure Network Guide

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

Output:

*AO Wired                ethernet_000c29eeaf0e_cable
*AR Wired ethernet_aae0cd9b094b_cable
*AR Wired ethernet_da9d68a358a4_cable
*AR Wired ethernet_d62316791d59_cable

Now query the “AO Wired” service as follows.

sudo connmanctl services ethernet_000c29eeaf0e_cable

Output:

/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.

Recommended Training: Certified Kubernetes Administrator (CKA) with Practice Tests from Mumshad Mannambeth, KodeKloud Training

2301254 26c8 7

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

Output:

 * 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

Output:

kubemaster-01.example.com

Hostname has been persistently changed on k3OS.

Frequently Asked Questions (FAQs)

1. How do I check my current network settings in k3OS?

You can use the ifconfig or ip a command in the terminal to view your active network interfaces and their configurations.

2. Can I configure a static IP address in k3OS?

Yes, you can set a static IP by editing the network configuration file (/etc/rancher/k3os/config.yaml) and specifying the IP, gateway, and DNS settings.

3. How do I connect to a Wi-Fi network in k3OS?

You need to modify the network configuration file to include your Wi-Fi SSID and password, then restart the network service.

4. What should I do if my network changes don’t apply?

After modifying the network settings, ensure you reboot the system or restart the network service for the changes to take effect.

5. How can I troubleshoot network issues in k3OS?

Check your configuration file for errors, verify physical connections, and use commands like ping or ip route to test connectivity and routing.

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.

Need a dependable Linux system administrator? I specialize in managing, optimizing, and securing Linux servers to keep your operations running flawlessly. Check out my services on Fiverr!

Thank you for reading, and happy networking!

Looking for something?

Leave a Reply