1) 安装Snappy
[root@srv1 ~]# yum --enablerepo=epel install snapd -y
[root@srv1 ~]# ln -s /var/lib/snapd/snap /snap
[root@srv1 ~]# echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' > /etc/profile.d/snap.sh
[root@srv1 ~]# source /etc/profile.d/snap.sh
[root@srv1 ~]# systemctl enable --now snapd.service snapd.socket
2) 安装MicroK8S
(1) 安装最新版本的MicroK8S
[root@srv1 ~]# snap install microk8s --classic
2020-08-15T02:34:42+08:00 INFO Waiting for automatic snapd restart...
microk8s v1.18.6 from Canonical✓ installed
(2) 安装指定版本(v1.17)的MicroK8S
[root@srv1 ~]# snap info microk8s
name: microk8s
summary: Lightweight Kubernetes for workstations and appliances
publisher: Canonical✓
store-url: https://snapcraft.io/microk8s
contact: https://github.com/ubuntu/microk8s
license: Apache-2.0
description: |
MicroK8s is the smallest, simplest, pure production Kubernetes for clusters, laptops, IoT and
Edge, on Intel and ARM. One command installs a single-node K8s cluster with carefully selected
add-ons on Linux, Windows and macOS. MicroK8s requires no configuration, supports automatic
updates and GPU acceleration. Use it for offline development, prototyping, testing, to build your
CI/CD pipeline or your IoT apps.
snap-id: EaXqgt1lyCaxKaQCU349mlodBkDCXRcg
channels:
latest/stable: v1.18.6 2020-07-25 (1551) 215MB classic
latest/candidate: v1.19.0 2020-08-27 (1634) 214MB classic
latest/beta: v1.19.0 2020-08-27 (1634) 214MB classic
latest/edge: v1.19.0 2020-08-28 (1641) 214MB classic
dqlite/stable: –
dqlite/candidate: –
dqlite/beta: –
dqlite/edge: v1.16.2 2019-11-07 (1038) 189MB classic
1.19/stable: v1.19.0 2020-08-27 (1637) 214MB classic
1.19/candidate: v1.19.0 2020-08-27 (1637) 214MB classic
1.19/beta: v1.19.0 2020-08-27 (1637) 214MB classic
1.19/edge: v1.19.0 2020-08-28 (1642) 214MB classic
1.18/stable: v1.18.8 2020-08-25 (1609) 201MB classic
1.18/candidate: v1.18.8 2020-08-17 (1609) 201MB classic
1.18/beta: v1.18.8 2020-08-17 (1609) 201MB classic
1.18/edge: v1.18.8 2020-08-13 (1609) 201MB classic
1.17/stable: v1.17.11 2020-08-25 (1608) 179MB classic
1.17/candidate: v1.17.11 2020-08-21 (1608) 179MB classic
1.17/beta: v1.17.11 2020-08-21 (1608) 179MB classic
1.17/edge: v1.17.11 2020-08-13 (1608) 179MB classic
......
......
1.10/stable: v1.10.13 2019-04-22 (546) 222MB classic
1.10/candidate: ↑
1.10/beta: ↑
1.10/edge: ↑
[root@srv1 ~]# snap install node --channel=1.17/stable --classic
# 以下为输出内容
3) 查看MicroK8S的当前状态
[root@srv1 ~]# microk8s status
microk8s is running
addons:
ambassador: disabled
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
helm3: disabled
host-access: disabled
ingress: disabled
istio: disabled
jaeger: disabled
knative: disabled
kubeflow: disabled
linkerd: disabled
metallb: disabled
metrics-server: disabled
multus: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled
4) 显示当前配置
[root@srv1 ~]# microk8s config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR......
server: https://192.168.10.11:16443
name: microk8s-cluster
contexts:
- context:
cluster: microk8s-cluster
user: admin
name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
user:
token: SmoyTEI0WW93RHJ6TXYzVmpRRjE1N2lzbWFuQUhDVEZyZTVRQUtQTzR5QT0K
[root@srv1 ~]# microk8s kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 86s
[root@srv1 ~]# microk8s kubectl get nodes
NAME STATUS ROLES AGE VERSION
srv1.1000y.cloud Ready <none> 103s v1.18.6-1+64f53401f200a7
5) 停止或启动MicroK8S
[root@srv1 ~]# microk8s stop
Stopped.
[root@srv1 ~]# microk8s status
microk8s is not running. Use microk8s inspect for a deeper inspection.
[root@srv1 ~]# microk8s start
Started.
[root@srv1 ~]# snap disable microk8s
microk8s disabled
[root@srv1 ~]# snap enable microk8s
microk8s enabled
|