久久精品国产亚洲高清|精品日韩中文乱码在线|亚洲va中文字幕无码久|伊人久久综合狼伊人久久|亚洲不卡av不卡一区二区|精品久久久久久久蜜臀AV|国产精品19久久久久久不卡|国产男女猛烈视频在线观看麻豆

    1. <style id="76ofp"></style>

      <style id="76ofp"></style>
      <rt id="76ofp"></rt>
      <form id="76ofp"><optgroup id="76ofp"></optgroup></form>
      1. 千鋒教育-做有情懷、有良心、有品質(zhì)的職業(yè)教育機(jī)構(gòu)

        手機(jī)站
        千鋒教育

        千鋒學(xué)習(xí)站 | 隨時(shí)隨地免費(fèi)學(xué)

        千鋒教育

        掃一掃進(jìn)入千鋒手機(jī)站

        領(lǐng)取全套視頻
        千鋒教育

        關(guān)注千鋒學(xué)習(xí)站小程序
        隨時(shí)隨地免費(fèi)學(xué)習(xí)課程

        當(dāng)前位置:首頁  >  技術(shù)干貨  > Kubernetes指南從零開始搭建集群

        Kubernetes指南從零開始搭建集群

        來源:千鋒教育
        發(fā)布人:xqq
        時(shí)間: 2023-12-26 00:17:46 1703521066

        Kubernetes指南: 從零開始搭建集群

        在云計(jì)算時(shí)代,容器化已經(jīng)成為了一種廣泛使用的技術(shù),Kubernetes是其中的佼佼者,其作為一個(gè)容器編排平臺,在管理上的優(yōu)勢及其高可用性、易擴(kuò)展性深受企業(yè)和開發(fā)者的喜愛。在本文章中,我們將從零開始搭建Kubernetes集群,并解釋其中的技術(shù)知識點(diǎn)。

        1. 環(huán)境準(zhǔn)備

        在開始之前,需要先確定好環(huán)境,Kubernetes分為Master節(jié)點(diǎn)和Worker節(jié)點(diǎn),其中Master節(jié)點(diǎn)需要至少2個(gè),Worker節(jié)點(diǎn)至少1個(gè),硬件環(huán)境和軟件環(huán)境需要滿足一定的要求。硬件環(huán)境建議:

        - Master節(jié)點(diǎn):CPU 2核,內(nèi)存 2GB,硬盤 40GB以上

        - Worker節(jié)點(diǎn):CPU 4核,內(nèi)存 4GB,硬盤 40GB以上

        軟件環(huán)境建議:

        - 操作系統(tǒng):CentOS7.4以上

        - Docker:18.09.0以上

        - Kubeadm:1.20.1及以上

        2. 安裝Docker

        在CentOS系統(tǒng)下,我們可以執(zhí)行下方腳本安裝Docker:

        `bash

        $ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

        $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

        $ sudo yum install -y docker-ce-18.09.0 docker-ce-cli-18.09.0 containerd.io

        $ sudo systemctl start docker

        $ sudo systemctl enable docker

        3. 安裝Kubeadm我們可以執(zhí)行如下腳本安裝Kubeadm:`bash$ sudo vi /etc/sysctl.d/k8s.conf # 寫入如下內(nèi)容net.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1$ sudo sysctl --system$ sudo setenforce 0$ sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config $ sudo vi /etc/yum.repos.d/kubernetes.repo# 寫入如下內(nèi)容[kubernetes]name=Kubernetesbaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/enabled=1gpgcheck=0repo_gpgcheck=0gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg$ sudo yum install -y kubelet-1.20.1 kubeadm-1.20.1 kubectl-1.20.1 --disableexcludes=kubernetes$ sudo systemctl enable kubelet$ sudo systemctl start kubelet

        4. 搭建Master節(jié)點(diǎn)

        在搭建Master節(jié)點(diǎn)時(shí),我們需要先確定好IP地址,并編輯好如下配置文件:

        `yaml

        apiVersion: kubeadm.k8s.io/v1beta2

        kind: ClusterConfiguration

        kubernetesVersion: stable

        apiServer:

        certSANs:

        - "{{ Master節(jié)點(diǎn)IP地址 }}"

        controlPlaneEndpoint: "{{ Master節(jié)點(diǎn)IP地址 }}:6443"

        extraArgs:

        audit-log-path: /var/log/kubernetes/audit.log

        audit-log-maxage: "30"

        audit-log-maxbackup: "3"

        audit-log-maxsize: "100"

        authorization-mode: Node,RBAC

        enable-admission-plugins: NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,ResourceQuota

        runtime-config: api/all=true

        service-node-port-range: 30000-32767

        controllerManager:

        extraArgs:

        node-cidr-mask-size: "24"

        node-monitor-grace-period: "30s"

        pod-eviction-timeout: "2m"

        use-service-account-credentials: "true"

        networking:

        dnsDomain: cluster.local

        podSubnet: "10.244.0.0/16"

        serviceSubnet: "10.96.0.0/12"

        然后,我們在Master節(jié)點(diǎn)上執(zhí)行如下腳本:`bash$ sudo kubeadm init --config kubeadm-config.yaml

        在執(zhí)行完成后,我們可以看到如下輸出:

        `bash

        [init] Using Kubernetes version: v1.20.0

        [preflight] Running pre-flight checks

        [WARNING FileExisting-crictl]: crictl not found in system path

        [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'

        [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

        [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 [master-1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.1.120]

        [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 [localhost] and IPs [192.168.1.120 127.0.0.1 ::1]

        [certs] Generating "etcd/peer" certificate and key

        [certs] etcd/peer serving cert is signed for DNS names [localhost] and IPs [192.168.1.120 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

        [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

        [kubelet-check] Initial timeout of 40s passed.

        [apiclient] All control plane components are healthy after 80.001069 seconds

        [upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace

        [kubelet] Creating a ConfigMap "kubelet-config-1.20" in namespace kube-system with the configuration for the kubelets in the cluster

        [kubelet-start] Restarting the kubelet to use the new kubelet configuration

        [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

        [csr-approver] CSR approval is disabled. Nodes that match this CSR will be not be permitted to join the cluster. Passing --apiserver-advertise-address=0.0.0.0 may allow unauthorized nodes to join the cluster.

        [bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster

        [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 {{ Master節(jié)點(diǎn)IP地址 }}:6443 --token {{ Token }} \

        --discovery-token-ca-cert-hash sha256:{{ CA證書哈希值 }}

        在執(zhí)行完成后,我們需要執(zhí)行如下腳本,讓普通用戶也擁有使用Kubernetes的權(quán)限:`bash$ mkdir -p $HOME/.kube$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

        5. 搭建Worker節(jié)點(diǎn)

        在搭建Worker節(jié)點(diǎn)時(shí),我們需要使用之前Master節(jié)點(diǎn)輸出的join命令,并將其執(zhí)行在Worker節(jié)點(diǎn)上,如下:

        `bash

        $ sudo kubeadm join {{ Master節(jié)點(diǎn)IP地址 }}:6443 --token {{ Token }} \

        --discovery-token-ca-cert-hash sha256:{{ CA證書哈希值 }}

        執(zhí)行成功后,在Master節(jié)點(diǎn)上執(zhí)行如下腳本:`bash$ kubectl get nodes

        如果輸出了剛剛加入的Worker節(jié)點(diǎn)信息,說明Worker節(jié)點(diǎn)已經(jīng)成功加入到了集群中。

        至此,我們已經(jīng)成功搭建了一個(gè)Kubernetes集群,并且已經(jīng)加入了一個(gè)Worker節(jié)點(diǎn)。在實(shí)際生產(chǎn)環(huán)境中,我們還需要進(jìn)行更多的配置和優(yōu)化,例如網(wǎng)絡(luò)、存儲、高可用性等方面,這將在后續(xù)的文章中進(jìn)行探討。

        以上就是IT培訓(xùn)機(jī)構(gòu)千鋒教育提供的相關(guān)內(nèi)容,如果您有web前端培訓(xùn)鴻蒙開發(fā)培訓(xùn),python培訓(xùn),linux培訓(xùn),java培訓(xùn),UI設(shè)計(jì)培訓(xùn)等需求,歡迎隨時(shí)聯(lián)系千鋒教育。

        tags:
        聲明:本站稿件版權(quán)均屬千鋒教育所有,未經(jīng)許可不得擅自轉(zhuǎn)載。
        10年以上業(yè)內(nèi)強(qiáng)師集結(jié),手把手帶你蛻變精英
        請您保持通訊暢通,專屬學(xué)習(xí)老師24小時(shí)內(nèi)將與您1V1溝通
        免費(fèi)領(lǐng)取
        今日已有369人領(lǐng)取成功
        劉同學(xué) 138****2860 剛剛成功領(lǐng)取
        王同學(xué) 131****2015 剛剛成功領(lǐng)取
        張同學(xué) 133****4652 剛剛成功領(lǐng)取
        李同學(xué) 135****8607 剛剛成功領(lǐng)取
        楊同學(xué) 132****5667 剛剛成功領(lǐng)取
        岳同學(xué) 134****6652 剛剛成功領(lǐng)取
        梁同學(xué) 157****2950 剛剛成功領(lǐng)取
        劉同學(xué) 189****1015 剛剛成功領(lǐng)取
        張同學(xué) 155****4678 剛剛成功領(lǐng)取
        鄒同學(xué) 139****2907 剛剛成功領(lǐng)取
        董同學(xué) 138****2867 剛剛成功領(lǐng)取
        周同學(xué) 136****3602 剛剛成功領(lǐng)取
        相關(guān)推薦HOT
        Linux系統(tǒng)性能優(yōu)化常見問題及解決方式

        Linux 系統(tǒng)性能優(yōu)化:常見問題及解決方式Linux 系統(tǒng)性能優(yōu)化是系統(tǒng)管理員和運(yùn)維工程師必須具備的一項(xiàng)技能。一個(gè)優(yōu)化良好的系統(tǒng)能夠提高應(yīng)用程序...詳情>>

        2023-12-26 01:24:38
        理解Linux系統(tǒng)調(diào)優(yōu)提高服務(wù)性能的關(guān)鍵

        理解Linux系統(tǒng)調(diào)優(yōu): 提高服務(wù)性能的關(guān)鍵隨著互聯(lián)網(wǎng)的發(fā)展和普及,越來越多的企業(yè)和個(gè)人開始使用Linux系統(tǒng)來搭建服務(wù)。然而,隨著服務(wù)規(guī)模的不斷...詳情>>

        2023-12-26 01:15:50
        使用Kubernetes管理你的容器集群

        使用Kubernetes管理你的容器集群隨著云計(jì)算的興起,容器化技術(shù)越來越受到關(guān)注。容器化可以節(jié)省成本,提高部署效率,并提供更好的應(yīng)用程序可移植...詳情>>

        2023-12-26 01:14:04
        快速入門使用AWSEC2實(shí)現(xiàn)云服務(wù)器部署

        快速入門:使用AWS EC2實(shí)現(xiàn)云服務(wù)器部署AWS(亞馬遜云),是當(dāng)前全球最大的公有云提供商之一,EC2是AWS提供的一種云服務(wù)器。本文將介紹如何使用AW...詳情>>

        2023-12-26 01:12:19
        Kubernetes運(yùn)維指南從部署到監(jiān)控

        Kubernetes 運(yùn)維指南:從部署到監(jiān)控Kubernetes 是一個(gè)開源的容器編排平臺,它可以幫助我們更好地管理和部署容器化應(yīng)用程序。使用 Kubernetes 可...詳情>>

        2023-12-26 01:08:48
        快速通道
        铜鼓县| 辰溪县| 渝北区| 观塘区| 修文县| 贵阳市| 锡林郭勒盟| 金坛市| 修文县| 毕节市| 建宁县| 泰宁县| 应用必备| 南川市| 赤壁市| 平谷区| 吉林省| 丰宁| 彩票| 莱阳市| 邮箱| 高雄县| 绍兴市| 南漳县| 芮城县| 平乡县| 双辽市| 太保市| 东方市| 南宁市| 当阳市| 定州市| 石渠县| 武城县| 玉环县| 全州县| 绩溪县| 湖北省| 峨眉山市| 拉萨市| 安多县|