首页 > 其他分享 >国产化麒麟操作系统部署K8S

国产化麒麟操作系统部署K8S

时间:2024-07-20 18:26:09浏览次数:17  
标签:国产化 kubernetes etc -- kubelet certs key K8S 操作系统

国产化银河麒麟操作系统(Kylin)部署K8S集群

一、K8S集群节点准备

1.1 主机操作系统说明

序号操作系统及版本备注
1Kylin-Server-10-SP2-x86

1.2 主机硬件配置说明

需求CPU内存硬盘角色主机名
4C8G100GBslave1slave1
4C8G100GBslave2slave2

1.3 主机配置

1.3.1 主机名配置

由于本次使用2台主机完成kubernetes集群部署,其中1台为master节点,名称为slave1;其中1台为slave2节点,名称分别为:slave2

slave1节点
# hostnamectl set-hostname salve1
salve2节点
# hostnamectl set-hostname slave2



### 1.3.2 主机IP地址配置



~~~powershell
salve1节点IP地址为:192.168.71.102/24
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.71.102"
PREFIX="24"
GATEWAY="192.168.71.2"
DNS1="8.8.8.8"
salve2节点IP地址为:192.168.71.103/24
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.71.103"
PREFIX="24"
GATEWAY="192.168.71.2"
DNS1="8.8.8.8"

1.3.3 主机名与IP地址解析

所有集群主机均需要进行配置。

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.71.102 slave1
192.168.71.103 salve2

1.3.4 防火墙配置

所有主机均需要操作。

关闭现有防火墙firewalld
# systemctl disable firewalld
# systemctl stop firewalld
# firewall-cmd --state
not running

1.3.5 SELINUX配置

所有主机均需要操作。修改SELinux配置需要重启操作系统。

# sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

1.3.6 时间同步配置

所有主机均需要操作。最小化安装系统需要安装ntpdate软件。

# crontab -l
0 */1 * * * /usr/sbin/ntpdate time1.aliyun.com

1.3.7 配置内核转发及网桥过滤

所有主机均需要操作。

添加网桥过滤及内核转发配置文件
# cat /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness = 0
加载br_netfilter模块
# modprobe br_netfilter
查看是否加载
# lsmod | grep br_netfilter
br_netfilter           22256  0
bridge                151336  1 br_netfilter

1.3.8 安装ipset及ipvsadm

所有主机均需要操作。

安装ipset及ipvsadm
# yum -y install ipset ipvsadm
配置ipvsadm模块加载方式
添加需要加载的模块
# cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
授权、运行、检查是否加载
# chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack

1.3.9 关闭SWAP分区

修改完成后需要重启操作系统,如不重启,可临时关闭,命令为swapoff -a

临时关闭
# swapoff -a
永远关闭swap分区,需要重启操作系统
# cat /etc/fstab
......

# /dev/mapper/centos-swap swap                    swap    defaults        0 0

在上一行中行首添加#

二、 Docker准备

2.1 Docker安装包准备

二进制方式安装

2.2 Docker安装

链接:https://pan.baidu.com/s/1Tm4sdpM2eInUKhrf9aZYrQ?pwd=v63r
提取码:v63r
–来自百度网盘超级会员V3的分享

# tar -xzxf docker-19.03.10.tgz
# chmod +x docker/*
# cp docker/* /usr/bin/

2.3 启动Docker服务

# vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
 
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
 
[Install]
WantedBy=multi-user.target
# systemctl enable --now docker

2.4 修改cgroup方式

/etc/docker/daemon.json 默认没有此文件,需要单独创建

在/etc/docker/daemon.json添加如下内容

# cat /etc/docker/daemon.json
{
        "exec-opts": ["native.cgroupdriver=systemd"]
}
# systemctl restart docker

三、kubernetes 1.23.6 集群部署

3.2 kubernetes YUM源准备

3.2.1 谷歌YUM源

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

3.2.2 阿里云YUM源

[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

3.3 集群软件安装

所有节点均可安装

默认安装
# yum -y install  kubeadm  kubelet kubectl
查看指定版本
# yum list kubeadm.x86_64 --showduplicates | sort -r
# yum list kubelet.x86_64 --showduplicates | sort -r
# yum list kubectl.x86_64 --showduplicates | sort -r
安装指定版本
# yum -y install  kubeadm-1.23.6-0  kubelet-1.23.6-0 kubectl-1.23.6-0



## 3.4 配置kubelet

>为了实现docker使用的cgroupdriver与kubelet使用的cgroup的一致性,建议修改如下文件内容。



~~~powershell
# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--cgroup-driver=systemd"
设置kubelet为开机自启动即可,由于没有生成配置文件,集群初始化后自动启动
# systemctl enable kubelet

3.5 集群镜像准备

可使用VPN实现下载。

# kubeadm config images list --kubernetes-version=v1.23.6
 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers:kube-apiserver:v1.23.6

3.6 集群初始化

K8S 1.23.6版本集群初始化
[root@k8s-master01 ~]# kubeadm init --kubernetes-version=v1.23.6 --pod-network-cidr=10.224.0.0/16 --apiserver-advertise-address=192.168.71.102
初始化过程输出
[init] Using Kubernetes version: v1.23.6
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-master01 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.71.200]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-master01 localhost] and IPs [192.168.10.200 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-master01 localhost] and IPs [192.168.10.200 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 13.006785 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node k8s-master01 as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node k8s-master01 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule node-role.kubernetes.io/control-plane:NoSchedule]
[bootstrap-token] Using token: 8x4o2u.hslo8xzwwlrncr8s
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.71.102:6443 --token 8x4o2u.hslo8xzwwlrncr8s \
        --discovery-token-ca-cert-hash sha256:7323a8b0658fc33d89e627f078f6eb16ac94394f9a91b3335dd3ce73a3f313a0

