如何在Ubuntu上安装Kubernetes 1.4

Kubernetes是生产级的容器编排工具,它自动化了容器的部署、扩展和管理。这是一个谷歌产品,用于 谷歌 内部。Kubernetes较新,因为它是灵活的。Kubernetes是开源的,因此没有限制、费用等。一些使用Kubernetes的公司有Pearson、Ebay和Wikimedia。Kubernetes具有动态扩展应用程序的能力。

Box Thermal Bag Bento Pouch Lunch Container School Food Box
| 月销量9件
优惠价10.34元
原价¥22

淘口令:

¥4ISOXt90i2V¥
 

安装Kubernetes

我们首先下载Google的存储库密钥 乌班图 把它们加到钥匙圈里。

$ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100   663  100   663    0     0    775      0 --:--:-- --:--:-- --:--:--   776 OK

我们将所需的存储库添加到sources.list中

$ sudo cat < /etc/apt/sources.list.d/kubernetes.list > deb http://apt.kubernetes.io/ kubernetes-xenial main > EOF

更新我们的申请表以获取kubernetes的信息。

$ sudo apt-get update Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease ...

并从google存储库安装kubernetes包。

$ sudo apt-get install -y docker.io kubelet kubeadm kubectl kubernetes-cni

我们安装了所有其他的系统 将加入kubernetes星系团。我们实现了kubernetes安装部分中描述的相同命令。

初始化Kubernetes群集

我们将使用以下命令初始化集群头。

$ sudo kubeadm init  generated token: "3e313d.c5d75f78f4f9db27"  created keys and certificates in "/etc/kubernetes/pki"  created "/etc/kubernetes/kubelet.conf"  created "/etc/kubernetes/admin.conf"  created API client configuration  created API client, waiting for the control plane to become ready  all control plane components are healthy after 46.303552 seconds  waiting for at least one node to register and become ready  first node is ready after 3.502990 seconds  created essential addon: kube-discovery, waiting for it to become ready  kube-discovery is ready after 38.002656 seconds  created essential addon: kube-proxy  created essential addon: kube-dns  Kubernetes master initialised successfully!  You can now join any number of machines by running the following on each node:  kubeadm join --token 3e313d.c5d75f78f4f9db27 192.168.122.13

我们的第二个系统叫做poftut5。如前所述,我们已经安装了kubernetes。我们将运行“kubeadm join–token 3e313d.c5d75f78f4f9db27 192.168.122.137 由poftut4生产。

