-
Notifications
You must be signed in to change notification settings - Fork 0
/
microk8s as autostart service.txt
65 lines (42 loc) · 2.01 KB
/
microk8s as autostart service.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
To start MicroK8s automatically on your Raspberry Pi running Raspberry Pi OS (formerly Raspbian) each time your device boots, you can create a systemd service unit. systemd is the default init system on most modern Linux distributions, including Raspberry Pi OS. Here are the steps to create and enable such a service:
1. **Create a systemd Service Unit File**:
Open a terminal on your Raspberry Pi and create a systemd service unit file for MicroK8s. You can use your favorite text editor. For example:
```bash
sudo nano /etc/systemd/system/microk8s.service
```
Add the following content to the file:
```ini
[Unit]
Description=MicroK8s
[Service]
ExecStart=/snap/bin/microk8s.start
Restart=always
User=thomasschissler
Group=adm
[Install]
WantedBy=multi-user.target
```
Replace `<your_username>` and `<your_group>` with your actual username and group. You can find your username by running `whoami` and your group with the `groups` command.
2. **Reload systemd**:
After creating the service unit file, you need to reload systemd to recognize the new service. Run the following command:
```bash
sudo systemctl daemon-reload
```
3. **Enable the Service**:
To enable the MicroK8s service to start at boot, use the following command:
```bash
sudo systemctl enable microk8s
```
4. **Start the Service**:
You can either reboot your Raspberry Pi or start the MicroK8s service manually with the following command:
```bash
sudo systemctl start microk8s
```
It will now start automatically at boot.
5. **Check the Service Status**:
You can check the status of the MicroK8s service to ensure it's running properly:
```bash
sudo systemctl status microk8s
```
It should show that the service is active and running.
That's it! Your MicroK8s should now start automatically each time your Raspberry Pi boots up. You can also stop and disable it if needed using `sudo systemctl stop microk8s` and `sudo systemctl disable microk8s`, respectively.