Skip to content

Instantly share code, notes, and snippets.

@emoss08
Last active April 6, 2023 02:24
Show Gist options
  • Save emoss08/ebb853881bba4d861da33b7be790bd9d to your computer and use it in GitHub Desktop.
Save emoss08/ebb853881bba4d861da33b7be790bd9d to your computer and use it in GitHub Desktop.
  1. Run the following command to create a kubectlproxy service file.
sudo nano /lib/systemd/system/kubectlproxy.service
  1. 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.

  1. Run the below command to reload systemd manager configuration.
sudo systemctl daemon-reload
  1. Run the below command to enable the service.
sudo systemctl enable kubectlproxy.service
  1. Restart the service by running the below command.
sudo systemctl restart kubectlproxy.service
  1. 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
  1. Make a request to the API.
curl http://localhost:8080/api/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment