Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-45-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Thu 03 Sep 2020 06:19:14 AM UTC
System load: 0.01 Processes: 147
Usage of /: 26.9% of 21.53GB Users logged in: 1
Memory usage: 62% IPv4 address for docker0: 172.17.0.1
Swap usage: 0% IPv4 address for eth0: 192.168.151.14
* Kubernetes 1.19 is out! Get it in one command with:
sudo snap install microk8s --channel=1.19 --classic
https://microk8s.io/ has docs and details.
root@ub20:~# snap --help
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.
Usage: snap <command> [<options>...]
Commands can be classified as follows:
Basics: find, info, install, list, remove
...more: refresh, revert, switch, disable, enable
History: changes, tasks, abort, watch
Daemons: services, start, stop, restart, logs
Commands: alias, aliases, unalias, prefer
Configuration: get, set, unset, wait
Account: login, logout, whoami
Permissions: connections, interface, connect, disconnect
Snapshots: saved, save, check-snapshot, restore, forget
Other: version, warnings, okay, ack, known, model, create-cohort
Development: run, pack, try, download, prepare-image
For more information about a command, run 'snap help <command>'.
For a short summary of all commands, run 'snap help --all'.
官方文档:
-
Install MicroK8s on Linux
sudo snap install microk8s --classic
Don’t have the
snap
command? Get set up for snaps -
Check the status while Kubernetes starts
microk8s status --wait-ready
-
Turn on the services you want
microk8s enable dashboard dns registry istio
Try
microk8s enable --help
for a list of available services and optional features.microk8s disable <name>
turns off a service. -
Start using Kubernetes
microk8s kubectl get all --all-namespaces
If you mainly use MicroK8s you can make our kubectl the default one on your command-line with
alias mkctl="microk8s kubectl"
. Since it is a standard upstream kubectl, you can also drive other Kubernetes clusters with it by pointing to the respective kubeconfig file via the--kubeconfig
argument. -
Access the Kubernetes dashboard
microk8s dashboard-proxy
-
Start and stop Kubernetes to save battery
Kubernetes is a collection of system services that talk to each other all the time. If you don’t need them running in the background then you will save battery by stopping them.
microk8s start
andmicrok8s stop
will do the work for you.
root@ub20:~# 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-09-01 (1656) 214MB classic
latest/beta: v1.19.0 2020-09-01 (1656) 214MB classic
latest/edge: v1.19.0 2020-09-02 (1668) 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-09-02 (1667) 214MB classic
1.19/beta: v1.19.0 2020-09-02 (1667) 214MB classic
1.19/edge: v1.19.0 2020-09-02 (1667) 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.16/stable: v1.16.14 2020-08-23 (1606) 179MB classic
1.16/candidate: v1.16.14 2020-08-20 (1606) 179MB classic
1.16/beta: v1.16.14 2020-08-20 (1606) 179MB classic
1.16/edge: v1.16.15 2020-09-02 (1671) 179MB classic
1.15/stable: v1.15.11 2020-03-27 (1301) 171MB classic
1.15/candidate: v1.15.11 2020-03-27 (1301) 171MB classic
1.15/beta: v1.15.11 2020-03-27 (1301) 171MB classic
1.15/edge: v1.15.11 2020-03-26 (1301) 171MB classic
1.14/stable: v1.14.10 2020-01-06 (1120) 217MB classic
1.14/candidate: ↑
1.14/beta: ↑
1.14/edge: v1.14.10 2020-03-26 (1303) 217MB classic
1.13/stable: v1.13.6 2019-06-06 (581) 237MB classic
1.13/candidate: ↑
1.13/beta: ↑
1.13/edge: ↑
1.12/stable: v1.12.9 2019-06-06 (612) 259MB classic
1.12/candidate: ↑
1.12/beta: ↑
1.12/edge: ↑
1.11/stable: v1.11.10 2019-05-10 (557) 258MB classic
1.11/candidate: ↑
1.11/beta: ↑
1.11/edge: ↑
1.10/stable: v1.10.13 2019-04-22 (546) 222MB classic
1.10/candidate: ↑
1.10/beta: ↑
1.10/edge: ↑
拉镜像,官方很慢
root@ub20:~# microk8s kubectl describe pods coredns-588fd544bf-97vc4 -n kube-system
Name: coredns-588fd544bf-97vc4
Namespace: kube-system
Priority: 2000000000
Priority Class Name: system-cluster-critical
Node: ub20/192.168.151.4
Start Time: Tue, 15 Sep 2020 07:07:39 +0000
Labels: k8s-app=kube-dns
pod-template-hash=588fd544bf
Annotations: scheduler.alpha.kubernetes.io/critical-pod:
Status: Pending
IP:
IPs: <none>
Controlled By: ReplicaSet/coredns-588fd544bf
Containers:
coredns:
Container ID:
Image: coredns/coredns:1.6.6
Image ID:
Ports: 53/UDP, 53/TCP, 9153/TCP
Host Ports: 0/UDP, 0/TCP, 0/TCP
Args:
-conf
/etc/coredns/Corefile
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Limits:
memory: 170Mi
Requests:
cpu: 100m
memory: 70Mi
Liveness: http-get http://:8080/health delay=60s timeout=5s period=10s #success=1 #failure=5
Readiness: http-get http://:8181/ready delay=0s timeout=1s period=10s #success=1 #failure=3
Environment: <none>
Mounts:
/etc/coredns from config-volume (ro)
/var/run/secrets/kubernetes.io/serviceaccount from coredns-token-9pwz4 (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
config-volume:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: coredns
Optional: false
coredns-token-9pwz4:
Type: Secret (a volume populated by a Secret)
SecretName: coredns-token-9pwz4
Optional: false
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: CriticalAddonsOnly op=Exists
node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 48s default-scheduler Successfully assigned kube-system/coredns-588fd544bf-97vc4 to ub20
Warning FailedCreatePodSandBox 17s kubelet, ub20 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to get sandbox image "k8s.gcr.io/pause:3.1": failed to pull image "k8s.gcr.io/pause:3.1": failed to pull and unpack image "k8s.gcr.io/pause:3.1": failed to resolve reference "k8s.gcr.io/pause:3.1": failed to do request: Head "https://k8s.gcr.io/v2/pause/manifests/3.1": dial tcp 108.177.125.82:443: i/o timeout
获取镜像:
microk8s kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-588fd544bf-dmbxj 0/1 ContainerCreating 0 10d
dashboard-metrics-scraper-59f5574d4-rbh96 0/1 ContainerCreating 0 10d
hostpath-provisioner-75fdc8fccd-bhr5w 0/1 ContainerCreating 0 10d
kubernetes-dashboard-6d97855997-zp4nn 0/1 ContainerCreating 0 10d
metrics-server-c65c9d66-42pkb 0/1 ContainerCreating 0 10d
microk8s kubectl get pods coredns-588fd544bf-dmbxj -n kube-system -o yaml > microk8s-coredns.yaml
microk8s kubectl get pods dashboard-metrics-scraper-59f5574d4-rbh96 -n kube-system -o yaml > microk8s-dashboard-metrics-scraper.yaml
microk8s kubectl get pods hostpath-provisioner-75fdc8fccd-bhr5w -n kube-system -o yaml > microk8s-hostpath-provisioner.yaml
microk8s kubectl get pods kubernetes-dashboard-6d97855997-zp4nn -n kube-system -o yaml > microk8s-kubernetes-dashboard.yaml
microk8s kubectl get pods metrics-server-c65c9d66-42pkb -n kube-system -o yaml > microk8s-metrics-server.yaml
# 从中获取镜像URL
grep " image:" microk8s-*.yaml
microk8s-coredns.yaml: image: coredns/coredns:1.6.6
microk8s-coredns.yaml: - image: coredns/coredns:1.6.6
microk8s-dashboard-metrics-scraper.yaml: - image: kubernetesui/metrics-scraper:v1.0.4
microk8s-dashboard-metrics-scraper.yaml: - image: kubernetesui/metrics-scraper:v1.0.4
microk8s-hostpath-provisioner.yaml: image: cdkbot/hostpath-provisioner-amd64:1.0.0
microk8s-hostpath-provisioner.yaml: - image: cdkbot/hostpath-provisioner-amd64:1.0.0
microk8s-kubernetes-dashboard.yaml: image: kubernetesui/dashboard:v2.0.0
microk8s-kubernetes-dashboard.yaml: - image: kubernetesui/dashboard:v2.0.0
microk8s-metrics-server.yaml: image: k8s.gcr.io/metrics-server-amd64:v0.3.6
microk8s-metrics-server.yaml: - image: k8s.gcr.io/metrics-server-amd64:v0.3.6
docker pull registry.aliyuncs.com/google_containers/pause:3.1
docker tag registry.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1
docker pull registry.aliyuncs.com/google_containers/coredns:1.6.6
docker tag registry.aliyuncs.com/google_containers/coredns:1.6.6 coredns/coredns:1.6.6
docker pull kubernetesui/metrics-scraper:v1.0.4
docker pull cdkbot/hostpath-provisioner-amd64:1.0.0
docker pull kubernetesui/dashboard:v2.0.0
docker pull lizhenliang/metrics-server:v0.3.7
docker tag lizhenliang/metrics-server:v0.3.7 k8s.gcr.io/metrics-server-amd64:v0.3.6
docker tag lizhenliang/metrics-server:v0.3.7 k8s.gcr.io/metrics-server-amd64:v0.3.7
microk8s kubectl get rs --all-namespaces
NAMESPACE NAME DESIRED CURRENT READY AGE
container-registry registry-9b57d9df8 1 1 0 4m29s
kube-system coredns-86f78bb79c 1 1 0 4m40s
kube-system dashboard-metrics-scraper-6c4568dc68 1 1 0 4m42s
kube-system hostpath-provisioner-5c65fbdb4f 1 1 0 4m31s
kube-system kubernetes-dashboard-7ffd448895 1 1 0 4m42s
kube-system metrics-server-8bbfb4bdb 1 1 0 4m47s
很坑爹,拉到本地的镜像,microk8s不会用,还是去官方拉取,然后就拉不到。。。