Logo

dev-resources.site

for different kinds of informations.

AIO : Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify ... permissions

Published at
5/2/2024
Categories
aio
azureiot
troubleshooting
Author
danuw
Categories
3 categories in total
aio
open
azureiot
open
troubleshooting
open
Author
5 person written this
danuw
open
AIO : Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify ... permissions

Using Azure IoT Operations (AIO) and found that issue of permissions denied and the cluster not running with the following messages? Here is how I fixed it...

When I connect to my clusters, my first action is to check if my pods or services are running with the following command, but recently I have at times been getting the subsequent output error:

$ kubectl get service -n azure-iot-operations
WARN[0000] Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify kube config permissions
error: error loading config file "/etc/rancher/k3s/k3s.yaml": open /etc/rancher/k3s/k3s.yaml: permission denied
Enter fullscreen mode Exit fullscreen mode

I tried the following solution using this command, but that was only temporary...

Solution 1: Admin Kubeconfig Options

sudo k3s server --write-kubeconfig-mode 644
Enter fullscreen mode Exit fullscreen mode

If you encounter the following...

$ sudo k3s server --write-kubeconfig-mode 644
[sudo] password for dan:
INFO[0000] Starting k3s v1.28.7+k3s1 (051b14b2)
INFO[0000] Configuring sqlite3 database connection pooling: maxIdleConns=2, maxOpenConns=0, connMaxLifetime=0s
INFO[0000] Configuring database table schema and indexes, this may take a moment...
INFO[0000] Database tables and indexes are up to date
INFO[0000] Kine available at unix://kine.sock
INFO[0000] Reconciling bootstrap data between datastore and disk
FATA[0000] starting kubernetes: preparing server: init cluster datastore and https: listen tcp :6443: bind: address already in use
Enter fullscreen mode Exit fullscreen mode

...you can just stop the service with this command first:

sudo systemctl stop k3s
Enter fullscreen mode Exit fullscreen mode

Solution 2: Directly provide access to the file for all users

sudo chmod 644 /etc/rancher/k3s/k3s.yaml
Enter fullscreen mode Exit fullscreen mode

Your k3s cluster should now start and you will be able to get the list of pods/services confirming everything is running as expected.

kubectl get pods -n azure-iot-operations
Enter fullscreen mode Exit fullscreen mode

This issue occurred every time I reset my ubuntu server's kubernetes cluster, but I will just apply that going forward to continue testing with my user and run kubectl commands without sudo ...

References:

troubleshooting Article's
30 articles in total
Favicon
Fix 105 Common WordPress Issues Using Simple Code Snippets
Favicon
5 errores comunes en Kubernetes y cómo solucionarlos rápidamente
Favicon
Half-Duplex vs Full-Duplex: What are the Differences?
Favicon
npm error 'node' is not recognized as an internal or external command
Favicon
Troubleshooting Kubernetes Clusters and Pods: A Comprehensive Guide
Favicon
Kubernetes Logs and Debugging Techniques: Best Practices for Efficient Troubleshooting
Favicon
Effective Methods for Troubleshooting Deadlocks in SQL Server
Favicon
NuPhy Air75 V2 - firmware upgrade & troubleshooting
Favicon
Moving beyond console.log
Favicon
How to Master Kubernetes Troubleshooting? Do it with 35 Real-World Scenarios
Favicon
Owning the Chaos: A Simple Guide to Tackling Obscure Errors
Favicon
[pt-BR] Troubleshooting Linux - Comandos e ações
Favicon
The Art of Problem-Solving
Favicon
error when starting dev server
Favicon
What to do if you accidentally remove the `amd-ucode` package on Arch Linux
Favicon
Stop the cursor from jumping to the corner of the screen on a Lenovo Yoga laptop
Favicon
Advanced Linux Troubleshooting in DevOps and Cloud: Practical Use Cases and Commands
Favicon
Troubleshooting Amazon Bedrock Payment Errors: A Comprehensive Step-by-Step Guide
Favicon
Respect Your Youngers
Favicon
Troubleshooting Automatic Scrolling to Cal.com Inline Embed on Page Load
Favicon
Troubleshooting Adabas Event Replicator on z/OS Command Code A1 Error 77 Subcode 11
Favicon
Round Two: Enhancing the Ollama Cluster
Favicon
Troubleshooting with PipeOps: Error 502 with React apps
Favicon
Everything you need to know about monitoring CoreDNS for DNS performance
Favicon
Troubleshooting External Hard Drives on Linux
Favicon
How to Fix the Frustrating Error 0x80300024 When Installing Windows 11/10
Favicon
Troubleshooting Common Issues in Printed Circuit Board Fabrication
Favicon
AIO : Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify ... permissions
Favicon
Troubleshooting 'Command Not Found: Flutter' Error: Solutions and Tips
Favicon
Fix OpenRGB Post-Sleep Glitches: Automated Profile Reload

Featured ones: