工作上用到 Microk8s,因架设在 Hyper-V 上,当电脑重新开机後 Hyper-V IP会浮动,导致 microk8s 指令无法正常运作,因此想到了使用固定IP来解决这个问题。
在 Windows 10 先安装好以下工具:
安装Kubernetes
microk8s install
执行完後
Launched: microk8s-vm
2022-01-19T15:40:30+08:00 INFO Waiting for automatic snapd restart...
microk8s (1.22/stable) v1.22.5 from Canonical✓ installed
microk8s-integrator-windows 0.1 from Canonical✓ installed
MicroK8s is up and running. See the available commands with `microk8s --help`.
会在 Hyper-V 管理员看到 microk8s-vm 的虚拟机
查看 Microk8s 状态
microk8s status
microk8s is running
high-availability: no
datastore master nodes: 127.0.0.1:19001
datastore standby nodes: none
addons:
enabled:
ha-cluster # Configure high availability on the current node
disabled:
ambassador # Ambassador API Gateway and Ingress
cilium # SDN, fast with full network policy
dashboard # The Kubernetes dashboard
dns # CoreDNS
fluentd # Elasticsearch-Fluentd-Kibana logging and monitoring
gpu # Automatic enablement of Nvidia CUDA
helm # Helm 2 - the package manager for Kubernetes
helm3 # Helm 3 - Kubernetes package manager
host-access # Allow Pods connecting to Host services smoothly
ingress # Ingress controller for external access
istio # Core Istio service mesh services
jaeger # Kubernetes Jaeger operator with its simple config
kata # Kata Containers is a secure runtime with lightweight VMS
keda # Kubernetes-based Event Driven Autoscaling
knative # The Knative framework on Kubernetes.
kubeflow # Kubeflow for easy ML deployments
linkerd # Linkerd is a service mesh for Kubernetes and other frameworks
metallb # Loadbalancer for your Kubernetes cluster
metrics-server # K8s Metrics Server for API access to service metrics
multus # Multus CNI enables attaching multiple network interfaces to pods
openebs # OpenEBS is the open-source storage solution for Kubernetes
openfaas # openfaas serverless framework
portainer # Portainer UI for your Kubernetes cluster
prometheus # Prometheus operator for monitoring and logging
rbac # Role-Based Access Control for authorisation
registry # Private image registry exposed on localhost:32000
storage # Storage class; allocates storage from host directory
traefik # traefik Ingress controller for external access
建立虚拟交换器
填入名称 LANBridge
设定交换器
停止 Microk8s
microk8s stop
设定 microk8s-vm 虚拟机网路介面卡
启动 Microk8s
microk8s start
查看 microk8s-vm 讯息
multipass info microk8s-vm
Name: microk8s-vm
State: Running
IPv4: 172.21.68.80
10.1.254.64
Release: Ubuntu 18.04.6 LTS
Image hash: 7bd21b98e344 (Ubuntu 18.04 LTS)
Load: 0.69 0.53 0.37
Disk usage: 2.3G out of 48.3G
Memory usage: 1.3G out of 3.9G
Mounts: --
透过 multipass 编辑 microk8s-vm 网路设定
multipass exec microk8s-vm -- sudo vi /etc/netplan/50-cloud-init.yaml
Vi 文字编辑器
原有设定
network:
ethernets:
eth0:
dhcp4: true
match:
macaddress: 52:54:00:5e:ec:bd
set-name: eth0
version: 2
修改後设定
network:
ethernets:
eth0:
dhcp4: true
match:
macaddress: 52:54:00:5e:ec:bd
set-name: eth0
eth1:
addresses: [192.168.1.101/24]
version: 2
配置网路设定
multipass exec microk8s-vm -- sudo netplan apply
查看 microk8s-vm 讯息
multipass info microk8s-vm
Name: microk8s-vm
State: Running
IPv4: 172.21.68.80
192.168.1.101
10.1.254.64
Release: Ubuntu 18.04.6 LTS
Image hash: 7bd21b98e344 (Ubuntu 18.04 LTS)
Load: 0.78 0.59 0.41
Disk usage: 2.3G out of 48.3G
Memory usage: 1.3G out of 3.9G
Mounts: --
确认可以连到该主机
ping 192.168.1.101
Pinging 192.168.1.101 with 32 bytes of data:
Reply from 192.168.1.101: bytes=32 time<1ms TTL=64
Reply from 192.168.1.101: bytes=32 time<1ms TTL=64
Reply from 192.168.1.101: bytes=32 time<1ms TTL=64
Reply from 192.168.1.101: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.1.101:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
更改 microk8s 主机IP
修改为 192.168.1.101
重新开机後输入指令,可以正常显示讯息就成功了
microk8s status
参考文章
使用 MicroK8s 架设 Kubernetes 丛集的完整过程解析
Git Graph操作 点击 commit 名称就可以展开细节,再点一次收回 右边栏位绿字为新增的项...
通过本文,您将能够解决Windows 10/8/7中的“硬碟仅显示少量容量”问题,并使用“Bitwa...
考量到要建立各种 class 所以统一建立一个 class 给所有人继承 可以直接跳过,但注意之後有...
不难发现,问题在於该用什麽标准来做决定呢?梁晓声曾讲过,友谊,好比一瓶酒,封存的时间越长,价值则越高...
大家~ 今天文章会特别短Q 来讲一下静态网站可以部署到哪里呢?大家应该常听到 Github Page...