Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy k8s of Docker

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to deploy Docker K8s, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Preparatory work system

Install Ubuntu 14.04 LTS 64bit server version of the system, configure hostname and ip.

When updating domestic software sources, md5 verification errors often occur due to GFW reasons. It is recommended to use Aliyun's source.

Docker

To install Docker on the minion node, version 1.2 is required, and 1.7.1 is installed here. For installation methods, see Docker installation (Ubuntu 64bit).

After installing Docker, we'd better configure a domestic registry mirror to speed up the image pull speed. Refer to the configuration of domestic free registry mirror.

Google pause

Download the Google pause image for each minion. Gcr.io/google_containers/pause image will be used for later work. Domestic users always make errors due to GFW problems, so we first download pause image from docker.io and set tag.

# docker pull docker.io/kubernetes/pause# docker tag kubernetes/pause gcr.io/google_containers/pause:0.8.0# docker tag gcr.io/google_containers/pause:0.8.0 gcr.io/google_containers/pause

SSH

All minion nodes need to be able to log in directly from the master node without a password.

On the master node, do the following:

$ssh-keygen$ ssh-copy-id user@192.168.0.201$ ssh-copy-id user@192.168.0.202$ ssh-copy-id user@192.168.0.203

Deploy the cluster

download

Download the deployment script and binaries.

First download the deployment script from the github repository of K8S.

$git clone https://github.com/kubernetes/kubernetes.git

Modify the version of each component and download the binaries for all components. Here we use etcd 2.2.0, flashing 0.5.0, k8s 1.0.6.

$cd kubernetes/cluster/ubuntu$ vim build.sh # modified version # version setting FLANNEL_VERSION= "0.5.0" ETCD_VERSION= "2.2.0" KUBE_VERSION= "1.0.6" $. / build.sh

Sometimes there will be an error when downloading using a non-root account. At this time, we can switch to the root permission to download, and then use the chown command to set the file permission to the original account.

The following structure in the directory binaries indicates success.

Configuration

Open the cluster/ubuntu/config-default.sh file and modify the following fields:

Export nodes=$ {nodes:- "wangtao@192.168.0.201 wangtao@192.168.0.202 wangtao@192.168.0.203"} export role=$ {role:- "an i i"} export NUM_MINIONS=$ {NUM_MINIONS:-2} export SERVICE_CLUSTER_IP_RANGE=$ {SERVICE_CLUSTER_IP_RANGE:-10.0.1.0/24} export FLANNEL_NET=$ {FLANNEL_NET:-172.16.0.0/16}

If you need a master node to also act as a minion node, simply change an in role to ai, and NUM_MINIONS represents the number of minion nodes.

Service_cluster_ip_range represents the IP range corresponding to service in the cluster.

Flannel_net represents the IP range assigned by pod.

Deployment

Go to the cluster/ directory and do the following

$export KUBERNETES_PROVIDER=ubuntu$. / kube-up.sh

The script then copies the binaries to the appropriate node, but requires root permission to run the service, so we need to enter a password for each node.

test

We can use the kubectl tool to test whether the installation is successful.

First we add the path of kubectl to PATH, and then we can use the command directly.

Let's start a Redis service and try it.

Enter the examples/guestbook directory and modify the redis-master-controller.yaml file as follows:

ApiVersion: v1kind: ReplicationControllermetadata: name: redis-master labels: name: redis-masterspec: replicas: 2 selector: name: redis-master template: metadata: labels: name: redis-masterspec: containers:-name: master image: redis ports:-containerPort: 6379

Then run the following command to start Redis.

$kubectl create-f redis-master-controller.yaml

Then use kubectl get rc and kubectl get pods to see if it was successful.

If the status of each pod is Running, the deployment is successful.

You may encounter the problem that the pod status has been in Penning all the time. You can view the pod information through kubectl describe pods/pod-name. If there is no error message, Minion has been in the download image. After the download, pod will start successfully.

Dynamic management Cluster

If the cluster is already deployed, we want to be able to add and remove Minion nodes dynamically.

One way is to use kube-down.sh to stop all nodes, modify the config-default.sh file to add the newly added node information, or delete the unused node information, and then restart using the kube-up.sh script.

Of course we want to be able to dynamically add new Minion nodes without shutting down existing nodes, but I haven't found a way yet.

These are all the contents of the article "how to deploy Docker's K8s". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report