3.7 集群应用客户端管理集群文件准备

[root@k8s-master01 ~]# mkdir -p $HOME/.kube
[root@k8s-master01 ~]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@k8s-master01 ~]# chown $(id -u):$(id -g) $HOME/.kube/config
[root@k8s-master01 ~]# ls /root/.kube/
config

3.8 集群网络准备

链接:https://pan.baidu.com/s/14r7g_4E0kKNygZnWKd5U2Q?pwd=hslo
提取码:hslo
–来自百度网盘超级会员V3的分享
在这里插入图片描述

3.9 集群工作节点添加

K8S 1.23版本集群加入方法
[root@k8s-worker0X ~]# kubeadm join 192.168.71.102:6443 --token 8x4o2u.hslo8xzwwlrncr8s \                              --discovery-token-ca-cert-hash sha256:7323a8b0658fc33d89e627f078f6eb16ac94394f9a91b3335dd3ce73a3f313a0

标签:国产化,kubernetes,etc,--,kubelet,certs,key,K8S,操作系统
From: https://blog.csdn.net/weixin_46544841/article/details/140533212

相关文章

  • 麒麟 V10 桌面操作系统使用 root 登录
    国产化的趋势已经势不可挡,首先考虑的就是麒麟操作系统,分为桌面版本和服务器版本。桌面版本的Linux命令使用体验跟Ubuntu基本一致。服务器版本的Linux命令使用体验跟CentOS7基本一致。由于越来越多的项目,在开发时就要求在Linux系统下开发,各种开发工具安装都非常方便,比......
  • 【Windows】操作系统之任务管理器(第一篇)
    一、操作系统简介Windows操作系统是由微软公司(Microsoft)开发的一款图形操作系统,它以其强大的功能和广泛的用户基础,成为了目前世界上用户使用最多、兼容性最强的操作系统之一。以下是关于Windows操作系统的详细介绍:一、历史与发展起源:Windows操作系统的历史可以追溯到1983年,......
  • k8s 集群安装
    决定重新搭建一个k8s集群,记录一下过程。本次使用三台主机,分别是master节点和两个worker节点。主机配置统一如下:配置项配置OSUbuntu22.04.4LTSx86_64Kernel5.15.0-102-genericCPUAMDRyzen75700X(16)@3.399GHzMemory8GDisk100GClust......
  • FreeRTOS【面试】实时操作系统的知识总结
    RTOS的实时性是如何实现的?任务之间是如何通信的?二值信号量与互斥信号量的区别?优先级反转?如何解决优先级反转问题?任务通知是怎么实现的?框架性的回答一个嵌入式系统Freertos的启动到结束的过程?任务切换的原理? 除了任务切换对freertos其他底层了解吗?讲讲FreeRT......
  • 银河麒麟桌面操作系统V10(SP1)
    系统初始化操作cat/etc/os-release1、开启root登录输入命令:sudopasswdroot回车。输入普通用户的密码后,输入新的root密码(建议密码由字母大小写、数字、符号组成)。2、配置主机静态IP#vim/etc/network/interfaces3、配置本地ISOapt源sudocp/etc/apt/sources.lis......
  • 信创终端操作系统上定时任务crontab详解 _ 统信 _ 麒麟 _ 中科方德
    原文链接:信创终端操作系统上定时任务crontab详解|统信|麒麟|中科方德Hello,大家好啊!今天给大家带来一篇关于在信创终端系统上使用定时任务工具crontab的详解文章。crontab是Unix和类Unix操作系统中的一个非常强大的工具,用于定时执行命令或脚本。本文将详细介绍如何在......
  • FreeRTOS操作系统(详细速通篇)——— 第四章
             本专栏将对FreeRTOS进行快速讲解,带你了解并使用FreeRTOS的各部分内容。适用于快速了解FreeRTOS并进行开发、突击面试、对新手小白非常友好。期待您的后续关注和订阅!目录任务创建和删除1任务创建方式1.1动态任务创建1.2静态任务创建2任务删除函数......
  • FreeRTOS操作系统(详细速通篇)——— 第一章
            本专栏将对FreeRTOS进行快速讲解,带你了解并使用FreeRTOS的各部分内容。适用于快速了解FreeRTOS并进行开发、突击面试、对新手小白非常友好。期待您的后续关注和订阅目录1FreeRTOS简介1.1 什么为FreeRTOS?1.2为什么选择FreeRTOS?1.3FreeRTOS与裸机的区......
  • Linux操作系统Redhat<>--用户与组
    用户(超级、系统、普通)用户分类:1、超级用户。用来管理操作系统,它的权限非常高。一般是创建用户等条件下使用。它的编号为0(uid)。2、普通用户。用来登录操作系统,使用操作系统的功能。它的编号范围1000-600003、系统用户。确保系统能够正常运行。不用来登录。它的编号范围1-99......
  • 在K8S中,什么是CNI?平时K8s集群常用什么网络插件?
    1.什么是CNI?CNI(ContainerNetworkInterface)是容器网络接口,它是一种标准的设计,旨在简化容器网络配置的过程。CNI允许容器在创建或销毁时动态地配置网络。CNI插件负责为容器配置和管理IP地址,并提供与IP管理、每个容器的IP分配以及多主机连接相关的功能。CNI的主要作用是......