真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

kubernetes集群安裝指南:客戶端安裝及各組件認(rèn)證文件創(chuàng)建

大多情況,證書用于服務(wù)安全訪問(wèn)(即https訪問(wèn))所需要,在kubernetes集群中,如果關(guān)閉了匿名訪問(wèn),開啟了集群HTTPS訪問(wèn)以及TLS雙向認(rèn)證;如:worker節(jié)點(diǎn)組件HTTPS訪問(wèn)apiserver服務(wù)時(shí),Apiserver還需要驗(yàn)證客戶端是否合法,此時(shí)就需要為worker節(jié)點(diǎn)上的組件生成kubeconfig認(rèn)證文件用于連接apiserver。

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、赫山ssl等。為成百上千企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的赫山網(wǎng)站制作公司

1. 基本設(shè)置

1.1 變量設(shè)置
PACKAGE=kubernetes-server-v1.12.0-linux-amd64.tar.gz
K8S_DOWNLOAD_URL=https://github.com/devops-apps/download/raw/master/kubernetes/$PACKAGE
K8S_CONF_PATH=/etc/k8s/kubernetes
K8S_KUBECONFIG_PATH=/etc/k8s/kubeconfig
KUBE_APISERVER=https://dev-kube-api.mo9.com
BOOTSTRAP_TOKEN=$(head -c 16 /dev/urandom | od -An -t x | tr -d ' ')
1.2 kubectl、kubens工具集安裝
sudo wget $K8S_DOWNLOAD_URL -P /root/software
cd $SOFTWARE 
tar -xzfkubernetes-server-v1.12.0-linux-amd64.tar.gz -C ./
cp -fp kubernetes/server/bin/{kubectl,kubens} /usr/local/sbin
1.3 創(chuàng)建認(rèn)證文件存放目錄
if [ ! -d "$K8S_CONF_PATH" ]; then
     mkdir -p $K8S_CONF_PATH
fi

if [ ! -d "$K8S_KUBECONFIG_PATH" ]; then
     mkdir -p $K8S_KUBECONFIG_PATH
fi

2. 創(chuàng)建 TLS Bootstrapping Token

cat > ${K8S_CONF_PATH}/token.csv <
  • bootstrapping token文件主要用于為apiserver開啟tocken認(rèn)證而創(chuàng)建,如果沒有開啟apiserver token認(rèn)證可以不用創(chuàng)建此文件;

3 kubeconfig文件創(chuàng)建

3.1 創(chuàng)建kube-controller-manager kubeconfig文件
kubectl config set-cluster kubernetes \
  --certificate-authority=${CA_DIR}/ca.pem \
  --embed-certs=true \
  --server=${KUBE_APISERVER} \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-controller-manager.kubeconfig

kubectl config set-credentials system:kube-controller-manager \
  --client-certificate=${CA_DIR}/kube-controller-manager.pem \
  --client-key=${CA_DIR}/kube-controller-manager-key.pem \
  --embed-certs=true \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-controller-manager.kubeconfig

kubectl config set-context system:kube-controller-manager \
  --cluster=kubernetes \
  --user=system:kube-controller-manager \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-controller-manager.kubeconfig

kubectl config use-context system:kube-controller-manager \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-controller-manager.kubeconfig
3.2 創(chuàng)建kube-shceduler kubeconfig文件
kubectl config set-cluster kubernetes \
  --certificate-authority=${CA_DIR}/ca.pem \
  --embed-certs=true \
  --server=${KUBE_APISERVER} \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-scheduler.kubeconfig

kubectl config set-credentials system:kube-scheduler \
  --client-certificate=${CA_DIR}/kube-scheduler.pem \
  --client-key=${CA_DIR}/kube-scheduler-key.pem \
  --embed-certs=true \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-scheduler.kubeconfig

kubectl config set-context system:kube-scheduler \
  --cluster=kubernetes \
  --user=system:kube-scheduler \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-scheduler.kubeconfig

kubectl config use-context system:kube-scheduler \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-scheduler.kubeconfig
3.3 創(chuàng)建kubelet bootstrapping kubeconfig文件
kubectl config set-cluster kubernetes \
  --certificate-authority=${CA_DIR}/ca.pem \
  --embed-certs=true \
  --server=${KUBE_APISERVER} \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/bootstrap.kubeconfig

kubectl config set-credentials kubelet-bootstrap \
  --token=${BOOTSTRAP_TOKEN} \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/bootstrap.kubeconfig

kubectl config set-context default \
  --cluster=kubernetes \
  --user=kubelet-bootstrap \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/bootstrap.kubeconfig

kubectl config use-context default \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/bootstrap.kubeconfig
  • bootstrapping文件主要用于apiserver給kubelet證書做自動(dòng)輪轉(zhuǎn),使用該文件,apiserver會(huì)自動(dòng)給kubelet頒發(fā)服務(wù)端證書以及證書密鑰,從而不必為kubelet證書
3.4 創(chuàng)建kube-proxy kubeconfig文件
kubectl config set-cluster kubernetes \
  --certificate-authority=${CA_DIR}/ca.pem \
  --embed-certs=true \
  --server=${KUBE_APISERVER} \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-proxy.kubeconfig

kubectl config set-credentials kube-proxy \
  --client-certificate=${CA_DIR}/kube-proxy.pem \
  --client-key=${CA_DIR}/kube-proxy-key.pem \
  --embed-certs=true \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-proxy.kubeconfig

kubectl config set-context default \
  --cluster=kubernetes \
  --user=kube-proxy \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-proxy.kubeconfig

kubectl config use-context default \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kube-proxy.kubeconfig
3.5 創(chuàng)建kubectl kubeconfig文件
kubectl config set-cluster kubernetes \
  --certificate-authority=${CA_DIR}/ca.pem \
  --embed-certs=true \
  --server=${KUBE_APISERVER} \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kubectl.kubeconfig

kubectl config set-credentials admin \
  --client-certificate=${CA_DIR}/admin.pem \
  --client-key=${CA_DIR}/admin-key.pem \
  --embed-certs=true \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kubectl.kubeconfig

kubectl config set-context kubernetes \
  --cluster=kubernetes \
  --user=admin \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kubectl.kubeconfig

kubectl config use-context kubernetes \
  --kubeconfig=${K8S_KUBECONFIG_PATH}/kubectl.kubeconfig
  • --certificate-authority:驗(yàn)證 kube-apiserver 證書的根證書;
  • --client-certificate、--client-key:剛生成的 admin 證書和私鑰,連接 kube-apiserver 時(shí)使用;
  • --embed-certs=true:將 ca.pem 和 admin.pem 證書內(nèi)容嵌入到生成的 kubectl.kubeconfig 文件中(不加時(shí),寫入的是證書文件路徑);

備注:kubeconfig文件是用于安全連接apiserver服務(wù)的認(rèn)證文件。

4 同步token文件及kubeconfig文件到相應(yīng)的節(jié)點(diǎn)

  • master節(jié)點(diǎn):

    cd $K8S_KUBECONFIG_PATH
    ansible master_k8s_vgs -m copy -a \
    "src=kube-controller-manager.kubeconfig dest=$K8S_KUBECONFIG_PATH/ " -b
    ansible master_k8s_vgs -m copy -a \
    "src=kube-scheduler.kubeconfig dest=$K8S_KUBECONFIG_PATH/ " -b
  • worker節(jié)點(diǎn)
    cd $K8S_KUBECONFIG_PATH
    ansible worker_k8s_vgs -m copy -a \
    "src=bootstrap.kubeconfig dest=$K8S_KUBECONFIG_PATH/ " -b
    ansible worker_k8s_vgs -m copy -a \
    "src=kube-proxy.kubeconfig dest=$K8S_KUBECONFIG_PATH/ " -b
  • kubeconfig文件主要用于各組件在通過(guò)https訪問(wèn)apiserver時(shí)所需要的認(rèn)證的文件,該文件包括對(duì)應(yīng)組件的服務(wù)端證書、證書私鑰、ca根證書以及apiserver的訪問(wèn)地址

創(chuàng)建完kubernetes集群組件相關(guān)認(rèn)證文件后,接下來(lái)正式部署kubernetes集群相關(guān)組件etcd集群,請(qǐng)參考:kubernetes集群安裝指南:etcd集群部署


網(wǎng)站名稱:kubernetes集群安裝指南:客戶端安裝及各組件認(rèn)證文件創(chuàng)建
本文來(lái)源:http://weahome.cn/article/jpgcjp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部