This is a supplimentary 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.
This Article Provides:
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.
k3os-1185 [~]$ sudo connmanctl services
*AO Wired ethernet_000c29eeaf0e_cable
*AR Wired ethernet_aae0cd9b094b_cable
*AR Wired ethernet_da9d68a358a4_cable
*AR Wired ethernet_d62316791d59_cable
k3os-1185 [~]$ 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.
Set Static IP Address on k3OS:
To set static IP address for our connman network service, we can use following command.
k3os-1185 [~]$ 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
Set Preferred DNS Server on k3OS:
Use following command to set preferred DNS server(s) for our connman network service.
k3os-1185 [~]$ sudo connmanctl config ethernet_000c29eeaf0e_cable --nameservers 192.168.116.2
Disable IPv6 Networking in k3OS:
Disable IPv6 using following command.
k3os-1185 [~]$ sudo connmanctl config ethernet_000c29eeaf0e_cable --ipv6 off
Restart connman service to apply changes.
k3os-1185 [~]$ 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 ]
k3os-1185 [~]$ * 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 ]
Change Hostname of k3OS 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.
k3os-1185 [~]$ sudo vi /var/lib/rancher/k3os/hostname
and update hostname therein.
kubemaster-01.example.com
Reboot k3OS machine to see the effect.
k3os-1185 [~]$ 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.
kubemaster-01 [~]$
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.
kubemaster-01 [~]$ hostname
kubemaster-01.example.com
Hostname has been persistently changed on k3OS.
0 Comments