簡體   English   中英

如何更改microk8s的默認端口?

[英]How to change the default port of microk8s?

Microk8s 安裝在默認端口 16443 上。我想將其更改為 6443。我使用的是 Ubuntu 16.04。 我已經使用 snapd 和 conjure-up 安裝了 microk8s。

我嘗試過的以下選項均無效。

  1. 嘗試編輯/snap/microk8s/current/kubeproxy.config的端口。 由於卷是只讀的,我無法編輯它。
  2. 編輯/home/user_name/.kube/config並重新啟動集群。
  3. 嘗試使用該命令並重新啟動集群sudo kubectl config set clusters.microk8s-cluster.server https://my_ip_address:6443
  4. 嘗試使用kubectl proxy --port=6443 --address=0.0.0.0 --accept-hosts=my_ip_address & 它偵聽 6443,但僅偵聽 HTTP,而不偵聽 HTTPS 流量。

這最初在microk8s 問題 43 中得到解決,但在microk8s 問題 300 中有詳細說明:

這是用於最新 microk8s 的正確方法:

#!/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 && 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

# disable and enable the microk8s snap to restart all services
sudo snap disable microk8s && sudo snap enable microk8s

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM