- Run the following command to create a kubectlproxy service file.
sudo nano /lib/systemd/system/kubectlproxy.service
- Copy these contents into your file and save.
[Unit]
Description=kubectl proxy 8080
After=network.target
[Service]
User=root
ExecStart=/bin/bash -c "/usr/bin/kubectl proxy --address=127.0.0.1 --port=8080"
StartLimitInterval=0
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
Note: Replace usr/bin/kubectl
with the location of your kubectl. Run which kubectl
if you
don't know where it is located.
- Run the below command to reload systemd manager configuration.
sudo systemctl daemon-reload
- Run the below command to enable the service.
sudo systemctl enable kubectlproxy.service
- Restart the service by running the below command.
sudo systemctl restart kubectlproxy.service
- Check the status of your service to ensure it is running.
sudo systemctl -l status kubectlproxy.service
Response should be similar to the following.
kubectlproxy.service - kubectl proxy 8080
Loaded: loaded (/lib/systemd/system/kubectlproxy.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-04-05 20:21:58 EDT; 8min ago
- Make a request to the API.
curl http://localhost:8080/api/