Current location - Quotes Website - Signature design - K8s system for deploying kubelet service
K8s system for deploying kubelet service
Kubelet is the main "node agent" running on each node. It can use one of the following to register with the apiserver: hostname replaces the parameter of the host name; Specific logic driven by the cloud.

Kubelet works based on PodSpec. Each PodSpec is a YAML or JSON object that describes the Pod. Kubelet accepts a set of POD specifications provided through various mechanisms, mainly through apiserver, and ensures that the containers described in these POD specifications are running and in good condition. Kubelet does not manage containers that were not created by Kubernetes.

Running on hdss01-221.host.com and hdss0 1-222.host.com: Host:

Issue kubelet certificate:

On the operation and maintenance host hdss0 1-200.host.com:

Create a json configuration file that generates a certificate signing request (csr):

Host: Write down the ip addresses that have been used and may be used. (Be sure to plan it first)

~]# cd /opt/certs/

certs]# vi kubelet-csr.json

{

" CN": "k8s-kubelet ",

"Host": [

" 127.0.0. 1",

" 10.4 1. 1.2 10",

" 10.4 1. 1.22 1",

" 10.4 1. 1.222",

" 10.4 1. 1.223",

" 10.4 1. 1.224",

" 10.4 1. 1.225",

" 10.4 1. 1.226",

" 10.4 1. 1.227",

" 10.4 1. 1.228"

],

"Key": {

"algorithm": "rsa",

"Size": 2048

},

"Name": [

{

“C”:“CN”,

Saint: Henan,

"l": "Zhengzhou",

“O”:“JX”,

"ou": "xxzx"

}

]

}

certs]# cfssl gencert-ca = ca . PEM-ca-key = ca-key . PEM-config = ca-config . JSON-profile = server kube let-CSR . JSON | cfssl-JSON-bare kube let

Copy the certificate to the operation nodes hdss01-221.host.com and hdss0 1-222.host.com:

CD/opt/kubernetes/server/bin/cert

scp hdss 0 1-200:/opt/certs/kube let . PEM。

scp hdss 0 1-200:/opt/certs/kube let-key . PEM

Create configuration kube delet. kube config:

Do it once, and the generated kubelet.kubeconfig will be copied to other nodes.

conf]# CD/opt/kubernetes/server/bin/conf

Set-Cluster:

Kubectl configuration set-cluster myk8s

-certificate-authority =/opt/kubernetes/server/bin/cert/ca . PEM

- embed-certs=true

-Server = On:

cert]# CD/opt/kubernetes/server/bin/conf

conf]# scp hdss 0 1-22 1:/opt/kubernetes/server/bin/conf/kube delet . kube config。

Prepare to pause the basic image:

Operate on the operation and maintenance host hdss0 1-200.host.com:

Download image:

certs]# docker pull kubernetes/pause

Label the mirror.

Certificate] # Wharf label F9D5DE079539 harbor.od.com/public/pause:latest

Upload to private library:

Harbor.od.com/public/pause:latest dock workers push

Create kubelet startup script:

On hdss01-221.host.com:

cat/opt/kubernetes/server/bin/kube let . sh

#! /bin/sh

. /Kublai

- anonymous-auth=false

-group c-drive system d

-cluster -dns 192. 168.0.2

- cluster-domain cluster.local

-runtime-cgroups =/systemd/system . slice

-kube let-cgroups =/systemd/system . slice

- fail-swap-on="false "

-client ca file. /cert/ca.pem

- tls-cert-file。 /cert/kubelet.pem

-TLS- private key-file. /cert/kubelet-key.pem

-hostname-override hdss01-221.host.com # hdss01-222 Make corresponding changes to hdss01-222.host.com.

-Image-Gas Chromatography-High Threshold 20

-image -GC- low threshold 10

- kubeconfig。 /conf/kube delet . kube config

-log-dir/data/logs/kubernetes/kube-kube let

-Pod-Infrared Container-Image harbor.od.com/public/pause:latest

- root-dir /data/kubelet

bin]# chmod +x kubelet.sh

bin]# mkdir-p/data/logs/kubernetes/kube-kube let/data/kube let

To create a supervisor configuration:

On hdss01-221.host.com:

bin]# cat/etc/supervisord . d/kube-kube let . ini

[Program: kube-kubelet-01-221] # hdss01-222.host.com changed to 22.

command =/opt/kubernetes/server/bin/kube let . sh; Program (relative path, with parameters)

num procs = 1; Number of process copies to start (def 1)

directory =/opt/kubernetes/server/bin; Directory where cwd went before exec (def no cwd)

Autostart = true starts with superuser (default: true).

Autorestart = true Restart when exiting unexpectedly (default: true).

Startsecs = 30 The number of seconds a program must keep running (defined. 1)

Number of retries started = 3; Maximum number of serial startup failures (default is 3)

exitcodes=0,2; Expected exit code of the process (default value is 0,2)

Stopsignal = exit; Signal to terminate a process (default term)

stopwaitsecs = 10; Maximum number of seconds to wait for b4 SIGKILL (default is 10).

User = rootsetuid to this UNIX account to run the program.

Redirect _ stderr = true Redirects the procedure stderr to stdout (false by default).

stdout _ log file =/data/logs/kubernetes/kube-kube let/kube let . stdout . log; Stderr log path, nothing to nothing. Default automatic

Stdout _ logfile _ maxbytes = 64MB Maximum log file bytes b4 Cycle (default is 50MB)

stdout _ log file _ backups = 4; Number of stdout log file backups (default is 10)

stdout _ capture _ max bytes = 1MB; Number of bytes in Capture Mode (default is 0)

Stdout _ events _ enabled = false Emits an event when stdout writes (default is false).

Bin]# Supervisor Update

Bin]# Supervisor Status

Bin]# kubectl get node

Add labels to roles, set node roles, and add two labels at the same time.

Bin]#kubectl label node hdss01-221.host.com node-role.kubernetes.io/master=.

Bin]# kubectl label node hdss01-221.host.com node-role.kubernetes.io/node=.

Bin]#kubectl tag node hdss01-222.host.com node-role.kubernetes.io/node=

Bin]# kubectl tag node hdss01-222.host.com node-role.kubernetes.io/master=