$ sudo kubeadm join --token 3e313d.c5d75f78f4f9db27 192.168.122.137  validating provided token  created cluster info discovery client, requesting info from "http://192.168.122.137:9898/cluster-info/v1/?token-id=3e313d"  cluster info object received, verifying signature using given token  cluster info signature and contents are valid, will use API endpoints [https://192.168.122.137:443]  created API client to obtain unique certificate for this node, generating keys and certificate signing request  received signed certificate from the API server, generating kubelet configuration  created "/etc/kubernetes/kubelet.conf"  Node join complete: * Certificate signing request sent to master and response   received. * Kubelet informed of new secure connection details.  Run 'kubectl get nodes' on the master to see this machine join.

在poftut4上,我们将检查poftut5是否加入集群。

$ kubectl get nodes NAME      STATUS    AGE poftut4   Ready     21m poftut5   Ready     2m

很好,似乎一切都好。我们可以看到我们的两个系统连接到kubernetes星团 他们的状态已经准备好了。

相关文章: 如何在Docker中获取有关运行容器、图像的信息?

使系统在库伯内特斯行话豆荚沟通。使用followinf命令安装daemong。

$ kubectl apply -f https://git.io/weave-kube daemonset "weave-net" created

部署测试应用程序

我们使用github项目作为测试应用程序。我们用git完成了这个项目。

$ git clone https://github.com/microservices-demo/microservices-demo Cloning into 'microservices-demo'... remote: Counting objects: 4885, done....

我们使用应用程序提供的部署清单,如下所示

$ kubectl apply -f microservices-demo/deploy/kubernetes/manifests deployment "cart-db" created service "cart-db" created deployment "cart" created service "cart" created deployment "catalogue-db" created service "catalogue-db" created...

在这里创建容器。我们可以通过发布kubectl get pods来获取信息。

$ kubectl get pods NAME                           READY     STATUS              RESTARTS   AGE cart-3694116665-8ovlg          1/1       Running             0          1m cart-db-2305146297-6zvky       0/1       ContainerCreating   0          1m catalogue-11453786-yu44e       0/1       ContainerCreating   0          1m catalogue-db-393939662-fm3g6   0/1       ContainerCreating   0          1m front-end-3820830240-zojqb     0/1       ContainerCreating   0          1m orders-3498886496-qbafq        0/1       ContainerCreating   0          1m orders-db-1775353731-0knx5     0/1       ContainerCreating   0          1m payment-3012088042-edphj       0/1       ContainerCreating   0          1m queue-master-936560853-zaiqj   0/1       ContainerCreating   0          1m rabbitmq-1897447621-242ds      0/1       ContainerCreating   0          1m shipping-1232389217-mraq4      0/1       ContainerCreating   0          1m user-3090014237-y7q8m          0/1       ContainerCreating   0          1m user-db-1338754314-nu2sp       0/1       ContainerCreating   0          1m

集装箱制造 表示它正在进行,而当前应用程序没有运行。

2分钟后,如果我们再次发出命令,我们可以看到一些pod正在运行,另一些正在创建。

$ kubectl get pods NAME                           READY     STATUS              RESTARTS   AGE cart-3694116665-8ovlg          1/1       Running             0          3m cart-db-2305146297-6zvky       1/1       Running             0          3m catalogue-11453786-yu44e       1/1       Running             0          3m catalogue-db-393939662-fm3g6   1/1       Running             0          3m front-end-3820830240-zojqb     1/1       Running             0          3m orders-3498886496-qbafq        1/1       Running             0          3m orders-db-1775353731-0knx5     1/1       Running             0          3m payment-3012088042-edphj       0/1       ContainerCreating   0          3m queue-master-936560853-zaiqj   0/1       ContainerCreating   0          3m rabbitmq-1897447621-242ds      0/1       ContainerCreating   0          3m shipping-1232389217-mraq4      0/1       ContainerCreating   0          3m user-3090014237-y7q8m          0/1       ContainerCreating   0          3m user-db-1338754314-nu2sp       0/1       ContainerCreating   0          3m

我们可以看到前端 服务 状态,并使用descripe命令获取有关它们的信息。

$ kubectl describe svc front-end Name:                   front-end Namespace:              default Labels:                 name=front-end Selector:               name=front-end Type:                   NodePort IP:                     100.70.194.72 Port:                    80/TCP NodePort:                31425/TCP Endpoints:               Session Affinity:       None

从Kubernetes集群中删除Pod

我们已经成功地部署了我们的应用程序。但如果我们想毁掉它呢。它类似于安装程序只是使用 删除 命令 库贝克特 .

$ kubectl delete -f microservices-demo/deploy/kubernetes/manifests deployment "cart-db" deleted service "cart-db" deleted deployment "cart" deleted service "cart" deleted deployment "catalogue-db" deleted service "catalogue-db" deleted deployment "catalogue" deleted service "catalogue" deleted deployment "front-end" deleted service "front-end" deleted networkpolicy "cart-access" deleted networkpolicy "cart-db-access" deleted networkpolicy "catalogue-access" deleted networkpolicy "catalogue-db-access" deleted networkpolicy "front-end-access" deleted networkpolicy "orders-access" deleted networkpolicy "orders-db-access" deleted networkpolicy "payment-access" deleted networkpolicy "prism-access" deleted networkpolicy "rabbitmq-access" deleted networkpolicy "shipping-access" deleted networkpolicy "user-access" deleted networkpolicy "user-db-access" deleted deployment "orders-db" deleted service "orders-db" deleted deployment "orders" deleted service "orders" deleted deployment "payment" deleted service "payment" deleted deployment "queue-master" deleted service "queue-master" deleted deployment "rabbitmq" deleted service "rabbitmq" deleted deployment "shipping" deleted service "shipping" deleted deployment "user-db" deleted service "user-db" deleted deployment "user" deleted service "user" deleted

如何在Ubuntu Infographic上安装Kubernetes 1.4

How to Setup Kubernetes 1.4 on Ubuntu Infographic
如何在Ubuntu Infographic上安装Kubernetes 1.4

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞0
分享