亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

kubernetes集群安裝指南:客戶端安裝及各組件認證文件創建

發布時間:2020-07-31 02:24:31 來源:網絡 閱讀:465 作者:清白之年 欄目:云計算

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

1. 基本設置

1.1 變量設置
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 創建認證文件存放目錄
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. 創建 TLS Bootstrapping Token

cat > ${K8S_CONF_PATH}/token.csv <<EOF
${BOOTSTRAP_TOKEN},kubelet-bootstrap,10001,"system:kubelet-bootstrap"
EOF
  • bootstrapping token文件主要用于為apiserver開啟tocken認證而創建,如果沒有開啟apiserver token認證可以不用創建此文件;

3 kubeconfig文件創建

3.1 創建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 創建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 創建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證書做自動輪轉,使用該文件,apiserver會自動給kubelet頒發服務端證書以及證書密鑰,從而不必為kubelet證書
3.4 創建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 創建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:驗證 kube-apiserver 證書的根證書;
  • --client-certificate、--client-key:剛生成的 admin 證書和私鑰,連接 kube-apiserver 時使用;
  • --embed-certs=true:將 ca.pem 和 admin.pem 證書內容嵌入到生成的 kubectl.kubeconfig 文件中(不加時,寫入的是證書文件路徑);

備注:kubeconfig文件是用于安全連接apiserver服務的認證文件。

4 同步token文件及kubeconfig文件到相應的節點

  • master節點:

    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節點
    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文件主要用于各組件在通過https訪問apiserver時所需要的認證的文件,該文件包括對應組件的服務端證書、證書私鑰、ca根證書以及apiserver的訪問地址

創建完kubernetes集群組件相關認證文件后,接下來正式部署kubernetes集群相關組件etcd集群,請參考:kubernetes集群安裝指南:etcd集群部署

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

邯郸市| 手游| 五寨县| 富源县| 桓仁| 阳城县| 三江| 噶尔县| 乐平市| 永春县| 高密市| 祁门县| 丰镇市| 武穴市| 巴林右旗| 德阳市| 集安市| 万源市| 玉树县| 九江县| 平顶山市| 张掖市| 武清区| 庆云县| 新化县| 丹寨县| 平昌县| 怀化市| 仙桃市| 南昌县| 连云港市| 盖州市| 洪泽县| 蛟河市| 申扎县| 隆昌县| 长海县| 玉门市| 青浦区| 湾仔区| 宁国市|