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

Kubernetes basic Cluster deployment of Advanced docker (part two) (34)

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!

Original link address: kubernetes basic cluster deployment of docker (part two) (34)

This time continue the deployment of the simple version of the cluster (part two). Source code: https://github.com/limingios/msA-docker K8s branch and https://github.com/limingios/kubernetes-starter

Introduction to deploying Scheduler (Master Node)

Kube-scheduler is responsible for assigning the dispatching Pod to the nodes in the cluster, listening to the kube-apiserver, querying the Pod of the unallocated Node, and then assigning nodes to these Pod according to the scheduling policy. It implements the various scheduling strategies of kubernetes that we mentioned earlier.

Deployment

Deploy through system services

Cp ~ / kubernetes-starter/target/master-node/kube-scheduler.service / lib/systemd/system/systemctl enable kube-scheduler.serviceservice kube-scheduler startjournalctl-f-u kube-scheduler

Key configuration instructions vi / lib/systemd/system/kube-scheduler.service

[Unit]

Description=Kubernetes Scheduler

...

[Service]

ExecStart=/home/michael/bin/kube-scheduler\

# the listening address of the external service, which means that only local programs can access it

-- address=127.0.0.1\

# url of apiserver

-- master= http://127.0.0.1:8080\

...

PS: the three most important core components are deployed

Deploy CalicoNode (all nodes)

It is accomplished by adding docker to the system service.

Brief introduction

Calico implements the CNI interface, which is a choice of kubernetes network solution. It is a pure three-layer data center network scheme (without Overlay), and has good integration with IaaS and container platforms such as OpenStack, Kubernetes, AWS, GCE and so on.

Calico uses Linux Kernel to implement an efficient vRouter for data forwarding at each computing node, and each vRouter is responsible for transmitting the routing information of the workload running on it like the whole Calico network through the BGP protocol-small-scale deployment can be directly interconnected, and large-scale deployment can be done through a specified BGP route reflector. This ensures that all data traffic between workload is interconnected through IP routing.

Deployment

Calico is completed through system service + docker.

Cp ~ / kubernetes-starter/target/all-node/kube-calico.service / lib/systemd/system/systemctl enable kube-calico.serviceservice kube-calico startjournalctl-f-u kube-calico

View the configuration vi / lib/systemd/system/kube-calico.service

Calico usability verification

Check the container operation

Docker ps

View the operation of the node

Calicoctl node status

Check that the port BGP protocol establishes neighbors through TCP connections, so you can verify BGP Peer with the netstat command

Netstat-natp | grep ESTABLISHED | grep 179

View cluster ippool status [master node]

Calicoctl get ipPool-o yaml

5.4 key configuration description

[Unit]

Description=calico node

...

[Service]

# run in docker mode

ExecStart=/usr/bin/docker run-net=host-privileged-name=calico-node\

# specify etcd endpoints (this is mainly responsible for the consistency of network metadata to ensure the accuracy of Calico network status)

-e ETCD_ENDPOINTS= http://192.168.66.101:2379\

# Network address range (same as ControllerManager above)

-e CALICO_IPV4POOL_CIDR=172.20.0.0/16\

# Image name. In order to speed up everyone's download speed, the image is put on Ali Cloud.

Registry.cn-hangzhou.aliyuncs.com/imooc/calico-node:v2.6.2

Introduction to configuring the kubectl command (master node)

Kubectl is a command line tool of Kubernetes and a necessary management tool for Kubernetes users and administrators.

Kubectl provides a large number of subcommands to facilitate the management of various functions in the Kubernetes cluster.

Initialization

The first step in using kubectl is to configure Kubernetes clusters and authentication methods, including:

Cluster information: api-server address user information: a combination of user name, password or key Context:cluster, user information, and Namespace

We don't have anything about security here, we just need to set up the api-server and context:

# specify apiserver address (replace ip with your own api-server address) kubectl config set-cluster kubernetes-server= http://192.168.66.101:8080# specify setting context, specify clusterkubectl config set-context kubernetes-- cluster=kubernetes# choose the default context kubectl config use-context kubernetes

The ultimate goal of the above settings is to generate a configuration file: ~ / .kube / config, of course, you can also handwrite or copy a file there, so you don't need the above command.

Introduction to configuring kubelet (2 machines of worker node 102103)

Each worker node runs a kubelet service process, which listens to port 10250 by default, receives and executes instructions from master, and manages containers in Pod and Pod. Each kubelet process registers the node's own information on the API Server, regularly reports the node's resource usage to the master node, and monitors the node and container resources through cAdvisor.

Deployment

Deploy through system services, but there will be more steps, as follows:

# make sure that there is mkdir-p / var/lib/kubeletmkdir-p / etc/kubernetesmkdir-p / etc/cni/net.d# replication kubelet service profile cp / kubernetes-starter/target/worker-node/kubelet.service / lib/systemd/system/# replication kubelet dependent configuration file cp ~ / kubernetes-starter/target/worker-node/kubelet.kubeconfig / etc/kubernetes/# replication kubelet plug-in configuration file cp ~ / kubernetes-starter/ Target/worker-node/10-calico.conf / etc/cni/net.d/systemctl enable kubelet.serviceservice kubelet startjournalctl-f-u kubelet

The master node views the information of node kubectl get nodes

Key configuration instructions

Kubelet.service

[Unit]

Description=Kubernetes Kubelet

[Service]

# kubelet working directory, which stores current node container, pod and other information

WorkingDirectory=/var/lib/kubelet

ExecStart=/home/michael/bin/kubelet\

# listening address of external service

-- address=192.168.66.103\

# specify the image of the basic container, which is responsible for creating shared networks and file systems within Pod. This basic container is very important: every POD running in K8S must contain this basic container. If it is not running, then your POD will definitely not be created.

-- pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/imooc/pause-amd64:3.0\

# access cluster configuration, such as api-server address, etc.

-- kubeconfig=/etc/kubernetes/kubelet.kubeconfig\

# declare the cni network plug-in

-- network-plugin=cni\

# cni network configuration directory, where kubelet will read the network configuration

-- cni-conf-dir=/etc/cni/net.d\

# specify the Service IP of the kubedns (you can assign it first, and then specify the IP when you create the kubedns service later), and-- cluster-domain specify the domain name suffix. These two parameters will not take effect until both parameters are specified.

-- cluster-dns=10.68.0.2\

...

Kubelet.kubeconfig

A configuration that kubelet depends on, which is also the yaml format that we often encounter later, describes how kubelet accesses apiserver.

ApiVersion: v1

Clusters:

-cluster:

# Skip tls, that is, the authentication of kubernetes

Insecure-skip-tls-verify: true

# api-server address

Server: http://192.168.1.102:8080

...

Calico.conf

Configuration of calico as a CNI plug-in for kubernets

{"name": "calico-k8s-network", "cniVersion": "0.1.0", "type": "calico", "ed_endpoints": "http://192.168.1.102:2379"," logevel ":" info "," ipam ": {" type ":" calico-ipam "} "kubernetes": {"k8s_api_root": "http://192.168.1.102:8080"}}"

PS: you need to read the log every time you install it. Don't think it's troublesome to read the log. The purpose of reading the log is to avoid the following problems. Take one step at a time! If problems arise in the follow-up, it will be even more troublesome. Next time, buddy, let's do some tests and exercises on this cluster.

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

Wechat

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

12
Report