Skip to content

Instantly share code, notes, and snippets.

@Machy8
Last active August 6, 2023 13:38
Show Gist options
  • Save Machy8/21ec48161787a30f6f77c2a41d807fbf to your computer and use it in GitHub Desktop.
Save Machy8/21ec48161787a30f6f77c2a41d807fbf to your computer and use it in GitHub Desktop.
Start Kubernetes proxy server automatically
  1. Create an empty file and paste the content bellow into it /lib/systemd/system/kubectlproxy.service
[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
  1. Restart the server
  2. Check the service status systemctl -l status kubectlproxy.service
  3. If the service is not enabled (error bellow)
kubectl-proxy.service - kubectl proxy 8080
   Loaded: loaded (/lib/systemd/system/kubectl-proxy.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

enable it by this command systemctl enable kubectlproxy.service

Notes If you modify the configuration of the service after start you need to run the following

  1. systemctl daemon-reload
  2. systemctl reenable kubectlproxy.service
  3. systemctl restart kubectlproxy.service
@Machy8
Copy link
Author

Machy8 commented Jun 18, 2019

@ashwnacharya
Copy link

@Trackhe Run it with 0.0.0.0 instead of 127.0.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment