导语
本文中,我们将介绍以下3部分服务:MicroK8s、k3s、Katacoda。MicroK8和k3定位在轻量级的Kubernetes环境中,不仅有望用于学习,而且还将用于各种环境,例如容量有限的IoT环境。Katacoda是一个免费的综合学习站点,您可以在其中基于浏览器学习云原生技术,不仅可以运行Kubernetes,还可以提供免费的学习课程。
MicroK8s
MicroK8s是一个轻量级的Kubernetes环境。与Minikube不同,它不需要VirtualBox,因此可以在虚拟服务器上运行。它是一个轻巧的单节点,并具有Istio,Knative和Kubeflow等全面功能,非常适合学习Kubernetes。
现在,让我们使用Micro K8。转到官方网站,然后单击“入门”按钮。
MicroK8s官网
在这里,选择“ macOS”,然后单击“为macOS下载Multipass”按钮以下载安装程序。
MicroK8s安装环境
从控制台启动multipass,然后输入multipass。然后使用snap安装microk8s。
$multipass launch --name microk8s-vm --mem 4G --disk 40G
Launched: microk8s-vm
$multipass shell microk8s-vm
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-70-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Mon Nov 25 19:15:38 JST 2019
System load: 0.03 Processes: 103
Usage of /: 2.5% of 38.60GB Users logged in: 0
Memory usage: 3% IP address for enp0s2: 192.168.64.3
Swap usage: 0%
0 packages can be updated.
0 updates are security updates.
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.
multipass@microk8s-vm:~$ sudo snap install microk8s --classic
2019-11-25T19:33:10 09:00 INFO Waiting for restart...
microk8s v1.16.3 from Canonical✓ installed
检查MicroK8s的启动状态。
multipass@microk8s-vm:~$ sudo microk8s.status --wait-ready
mAicrok8s is running
addons:
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
ingress: disabled
istio: disabled
jaeger: disabled
juju: disabled
knative: disabled
kubeflow: disabled
linkerd: disabled
metrics-server: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled
启动标准服务,安装完成。
multipass@microk8s-vm:~$ sudo microk8s.enable dns dashboard registry
Enabling DNS
Applying manifest
serviceaccount/coredns created
configmap/coredns created
deployment.apps/coredns created
service/kube-dns created
clusterrole.rbac.authorization.k8s.io/coredns created
clusterrolebinding.rbac.authorization.k8s.io/coredns created
〜中略〜
Applying registry manifest
namespace/container-registry created
persistentvolumeclaim/registry-claim created
deployment.apps/registry created
service/registry created
The registry is enabled
就像Minikube一样,尝试kubectl。在下面,执行“获取节点”和“获取服务”。
要停止MicroK8,请运行“ microk8s.stop”。
multipass@microk8s-vm:~$ sudo microk8s.kubectl get nodes
NAME STATUS ROLES AGE VERSION
microk8s-vm Ready 4d19h v1.16.3
multipass@microk8s-vm:~$ sudo microk8s.kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.152.183.1 443/TCP 4d19h
multipass@microk8s-vm:~$ sudo microk8s.stop
Stopped.
k3s
k3s是一个轻量级的Kubernetes环境,是Kubernetes的官方发行版。由Rancher Labs开发,它以小于40MB的二进制文件形式提供。由于重量轻,它有望用于边缘计算,物联网和CI等应用。
V1.0于2019年11月18日发布,截至2020年4月15日,最新版本是v1.17.4 k3s1。
请注意,支持的操作系统是Ubuntu或Raspbian Buster,在Mac上不起作用。
Rancher Labs官网
只需执行以下命令即可完成安装,并且可以使用kubectl命令等。
$curl -sfL https://get.k3s.io | sh -
[INFO] Finding latest release
[INFO] Using v1.17.4 k3s1 as release
[INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v1.17.4 k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v1.17.4 k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
$ sudo kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-172-xx-xx-xx Ready master 112s v1.17.4 k3s1
Katacoda
Katacoda是一个针对Kubernetes,Docker和Tensorflow等云原生技术的全面免费学习网站,您只能使用“与Kubernetes课堂一起玩”之类的浏览器进行学习。
对于没有EKS或GKE等云环境的用户,或者不安装Minikube等而立即尝试的用户,建议使用它。
例如,尝试在“ Kubernetes简介”中选择“开始课程”。在“启动单节点群集”课程中,您可以按照左侧窗格中显示的步骤并在右侧窗格中键入命令来轻松进行。
Katacoda官网
这次我介绍了Micro K8s,k3,Katocada。Micro K8s和k3易于制造且重量轻。Katacoda的另一个优点是您可以仅使用浏览器立即开始学习。如果您想开始使用Kubernetes但障碍很大,请尝试一下。
,