Kubernetes

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.

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!

Alaric Bird

Alaric Bird is a seasoned Linux System Administrator with over a decade of experience in managing and optimizing Linux-based servers and infrastructure. Known for his expertise in server deployment, security hardening, and performance tuning, Alaric has a deep understanding of various Linux distributions, including Ubuntu, CentOS, and Red Hat Enterprise Linux. His skills extend to cloud platforms like AWS, where he effectively manages virtual private servers and services. Alaric is also proficient in scripting languages such as Bash and Python, which he uses to automate routine tasks, enhancing efficiency and reliability. With a strong commitment to continuous learning, he stays updated with the latest developments in open-source technologies and best practices. His problem-solving abilities, combined with excellent communication skills, make him a valuable asset to any IT team. In addition to his technical expertise, Alaric is passionate about mentoring junior administrators and fostering a collaborative environment.

Share
Published by
Alaric Bird

Recent Posts

Puppy Linux: Fast and Simple OS

Puppy Linux is a fast, lightweight OS designed for speed and simplicity, perfect for old…

1 day ago

Change Apache Document Root in Linux

Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…

2 weeks ago

How to Change Apache Port in Linux

Discover how to change Apache port in Linux easily. Follow our simple guide to modify…

2 weeks ago

How to Create Virtual Host in Apache Server

Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…

3 weeks ago

10 Practical Tasks for RHCSA Exam with Solutions

Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…

3 weeks ago

Ultimate Fail2ban Configuration Guide

Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…

4 weeks ago

This website uses cookies.