<p>Microk8s is installed on default port 16443. I want to change it to 6443. I am using Ubuntu 16.04. I have installed microk8s using snapd and conjure-up.</p>

<p>None of the following options I have tried worked.</p>

<ol>
<li>Tried to edit the port in <code>/snap/microk8s/current/kubeproxy.config</code>. As the volume is read-only, I could not edit it.</li>
<li>Edited the <code>/home/user_name/.kube/config</code> and restarted the cluster.</li>
<li>Tried using the command and restarted the cluster
<code>sudo kubectl config set clusters.microk8s-cluster.server https://my_ip_address:6443</code>.</li>
<li>Tried to use <code>kubectl proxy --port=6443 --address=0.0.0.0 --accept-hosts=my_ip_address &amp;</code>. It listens on 6443, but only HTTP, not HTTPS traffic.</li>
</ol>

Srinivasa Rao
<p>That was initially resolved in <a href="https://github.com/ubuntu/microk8s/issues/43#issuecomment-434383633" rel="noreferrer">microk8s issue 43</a>, but detailed in <a href="https://github.com/ubuntu/microk8s/issues/300#issuecomment-476995716" rel="noreferrer">microk8s issue 300</a>:</p>

<blockquote>
  <p>This is the right one to use for the latest microk8s:</p>
</blockquote>

<pre><code>#!/bin/bash
# define our new port number
API_PORT=8888

# 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 &amp;&amp; microk8s.config -l  | sed "s/:8080/:$API_PORT/" | sudo tee /var/snap/microk8s/current/kubelet.config &gt; ~/.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

# disable and enable the microk8s snap to restart all services
sudo snap disable microk8s &amp;&amp; sudo snap enable microk8s
</code></pre>
