Skip to content

Instantly share code, notes, and snippets.

@parj
Last active May 3, 2020 20:02
Show Gist options
  • Save parj/a8c66762890e18d37ed82d132778e527 to your computer and use it in GitHub Desktop.
Save parj/a8c66762890e18d37ed82d132778e527 to your computer and use it in GitHub Desktop.
#!/bin/bash
# define our new port number
API_PORT=8080
# update kube-apiserver args with the new port
# tell other services about the new port
sudo find /var/snap/microk8s/current/args -type f -exec sed -i "s/8080/$API_PORT/g" {} ';'
# create new, updated copies of our kubeconfig for kubelet and kubectl to use
mkdir -p ~/.kube && microk8s.config -l | sed "s/:8080/:$API_PORT/" | sudo tee /var/snap/microk8s/current/kubelet.config > ~/.kube/microk8s.config
# tell kubelet about the new kubeconfig
sudo sed -i 's#${SNAP}/configs/kubelet.config#${SNAP_DATA}/kubelet.config#' /var/snap/microk8s/current/args/kubelet
echo "--insecure-port=$API_PORT" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver
# disable and enable the microk8s snap to restart all services
sudo snap disable microk8s && sudo snap enable microk8s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment