同一主机支持多个容器后端
只支持Linux
使用boot2docker镜像
模块化支持各家云提供商插件
命令行方式操作
不支持Windows和Mac
安装简便
自动配置命令行
图形化界面配置
一键启停作业
共享卷时性能很差
高耗能降低电池使用时间
支持Windows 10 pro或者enterprise
$ minikube start
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.
本地环境易于访问
Kubernetes可用
Kubernetes在空闲时耗费大量电力
感觉还是跟docker-machine很类似
内置Docker版本严重滞后
有些功能尚不支持,例如RBAC(role-based authentication control)
需要使用minikube start/stop
kubectl config use-context docker-for-desktop
如果发现有太多输出内容,Kubernetes社区有一个叫kubectx[3]的工具可以改善输出状况。Docker Swarm和Kubernetes之间一个不同是命名空间的支持。默认地,Kubernetes生态容器运行在称为system的隐藏命名空间,可以通过以下命令查看kubectl get all --all-namespaces:
$kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.2", GitCommit:"bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:"clean", BuildDate:"2017-10-24T19:48:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.2", GitCommit:"bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:"clean", BuildDate:"2017-10-24T19:38:10Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
$kubectl get stacks
No resources found.
$ kubectl get crd
NAME AGE
stacks.compose.docker.com 24d
$ docker stack deploy prometheus -c ./docker-compose.yml
Stack prometheus was created
Waiting for the stack to be stable and running...
- Service exporter has one container running
- Service grafana has one container running
- Service prom has one container running
Stack prometheus is stable and running
$ kubectl get stacks
NAME AGE
prometheus 1m
$kubectl get pods
NAME READY STATUS RESTARTS AGE
exporter-66c7bbfcc6-r5sq4 1/1 Running 0 2m
grafana-7c5f5f6b75-rfgzp 1/1 Running 0 2m
prom-76b4f584f7-qckc9 0/1 CrashLoopBackOff 4 2m
kubectl apply 支持YAML
helm
RBAC激活
$ mkdir -p go/src/github.com/openfaas/ && \
cd go/src/github.com/openfaas/ && \
git clone https://github.com/openfaas/faas-netes && \
cd faas-netes && \
kubectl apply -f ./yaml
如果碰到命名空间错误,可以在faas-netes目录下执行kubectl apply -f ./namespaces.yml ,然后再尝试一遍。OpenFaaS会在localhost:31112启动图形界面,并启用了RBAC和两个命名空间(openfaas / openfaas-fn),输出如下:
service "alertmanager" created
deployment "alertmanager" created
configmap "alertmanager-config" configured
service "faas-netesd" created
deployment "faas-netesd" created
deployment "gateway" created
service "gateway" created
service "nats" created
deployment "nats" created
service "prometheus" created
deployment "prometheus" created
configmap "prometheus-config" configured
deployment "queue-worker" created
serviceaccount "faas-controller" configured
role "faas-controller" configured
rolebinding "faas-controller-fn" configured
$ kubectl get all --namespace openfaas
$ kubectl get all --namespace openfaas-fn
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/figlet 1 1 1 1 8m
NAME DESIRED CURRENT READY AGE
rs/figlet-676c995d66 1 1 1 8m
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/figlet 1 1 1 1 8m
NAME DESIRED CURRENT READY AGE
rs/figlet-676c995d66 1 1 1 8m
NAME READY STATUS RESTARTS AGE
po/figlet-676c995d66-rqjpn 1/1 Running 0 8m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/figlet ClusterIP 10.101.45.157 8080/TCP 8m
相对于Docker Swarm,Kubernetes使用更多对象形成服务。激活服务查看结果:
https://www.docker.com/docker-mac
https://www.vagrantup.com/
https://github.com/ahmetb/kubectx
https://docs.docker.com/datacenter/ucp/2.2/guides/
https://news.ycombinator.com/item?id=16084243
本次培训包含:Kubernetes核心概念;Kubernetes集群的安装配置、运维管理、架构规划;Kubernetes组件、监控、网络;针对于Kubernetes API接口的二次开发;DevOps基本理念;微服务架构;微服务的容器化等,点击识别下方二维码加微信好友了解具体培训内容。